IBitmapImage::LockBits
A version of this page is also available for
4/8/2010
This method lets applications lock an area of a bitmap image object and access bitmap data in the specified pixel format.
Syntax
HRESULT LockBits(
const RECT* rect,
UINT flags,
PixelFormatID pixelFormat,
BitmapData* lockedBitmapData
);
Parameters
- rect
[in] A pointer to a RECT structure that defines the region of the bitmap to lock.
flags
[in] A UINT value that describes the type of lock.This value must be an ImageLockMode enumeration value or a combination of ImageLockMode values.
This parameter must contain the values ImageLockModeRead or ImageLockModeWrite.
pixelFormat
[in] A PixelFormatID value that specifies the pixel format of the locked bitmap area.This value must be set to one of the PixelFormat Values.
To use the current pixel format of the bitmap image, set this value to PixelFormatDontCare.
Bitmap image objects don't need to support all pixel formats, but they must support the canonical pixel formats.
lockedBitmapData
[in, out] A pointer to an instance of a BitmapData class that contains data about the locked pixels.If the ImageLockModeUserInputBuf bit of the flags parameter is set, the lockedBitmapData->Scan0 and lockedBitmapData->Stride members must contain valid values on input.
Your application must call the IBitmapImage::UnlockBits method when it is done using the pixel data. Concurrent locks are not allowed on the same bitmap image object.
Return Value
If successful, this method returns S_OK.
If it fails, this method should return one of the following error values:
- IMGERR_BADLOCK
- IMGERR_OBJECTBUSY
- E_FAIL
- E_INVALIDARG
For more information, see Error Codes for the Imaging API.
Requirements
Header | imaging.h |
Library | Imaging.lib |
Windows Embedded CE | Windows CE 5.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |
See Also
Reference
IBitmapImage
ImageLockMode
PixelFormatID
PixelFormat Values
BitmapData
IBitmapImage::UnlockBits