Assembly: Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)
Syntax
| Visual Basic (Declaration) |
|---|
Public Class BitmapData _ Inherits LockableObject |
| C# |
|---|
public class BitmapData : LockableObject |
| Visual C++ |
|---|
public ref class BitmapData : public 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
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);
| |