---
title: "BitmapData Class"
canonical: https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_BitmapData.htm
product: "Graphics Mill 5.5 for .NET"
---

This documentation is for the old version. [Go to the latest Graphics Mill docs](https://www.graphicsmill.com/docs/gm/)

# BitmapData Class
 
This class provides direct access to the bitmap pixels.
 
**Namespace:** [Aurigma.GraphicsMill](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill.htm.md)
 **Assembly:** Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)
 
## Syntax
  
```
Public Class BitmapData _Inherits LockableObject
```
 
```csharp
public class BitmapData : LockableObject
```
 
## Remarks
  
To get this class instance you should use [LockBits(Int32, Int32, Int32, Int32)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Bitmap_LockBits_4_951ae041.htm.md) method. After you get it, you can work with this bitmap bits directly. Property [Scan0](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_BitmapData_Scan0.htm.md) returns an address to the beginning of the bitmap (the very first pixel). Property [Stride](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_BitmapData_Stride.htm.md) holds the offset from the beginning of the row (scan line) to the next row. Property [Height](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_BitmapData_Height.htm.md) contains number of scan lines in the section you lock. Using [PixelFormat](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_BitmapData_PixelFormat.htm.md) 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](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_BitmapData_MemoryUsed.htm.md) property.
 
If you need you also have an access to the bitmap associated with this bitmap data via [Bitmap](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_BitmapData_Bitmap.htm.md) property. The parameters of the bitmap area you captured are available through [Left](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_BitmapData_Left.htm.md), [Top](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_BitmapData_Top.htm.md), [Width](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_BitmapData_Width.htm.md) and [Height](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_BitmapData_Height.htm.md) properties.
 
After you finished working with the the bitmap data, you should release it by calling [UnlockBits(BitmapData)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Bitmap_UnlockBits_1_ed2555df.htm.md) method.
 
## Examples
  
```csharp
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](http://msdn2.microsoft.com/en-us/e5kfa45b)
    - [Aurigma.GraphicsMill.LockableObject](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_LockableObject.htm.md)
        - 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

[![](https://www.graphicsmill.com/docs/gm5/Aurigma.GraphicsMill_ObjectModel_39.png)](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_BitmapData.htm.md)
![](https://www.graphicsmill.com/docs/gm5/ObjectModel2.png)[![](https://www.graphicsmill.com/docs/gm5/Aurigma.GraphicsMill_ObjectModel_40.png)](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Bitmap.htm.md)
![](https://www.graphicsmill.com/docs/gm5/ObjectModel1.png)[![](https://www.graphicsmill.com/docs/gm5/Aurigma.GraphicsMill_ObjectModel_41.png)](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Bitmap.htm.md)
  
## See Also

### Reference

- [BitmapData Members](https://www.graphicsmill.com/docs/gm5/AllMembers_T_Aurigma_GraphicsMill_BitmapData.htm.md)
- [Aurigma.GraphicsMill Namespace](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill.htm.md)
