---
title: "Bitmap..::.LockBits Method "
canonical: https://www.graphicsmill.com/docs/gm5/O_T_Aurigma_GraphicsMill_Bitmap_LockBits.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/)

# Bitmap.LockBits Method 
 
Locks a rectangular area of the bitmap and returns [BitmapData](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_BitmapData.htm.md) object which provides direct access to pixels (without copying).
 
## Overload List

|   |  Name |  Description |
| --- | --- | --- |
 |  ![Public method](https://www.graphicsmill.com/docs/gm5/icons/pubmethod.gif) |  [LockBits()](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Bitmap_LockBits.htm.md) |  Locks a entire bitmap and returns [BitmapData](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_BitmapData.htm.md) object which provides direct access to pixels (without copying). |
 |  ![Public method](https://www.graphicsmill.com/docs/gm5/icons/pubmethod.gif) |  [LockBits(Rectangle)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Bitmap_LockBits_1_fbc750e9.htm.md) |  Locks a rectangular area of the bitmap and returns [BitmapData](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_BitmapData.htm.md) object which provides direct access to pixels (without copying). |
 |  ![Public method](https://www.graphicsmill.com/docs/gm5/icons/pubmethod.gif) |  [LockBits(RectangleF)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Bitmap_LockBits_1_a73b99d3.htm.md) |  Locks a rectangular area of the bitmap and returns [BitmapData](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_BitmapData.htm.md) object which provides direct access to pixels (without copying). |
 |  ![Public method](https://www.graphicsmill.com/docs/gm5/icons/pubmethod.gif) |  [LockBits(Int32, Int32, Int32, Int32)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Bitmap_LockBits_4_951ae041.htm.md) |  Locks a rectangular area of the bitmap and returns [BitmapData](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_BitmapData.htm.md) object which provides direct access to pixels (without copying). |
 |  ![Public method](https://www.graphicsmill.com/docs/gm5/icons/pubmethod.gif) |  [LockBits(Single, Single, Single, Single)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Bitmap_LockBits_4_37f6c741.htm.md) |  Locks a rectangular area of the bitmap and returns [BitmapData](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_BitmapData.htm.md) object which provides direct access to pixels (without copying). |
 
## Remarks
  
Each call of this method should be followed with subsequent [UnlockBits(BitmapData)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Bitmap_UnlockBits_1_ed2555df.htm.md) method call. You cannot lock bits one more time until you unlock them with [UnlockBits(BitmapData)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Bitmap_UnlockBits_1_ed2555df.htm.md). You can check if bits are locked with [BitsLocked](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Bitmap_BitsLocked.htm.md) property.
 
**Note** 
If the specified rectangular area excides the [Bitmap](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Bitmap.htm.md) dimensions you will get the [BitmapData](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_BitmapData.htm.md) object with the same dimensions as an initial [Bitmap](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Bitmap.htm.md). Therefore, to avoid further errors, you should use the [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 of this [BitmapData](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_BitmapData.htm.md) object instead of the specified rectangle dimensions.
   
## See Also

### Reference

- [Bitmap Class](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Bitmap.htm.md)
- [Bitmap Members](https://www.graphicsmill.com/docs/gm5/AllMembers_T_Aurigma_GraphicsMill_Bitmap.htm.md)
- [Aurigma.GraphicsMill Namespace](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill.htm.md)
