GetBitmapData
int GetBitmapData (int bitmapID, int *bytesPerRow, int *pixelDepth, int *width, int *height, int colorTable[], unsigned char bits[], unsigned char mask[]);
Purpose
![]() |
Note This function has been superseded by GetBitmapDataEx, which you can use to get alpha-channel data. |
Obtains the bit values that define the image associated with a bitmap. Before calling GetBitmapData, you must do one of the following:
- Call GetBitmapInfo to get the size of the buffers to pass and then allocate the buffers.
- Call AllocBitmapData.
You can obtain the ID of the bitmap object from functions such as GetCtrlBitmap.
If the bitmap originated from a Windows metafile (.wmf or .emf), the size of the bitmap obtained by this function is the size stored in the original Windows metafile.
Parameters
Input | ||
Name | Type | Description |
bitmapID | int | ID of the bitmap object that contains the image. You can obtain the ID from functions such as NewBitmap and GetCtrlBitmap. |
Output | ||
Name | Type | Description |
bytesPerRow | int | Number of bytes on each scan line of the image. You can pass NULL for this parameter. |
pixelDepth | int | Number of bits per pixel. The valid values for the pixelDepth parameter are 1, 4, 8, 24, or 32. You can pass NULL for this parameter. |
width | int | Width of the image, in pixels. You can pass NULL for this parameter. |
height | int | Height of the image, in pixels. You can pass NULL for this parameter. |
colorTable | int [] | Array of RGB color values, or NULL if pixelDepth is greater than 8. If pixelDepth is 8 or less, the bits array contains indices into the colorTable array. The number of entries in the colorTable array must equal 2n, where n is the value of the pixelDepth parameter. If pixelDepth is greater than 8, the colorTable parameter is not used. The bits array contains actual RGB color values rather than indices into the colorTable array. If GetBitmapInfo sets the colorSize parameter to 0, this array is not filled in. You can pass NULL for this parameter. |
bits | unsigned char [] | Array of bits that determines the colors to display on each pixel in the image. The number of bits per pixel is equal to the pixelDepth value. The first pixel in the bits array is at the upper-left corner of the image. The pixels in the array are stored in row-major order. If pixelDepth is 8 or less, the bits array contains indices into the colorTable array. If pixelDepth is greater than 8, the colorTable array is not used, and the bits array contains the actual RGB values. If pixelDepth is 24, each pixel is represented by a 24-bit RGB value of the form RRGGBB, where RR, GG, and BB represent the red, green, and blue components of the color value. The RR byte is at the lowest memory address of the three bytes. If pixelDepth is 32, each pixel is represented by a 32-bit RGB value of the form 0x00RRGGBB, where RR, GG, and BB represent the red, green, and blue components of the color value. The 32-bit value is treated as a native 32-bit integer value. The BB byte is in the least significant byte and, therefore, is at the lowest memory address of the four bytes. The most significant byte of this integer is ignored. Notice that this byte ordering scheme differs from the byte ordering scheme when pixelDepth is 24. You can pass NULL for this parameter. |
mask | unsigned char [] | Array that determines which pixels in the image to draw. Use the mask array to achieve binary transparency. The mask array contains one bit for each pixel in the image. A mask array bit value of 1 indicates that the pixel is drawn; a mask array bit value of 0 indicates that the pixel is not drawn. When pixelDepth is 1, the pixels that have a bits array value of 1 are always drawn, regardless of the mask array value. In this case, the mask array affects only the pixels that have a bits array value of 0. You must pad each row of the mask array to the nearest even-byte boundary. For example, if the width of the image is 21 pixels, then each row of the mask array must have 32 bits (four bytes) of data. If GetBitmapInfo sets the maskSize parameter to 0, this array is not filled in. You can pass NULL for this parameter. |
Return Value
Name | Type | Description |
status | int | Return value indicating whether the function was successful. A negative number indicates that an error occurred. |
Additional Information
Library: User Interface Library
Include file: userint.h
LabWindows/CVI compatibility: LabWindows/CVI 4.0 and later