CBitmap

Win32++

CBitmap Class

Description

The class responsible for creating and managing bitmap resources.

CBitmap Members

Initialization and Assignment
CBitmap
CBitmap();
CBitmap(HBITMAP hBitmap);
CBitmap(LPCTSTR lpstr);
CBitmap(int nID);
Constructs a CBitmap object.
FromHandle
static CBitmap* FromHandle(HBITMAP hBitmap);
Returns the CBitmap associated with the specified bitmap handle. If a CBitmap object doesn't already exist, a temporary CBitmap object is created. This temporary CBitmap will be deleted sometime after the processing of the current message is complete. operator HBITMAP()
operator HBITMAP() const;
Allows a CBitmap object to be used as a bitmap handle (HBITMAP).   Attributes GetBitmapData
BITMAP GetBitmapData() const;
Retrieves the BITMAP structure of the attached bitmap. GetBitmapDimensionEx
CSize GetBitmapDimensionEx() const;
Retrieves the dimensions of a compatible bitmap. The retrieved dimensions must have been set by the SetBitmapDimensionEx function. GetDIBits
int GetDIBits(CDC* pDC, UINT uStartScan, UINT cScanLines, 
              LPVOID lpvBits, LPBITMAPINFO lpbmi, UINT uColorUse) const;
Retrieves the bits of the specified compatible bitmap and copies them into a buffer as a DIB using the specified format. SetBitmapDimensionEx
CSize SetBitmapDimensionEx(int nWidth, int nHeight);
Assigns preferred dimensions to a bitmap. These dimensions can be used by applications; however, they are not used by the system. SetDIBits
int SetDIBits(CDC* pDC, UINT uStartScan, UINT cScanLines, 
              CONST VOID* lpvBits, CONST BITMAPINFO* lpbmi, UINT uColorUse);
Sets the pixels in a compatible bitmap (DDB) using the color data found in the specified DIB.   Operations CreateBitmap
HBITMAP CreateBitmap(int nWidth, int nHeight, UINT nPlanes, 
                      UINT nBitsPerPixel, LPCVOID lpBits);
Creates a bitmap with the specified width, height, and color format (color planes and bits-per-pixel). CreateBitmapIndirect
HBITMAP CreateBitmapIndirect(LPBITMAP lpBitmap);
Creates a bitmap with the width, height, and color format specified in the BITMAP structure. CreateCompatibleBitmap
HBITMAP CreateCompatibleBitmap(CDC* pDC, int nWidth, int nHeight);
Creates a bitmap compatible with the device that is associated with the specified device context. CreateDIBitmap
HBITMAP CreateDIBitmap(CDC* pDC, CONST BITMAPINFOHEADER* lpbmih, DWORD dwInit,
                       LPCVOID lpbInit, CONST BITMAPINFO* lpbmi, UINT uColorUse);
Creates a compatible bitmap (DDB) from a DIB and, optionally, sets the bitmap bits. CreateDIBSection
HBITMAP CreateDIBSection(CDC* pDC, CONST BITMAPINFO* lpbmi, UINT uColorUse,
                         LPVOID* ppvBits, HANDLE hSection, DWORD dwOffset);
Creates a DIB that applications can write to directly. The function gives you a pointer to the location of the bitmap bit values. CreateMappedBitmap
HBITMAP CreateMappedBitmap(UINT nIDBitmap, UINT nFlags = 0,
                          LPCOLORMAP lpColorMap = NULL, int nMapSize = 0);
Creates a new bitmap using the bitmap data and colors specified by the bitmap resource and the color mapping information. GrayScaleBitmap
void GrayScaleBitmap(HBITMAP hbmSource);
Creates a gray scale bitmap from the specified bitmap. LoadBitmap
BOOL LoadBitmap(LPCTSTR lpszName);
BOOL LoadBitmap(int nID);
Loads a bitmap from a resource using the resource string. LoadImage
BOOL LoadImage(LPCTSTR lpszName, int cxDesired, int cyDesired, UINT fuLoad);
BOOL LoadImage(UINT nID, int cxDesired, int cyDesired, UINT fuLoad);
Loads a bitmap from a resource using the resource ID. LoadOEMBitmap
BOOL LoadOEMBitmap(UINT nIDBitmap);
Loads a predefined bitmap. TintBitmap
HIMAGELIST CreateDisabledImageList( HIMAGELIST himlNormal );
Modifies the colour of the supplied Device Dependant Bitmap, by the colour correction values specified. The correction values can range from -255 to +255.
Base class Members

For base class members, refer to the members of CGDIObject.

Remarks

CBitmap objects can be used anywhere a a handle to a bitmap (HBITMAP) might be used.  They can be substituted for the HBITMAP in any of the Windows API functions which use a HBITMAP as a function argument.  The benefit of using a CBitmap object is that it automatically deletes the bitmap when it is destroyed.

Refer to the Graphics Device Interface section of Using Win32++ for additional information on using this class.

Summary Information

Header file gdi.h
Win32/64 support Yes
WinCE support Yes