CGDIBitmap Class

class CGDIBitmap: public CGDIObject

Encapsulates a GDI bitmap object.

Defined in: GDIObjects.h

Class Members

CGDIBitmap(HBITMAP h = NULL, bool bOwn = true)

Attach constructor. Initializes a new instance of CGDIBitmap and optionally attaches a previously existing bitmap handle. The ownership of this handle is determined by the bOwn parameter.

CGDIBitmap(CGDIBitmap& rhs, bool bTransferOwnership = true)

Copy constructor. Takes an existing CGDIBitmap instance and copies its contents to the new instance being constructed. If the object being copied is the owner of the handle, ownership's transference is controlled by the parameter bTransferOwnership.

CGDIBitmap(int nPenStyle, int nWidth, COLORREF cr)

Creation constructor. Takes the parameters necessary to create a GDI pen object and attaches it to the new instance.

CGDIBitmap(int nPenStyle, int nWidth, COLORREF cr)

Indirect creation constructor. Takes the parameters necessary to create a GDI pen object and attaches it to the new instance.

CGDIBitmap& operator =(CGDIBitmap& rhs)

Copies the contents of the passed object into this instance. Ownership is always transfered if it belongs to the object being copied.

bool LoadBitmap(LPCTSTR lpszResourceName, HINSTANCE hInstResource = GetResourceHandle())

Loads a bitmap from resources

bool LoadBitmap(UINT nIDResource, HINSTANCE hInstResource = GetResourceHandle())

Loads a bitmap from resources

bool CreateBitmap(int nWidth, int nHeight, UINT nPlanes, UINT nBitcount, const void* lpBits)

Loads windows stock bitmap for OBM_/OCR_/OIC_

bool CreateBitmap(int nWidth, int nHeight, UINT nPlanes, UINT nBitcount, const void* lpBits)

Create a bitmap from direct parameters

bool CreateBitmapIndirect(LPBITMAP lpBitmap)

Create a new bitmap from BITMAP structure

bool CreateCompatibleBitmap(HDC hdc, int nWidth, int nHeight)

Create a bitmap compatible with the DC given

bool CreateDiscardableBitmap(HDC hdc, int nWidth, int nHeight)

Create a discardable bitmap

int GetBitmap(BITMAP* pBitMap)

Retrieve the BITMAP structure that describes this bitmap

CSize GetBitmapSize() const

Retrieve the size of the bitmap

DWORD SetBitmapBits(DWORD dwCount, const void* lpBits)

Set bits in the bitmap data

DWORD GetBitmapBits(DWORD dwCount, LPVOID lpBits) const

Get bits from the bitmap data

CSize SetBitmapDimension(int nWidth, int nHeight)

Set the dimensions of the bitmap

CSize GetBitmapDimension() const

Retrieve the dimensions of the bitmap