CreateBitmap

  HBITMAP CreateBitmap(nWidth, nHeight, cPlanes, cBitsPerPel, lpvBits)    
  int nWidth; /* bitmap width in pixels */
  int nHeight; /* bitmap height in pixels */
  UINT cPlanes; /* number of color planes used by device */
  UINT cBitsPerPel; /* number of bits required to identify a color */
  CONST VOID *lpvBits; /* address of array containing color data */

The CreateBitmap function creates a bitmap with the given width, height, and color format (color planes and bits per pixel).

Parameters

nWidth

Specifies the bitmap width in pixels.

nHeight

Specifies the bitmap height in pixels.

cPlanes

Specifies the number of color planes used by the device.

cBitsPerPel

Specifies the number of bits required to identify the color of a single pixel.

lpvBits

Points to an array of color data that is used to set the colors in a rectangle of pixels. Each scanline in the rectangle must be dword aligned (scanlines which aren't dword aligned must be padded with zeros). If this argument is NULL, the new bitmap is undefined.

Return Value

The return value identifies a bitmap if the function is successful. Otherwise, it is 0.

Comments

The CreateBitmap function should only be used to create monochrome bitmaps. The CreateDIBitmap function should be used to create color bitmaps. If the bitmap is monochrome, 0's represent the foreground color and 1's represent the background color for the destination device context.

Once a bitmap is created, it can be selected into a device context by calling the SelectObject function.

See Also

CreateDIBitmap, DeleteObject, SelectObject