Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
The ability to create a bitmap file opens many doors if you're working in a Microsoft Windows environment. On my last project, for example, I had to interface Java with Microsoft Access. The Java program allowed the user to draw a map on the screen. The map was then printed in a Microsoft Access report. Because Java doesn't support OLE, my only solution was to create a bitmap file of the map and tell the Microsoft Access report where to pick it up. If you've ever had to write an application to send an image to the clipboard, this tip may be of use to you -- especially if this information is being passed to another Windows application.
The bitmap file format supports 4-bit RLE (run length encoding), as well as 8-bit and 24-bit encoding. Because we're only dealing with the 24-bit format, let's take a look at the structure of the file.
The bitmap file is divided into three sections. I've laid them out for you below.
This header contains information about the type size and layout of the bitmap file. The structure is as follows (taken from a C language structure definition):
typedef struct tagBITMAPFILEHEADER {
UINT bfType;
DWORD bfSize;
UINT bfReserved1;
UINT bfReserved2;
DWORD bfOffBits;
}BITMAPFILEHEADER;
Here's a description of the code elements from the above listing:
bfType: Indicates the type of the file and is always set to BM.
bfSize: Specifies the size of the whole file in bytes.
bfReserved1: Reserved -- must be set to 0.
bfReserved2: Reserved -- must be set to 0.
bfOffBits: Specifies the byte offset from the BitmapFileHeader to the start of the image.
Here you've seen that the purpose of the bitmap header is to identify the bitmap file. Every program that reads bitmap files uses the bitmap header for file validation.
The next header, called the information header, contains all the properties of the image itself.
Here's how you specify information about the dimension and the color format of a Windows 3.0 (or higher) device independent bitmap (DIB):
typedef struct tagBITMAPINFOHEADER {
DWORD biSize;
LONG biWidth;
LONG biHeight;
WORD biPlanes;
WORD biBitCount;
DWORD biCompression;
DWORD biSizeImage;
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
} BITMAPINFOHEADER;
Each element of the above code listing is described below:
biSize: Specifies the number of bytes required by the BITMAPINFOHEADER structure.
biWidth: Specifies the width of the bitmap in pixels.
biHeight: Specifies the height of the bitmap in pixels.
biPlanes: Specifies the number of planes for the target device. This member must be set to 1.
biBitCount: Specifies the number of bits per pixel. This value must be 1, 4, 8, or 24.
biCompression: Specifies the type of compression for a compressed bitmap. In a 24-bit format, the variable is set to 0.
BI_RGB format.
biBitCount is set to 24, biClrUsed specifies the size of the reference color table used to optimize performance of Windows color palettes.
Now all the information needed to create the image has been defined.