IReadableBitmapDataGetPixel Method

KGy SOFT Drawing Libraries Help
Gets the color of the pixel at the specified coordinates.
See the Remarks section for details.

Namespace:  KGySoft.Drawing.Imaging
Assembly:  KGySoft.Drawing (in KGySoft.Drawing.dll) Version: 5.1.0

Color GetPixel(
	int x,
	int y


Type: SystemInt32
The x-coordinate of the pixel to retrieve.
Type: SystemInt32
The y-coordinate of the pixel to retrieve.

Return Value

Type: Color
A Color instance that represents the color of the specified pixel.

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.

If multiple pixels need to be retrieved process the bitmap line by line for better performance.

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

The returned value 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 ReadRaw method.

Note Note
For information about the possible usable PixelFormats on different platforms see the Remarks section of the ConvertPixelFormat method.
Note Note
See the Examples section of the GetReadWriteBitmapData method for examples.
See Also