IWritableBitmapDataSetPixel Method

Sets the color of the pixel at the specified coordinates.


Namespace: KGySoft.Drawing.Imaging
Assembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 7.0.0-preview.3
void SetPixel(
	int x,
	int y,
	Color color


x  Int32
The x-coordinate of the pixel to set.
y  Int32
The y-coordinate of the pixel to set.
color  Color
A Color structure that represents the color to assign to the specified pixel.


Use the SetColor32 method for a slightly better performance.

Line by line processing is also possible by obtaining the first row by the FirstRow property, setting the pixels by the IWritableBitmapDataRow members and then moving to the next line by the MoveNextRow method.

The color argument represents a straight (non-premultiplied) color with gamma correction γ = 2.2, regardless of the underlying PixelFormat. To access the actual PixelFormat-dependent raw value obtain a row and use the WriteRaw method.

If the color to be set is not supported by owner IReadWriteBitmapData, then it will be quantized to a supported color value.


ObjectDisposedExceptionThis IWritableBitmapData has already been disposed.
ArgumentOutOfRangeExceptionx is less than zero or is greater than or equal to Width.
y is less than zero or is greater than or equal to Height.

See Also