IReadableBitmapDataGetColorIndex Method

If this IReadableBitmapData is an indexed one, then gets the color index of the pixel in the current row of the specified pixel.

Definition

Namespace: KGySoft.Drawing.Imaging
Assembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 10.0.0-rc.1
C#
int GetColorIndex(
	int x,
	int y
)

Parameters

x  Int32
The x-coordinate of the color index to retrieve.
y  Int32
The y-coordinate of the color index to retrieve.

Return Value

Int32
A palette index that represents the color of the specified pixel.

Remarks

This method can be used only if Indexed is set in the PixelFormat of this IReadableBitmapData. Otherwise, this method throws an InvalidOperationException.

To get the actual color of the pixel at the specified coordinates you can use the GetColor.../GetPColor... methods, or you can call the Palette.GetColor method with the return value of this method on the Palette instance returned by the Palette property of this IReadableBitmapData.

Exceptions

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.
InvalidOperationExceptionThis IReadableBitmapData does not have an indexed pixel format.

See Also