Meet us at PRINT 19. Chicago, IL. Oct. 3 - 5.
This documentation is for the old version. Go to the latest Graphics Mill docs

Bitmap.GetPixel Method

Returns pixel value at specified coordinates.

Namespace: Aurigma.GraphicsMill
Assembly: Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)

Syntax

Visual Basic
Public Function GetPixel ( _
	x As Integer, _
	y As Integer _
) As Color
C#
public Color GetPixel(
	int x,
	int y
)

Parameters

x

Type: System.Int32

Horizontal position of the pixel.
y

Type: System.Int32

Vertical position of the pixel.

Return Value

Pixel value at the specified position. The actual type of the returned object depends on color space of the bitmap. E.g. if bitmap is in RGB color space, actual type will be RgbColor, etc.

Remarks

This method was implemented for easy but slow access to pixels. It works ideally if you need to get one pixel value, for example, when you implement color picker. However if you need iterate each pixel in bitmap, it will work too slow. In this case you should consider using LockBits() method instead. It will provide you a direct access to pixels.

Examples

Visual Basic
bitmap.SetPixel(120, 100, Aurigma.GraphicsMill.RgbColor.Red)

Dim color As Aurigma.GraphicsMill.RgbColor = bitmap.GetPixel(100, 80)
C#
bitmap.SetPixel(120, 100, Aurigma.GraphicsMill.RgbColor.Red);

Aurigma.GraphicsMill.RgbColor color =
    (Aurigma.GraphicsMill.RgbColor)(bitmap.GetPixel(100, 80));

See Also

Reference