IReadableBitmapDataRowGetColorIndex Method

If the owner IReadableBitmapData is an indexed one, then gets the color index of the pixel in the current row at the specified x coordinate.


Namespace: KGySoft.Drawing.Imaging
Assembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 8.0.0-preview.1
int GetColorIndex(
	int x


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

Return Value

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


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

To set the actual color of the pixel at the x coordinate you can use the GetColor.../GetPColor... methods or the indexer, 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 the parent IReadableBitmapData.


ArgumentOutOfRangeExceptionx is less than zero or is greater than or equal to the Width of the parent IReadableBitmapData.
InvalidOperationExceptionThis IReadableBitmapDataRow does not belong to a row of an indexed IReadableBitmapData.

See Also