Bitmap.Scan0 Property

Gets the pointer to the very first pixel of this bitmap.

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

Syntax

C#
public IntPtr Scan0 { get; }

Property Value

The address of the first pixel of this bitmap.

Examples

C#
using (var bitmap = new Bitmap(@"Images\in.jpg"))
{
    unsafe
    {
        //A pointer to the beginning of the pixel data region
        byte* pointer = (byte*)(bitmap.Scan0.ToPointer());
        //Number of bytes in a row
        int stride = bitmap.Stride;
        //Number of rows
        int height = bitmap.Height;

        for (int i = 0; i < height; i++)
        {
            byte* position = pointer + stride * i;
            for (int j = 0; j < stride; j++)
            {
                //Now we can modify the pixel, for example, invert it
                *position = (byte)(255 - *position);
                position++;
            }
        }
    }
    bitmap.Save(@"Images\Output\out.jpg");
}

See Also

Reference

Manual