Device-related bitmap DDB (device-dependent-Bitmap)
DDB does not have its own color palette information. Its color mode must be consistent with that of the output device. For example, the pixel value stored in a bitmap with less than 256 colors is the index of the system palette, and its color depends on the system palette. Because DDB is highly dependent on the output device, it can only exist in the memory, either in the video memory or in the system memory.
Device-Independent Bitmap (DIB)
DiB has its own palette information, which can be independent of the system's palette. Because it is not dependent on the device, all commonly used tokens are used to store files. For example, A. BMP file is DiB.
Differences between hbitmap and bitmap
bitmap is a structure:
typedef struct tagbitmap {/* BM */
int bmtype;
int bmwidth;
int bmheight;
int bmwidthbytes;
byte bmplanes;
byte bmbitspixel;
lpvoid bmbits;
} bitmap;
hbitmap is a handle pointing to bitmap.
Hbitmap hbmp = (hbitmap): LoadImage (AfxGetInstanceHandle (),
"Aaa.bmp", image_bitmap, 0, 0, lr_createdibsection | lr_loadfromfile );
Bitmap bm;
GetObject (hbmp, sizeof (BM), & BM); this function can be used to obtain bitmap from hbitmap;
For example, he used bitmapto construct a. BMP file.
Loadimagereads The. BMP file from the cookbook and converts it into an hbitmap file that is easy to operate by the system. However, bitmap data needs to be stored in many cases, such as: storage, d3dxcreatetexturefromfileinmemory(.bmp format strictly formatted data;
Construct bitmapfileheader bfileh, and fill in; construct and fill bitmapinfoheader binfoh;
Copy the above two data and the bitmap. bmbits data to a buffer zone;
Memcpy (buffer, sizeof (bitmapfileheader), bfileh );
Memcpy (& buffer [sizeof (bitmapfileheader)], sizeof (bitmapinfoheader), binfoh );
Memcpy (& buffer [sizeof (bitmapfileheader) + sizeof (bitmapinfoheader)], bytes in the graphic data area, bitmap. bmbits );
Other DiB and DDB functions:
Getdibits (); // obtain the Custom Data zone of hbitmap. You must obtain a space to accept the data;
Getbitmapbits (); // obtain the specified data zone of Bitmap in hbitmap.
Createdibsection (); // create a custom bitmap