This documentation is for the old version. Go to the latest Graphics Mill docs

BitmapData Class

This class provides direct access to the bitmap pixels.

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

Syntax

Visual Basic
Public Class BitmapData _
	Inherits LockableObject
C#
public class BitmapData : LockableObject

Remarks

To get this class instance you should use LockBits(Int32, Int32, Int32, Int32) method. After you get it, you can work with this bitmap bits directly. Property Scan0 returns an address to the beginning of the bitmap (the very first pixel). Property Stride holds the offset from the beginning of the row (scan line) to the next row. Property Height contains number of scan lines in the section you lock. Using PixelFormat you can get pixel-specific information. If you need to know how much bytes is taken by the captured area (for example, if you need to allocate buffer of the same size), you can use MemoryUsed property.

If you need you also have an access to the bitmap associated with this bitmap data via Bitmap property. The parameters of the bitmap area you captured are available through Left, Top, Width and Height properties.

After you finished working with the the bitmap data, you should release it by calling UnlockBits(BitmapData) method.

Examples

C#
Aurigma.GraphicsMill.BitmapData bitmapData = bitmap.LockBits();

unsafe
{
    byte* pos;
    byte* scan0 = (byte*)(bitmapData.Scan0.ToPointer());
    int stride = bitmapData.Stride;

    int widthInBytes = bitmapData.Width * bitmapData.BitsPerPixel / 8;
    int height = bitmapData.Height;

    for (int j = 0; j < height; j++)
    {
        pos = scan0 + stride * j;
        for (int i = 0; i < widthInBytes; i++)
        {
            *pos = (byte)(255 - *pos);
            pos++;
        }
    }
}

bitmap.UnlockBits(bitmapData);

Inheritance Hierarchy

System.Object
L Aurigma.GraphicsMill.LockableObject
L Aurigma.GraphicsMill.BitmapData

Thread Safety

Static members of this type are safe for multi-threaded operations. Instance members of this type are safe for multi-threaded operations.

Object Model





See Also

Reference