Basic steps for manipulating bitmaps:
* Create a bitmap handle
* Loading Bitmap objects
* Create a memory Device description object, select the bitmap into the memory device description object
* Graphic drawing using the drawing function
* Delete Bitmap handle
Create a bitmap handle and load the bitmap object:
* Bitmap Handle
Hbitmap hbmp
*bool LoadBitmap (
HInstance Hlnstance,
LPCTSTR lpbitmapname);
* There are two types of bitmap resources:
System built-in resources
Application Bitmap Resources
Hbitmap CreateBitmap (
int nwidth,//refers to the width of the mapping
int nheight,//refers to the height of the location map
UINT Cplanes,//number of color bits used by the device, 1 in CE environment
UINT cbitsperal,//Specifies the number of bits used per pixel, typically 2 of the n-th square
CONST VOID *lpbits)//Pointer to color data array
Examples include:
hbmp = Creatbitmap (20,5,1,4,bits);
Hbitmap Shloaddlbitmap (LPCTSTR szfilename);
Display steps for bitmaps:
* Create a memory device environment
* Select the bitmap handle into the device memory environment
* Call the transfer function to display the bitmap on the device
Memory Device Environment:
* The role of the memory device environment:
To improve access speed and match the settings of the bitmap with the settings of the device environment, Windows CE first loads the bitmap into the memory device environment and then assigns the value from memory to the device environment.
*HDC CreateCompatibleDC (hdc hdc);
* Bitmap Selection Device object using: SelectObject () function
Functions for transmitting data blocks:
BOOL BitBlt (
HDC hdcdest,//handle to target device environment
int Nxdest,int nydest,//logical coordinates of the upper-left corner of the target rectangle area
int Nwidth,int nheight,//width and height of the target rectangle area
HDC hdcsrc,//handle to the source drawing environment
int Nxsrc,int NYSRC,//logical coordinates of the upper-left corner of the source drawing
DWORD dwrop); Set raster operation code for execution
*srccopy Copy the source bitmap to the target bitmap
BOOL Stretchbit (
HDC Hdcdest,
int Nxorigindest,int Nyorigindest,
int Nwidthdest,int Nheightdest,
HDC hDCSrc,
int Nxoriginsrc,int NYORIGINSRC,
int Nwidthsrc,int NHEIGHTSRC,
UINT crtransparent);
WinCE use of bitmaps