IWritableBitmapDataSetPixel Method

Sets the color of the pixel at the specified coordinates from a Color value.

Definition

Namespace: KGySoft.Drawing.Imaging
Assembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 8.1.0
C#
void SetPixel(
	int x,
	int y,
	Color color
)

Parameters

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

Remarks

The color parameter represents a non-premultiplied color with 8 bits per channel in the sRGB color space, regardless of the underlying PixelFormat. The SetColor32 method works with the same range of colors as this one and has 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 IWritableBitmapDataRowMovable members and then moving to the next line by the MoveNextRow method.

To access the actual PixelFormat-dependent raw value obtain a row and use the WriteRaw method.

If the color to be set cannot be represented precisely by the owner IWritableBitmapData, then it will be quantized to a supported color value.

Exceptions

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

See Also