GdipBitmapLockBits

 

 

Description

Locks a rectangular portion of this bitmap and provides a temporary buffer that you can use to read or write pixel data in a specified format. Any pixel data that you write to the buffer is copied to the Bitmap object when you call GdipBitmapUnlockBits.

Syntax

GpStatus WINGDIPAPI GdipBitmapLockBits(

    GpBitmap* bitmap,

    GDIPCONST GpRect* rect,

    UINT flags,

    PixelFormat format,

    BitmapData* lockedBitmapData

);

PowerBASIC Syntax

DECLARE FUNCTION GdipBitmapLockBits ( _

    BYVAL pbitmap AS DWORD, _

    BYREF prect AS RECTL, _

    BYVAL flags AS LONG, _

    BYVAL PixelFormat AS LONG, _

    BYREF lockedBitmapData AS BitmapData _

) AS LONG

Parameters

 

bitmap

[in] Pointer to the Bitmap object.

rec

[in] Pointer to a rectangle that specifies the portion of the bitmap to be locked.

flags

[in] Set of flags that specify whether the locked portion of the bitmap is available for reading or for writing and whether the caller has already allocated a buffer. Individual flags are defined in the ImageLockMode enumeration.

format

[in] Long integer value that specifies the format of the pixel data in the temporary buffer. The pixel format of the temporary buffer does not have to be the same as the pixel format of this Bitmap object. Microsoft® Windows® GDI+ version 1.0 does not support processing of 16-bits-per-channel images, so you should not set this parameter equal to PixelFormat48bppRGB, PixelFormat64bppARGB, or PixelFormat64bppPARGB.

lockedBitmapData

[in, out] Pointer to a BitmapData object. If the ImageLockModeUserInputBuf flag of the flags parameter is cleared, then lockedBitmapData serves only as an output parameter. In that case, the Scan0 data member of the BitmapData object receives a pointer to a temporary buffer, which is filled with the values of the requested pixels. The other data members of the BitmapData object receive attributes (width, height, format, and stride) of the pixel data in the temporary buffer. If the pixel data is stored bottom-up, the Stride data member is negative. If the pixel data is stored top-down, the Stride data member is positive. If the ImageLockModeUserInputBuf flag of the flags parameter is set, then lockedBitmapData serves as an input parameter (and possibly as an output parameter). In that case, the caller must allocate a buffer for the pixel data that will be read or written. The caller also must create a BitmapData object, set the Scan0 data member of that BitmapData object to the address of the buffer, and set the other data members of the BitmapData object to specify the attributes (width, height, format, and stride) of the buffer.

Remarks

GdipBitmapLockBits and GdipBitmapUnlockBits must be used as a pair. A call to GdipBitmapLockBits establishes a temporary buffer that you can use to read or write pixel data in a specified format. After you write to the temporary buffer, a call to GdipBitmapUnlockBits copies the pixel data in the buffer to the Bitmap object. If the pixel format of the temporary buffer is different from the pixel format of the Bitmap object, the pixel data is converted appropriately.

 

Valid HTML 4.01 Transitional