ImageGear Professional v18.4 > User Guide > Appendices/General Reference > Understanding Bitmap Images > Device-Independent/Device-Dependent Bitmaps > Device-Independent Bitmaps (DIB) |
A DIB consists of a header structure called a BITMAPINFOHEADER followed by the color palette, if one is present, followed by the bitmap (pixel) data:
BITMAPINFOHEADER |
COLOR PALETTE (if any) |
BITMAP DATA |
The BITMAPINFOHEADER structure contains such information as the number of bits per pixel, number of pixels per row, and total number of rows in the image, as well as whether the bitmap data has been compressed for more efficient storage. Its form is shown below. Its fields are described in detail in the sections Core Component Data Types Reference and Core Component Structures Reference.
BITMAPINFOHEADER: | DWORD | biSize |
LONG | biWidth | |
LONG | biHeight | |
WORD | biPlanes | |
WORD | biBitCount | |
DWORD | biCompression | |
DWORD | biSizeImage | |
LONG | biXPelsPerMeter | |
LONG | biYPelsPerMeter | |
DWORD | biClrUsed | |
DWORD | biClrImportant |
A color palette is present in the DIB if the image is 1-bit, 4-bit, or 8-bit. The format of the color palette was described at the beginning of this chapter.
The format of the bitmap data is:
It should be noted that in a DIB, the first row of the bitmap data is the row to be displayed at the bottom of the image. For historical reasons, many file formats store their bitmap data top row first (this is because most devices to which bitmap data is sent display the rows top-to-bottom. Such devices, which include most CRT display monitors, are often called raster-scan devices.).
Whenever ImageGear loads a file of a format having top-to-bottom row ordering, it automatically reverses the order of the rows, assuring bottom-to-top row ordering for all DIBs, regardless of where the image originated. Keep in mind the ordering of a DIB is therefore "upside down" relative to the convention used in much display software that the top row of a display is row 0 and row numbers increase downward. However, it is important to note, ImageGear's pixel access functions (such as IG_DIB_pixel_set()) consider the coordinates 0,0 to refer to the upper left-hand corner of the bitmap data. As with an image shown on the screen, the x values will increase toward the right, and the y values will increase toward the bottom.
ImageGear Architecture Diagram