RasterImageGetPixel Method
Gets an image pixel.

Namespace: Aspose.Imaging
Assembly: Aspose.Imaging (in Aspose.Imaging.dll) Version: 21.05
public Color GetPixel(
	int x,
	int y


Type: SystemInt32
The pixel x location.
Type: SystemInt32
The pixel y location.

Return Value

Type: Color
The pixel color for the specified location.
The following example loads a raster image and obtains the color of an arbitrary pixel.

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\sample.png"))
    Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

    // Get the color of the top-left pixel of the image.
    Color color = rasterImage.GetPixel(0, 0);

    // Obtain the values of the individual color components
    byte alpha = color.A;
    byte red = color.R;
    int green = color.G;
    int blue = color.B;

    System.Console.WriteLine("The color of the pixel(0,0) is A={0},R={1},G={2},B={3}", alpha, red, green, blue);
See Also