Theoretical Paper
- Computer Organization
- Data Structure
- Digital Electronics
- Object Oriented Programming
- Discrete Mathematics
- Graph Theory
- Operating Systems
- Software Engineering
- Computer Graphics
- Database Management System
- Operation Research
- Computer Networking
- Image Processing
- Internet Technologies
- Micro Processor
- E-Commerce & ERP
Practical Paper
Industrial Training
BMP File Format
Windows bitmaps are stored in a device-independent bitmap (DIB) format that allows windows to display the bitmap on any type of display device. The term "device independent" means that the bitmap specifies pixel color in a form independent of the method used by a display to represent color. The default filename extension of a Windows DIB file is .BMP.
Each bitmap file contains a bitmap-file header, a color table, and an array of bytes that defines the bitmap bits. Let us understand these three entities in detail.
Bitmap Header
The bitmap-file header contains information about the type, size, layout, dimensions, compression type, and color format of a device-independent bitmap file. The bytewise distribution of this head is given in Figure 1
|
|
|
|
|
Item |
Bytes |
|
|
signature - 'BM' |
2 |
|
|
size of file in bytes |
4 |
|
|
Reserved, always 0 |
4 |
|
|
offset to bitmap data |
4 |
|
|
remaining size of header in file here onwards |
4 |
|
|
width of image |
4 |
|
|
height of image |
4 |
|
|
number of color planes, always 1 |
2 |
|
|
Bits per pixel |
2 |
|
|
compression flag |
4 |
|
|
compressed image? |
4 |
|
|
Horzontal resolution |
4 |
|
|
vert resolution |
4 |
|
|
color table size |
4 |
|
|
important color count |
4 |
|
|
|
|
|
Figure 1
Color Table
The color table is used to store the color components of red, green and blue and contains as many elements as there are colors in the bitmap. The color table is not present for bitmaps with 24 color bits because each pixel is represented by 24-bit red-green-blue (RGB) values in the actual bitmap data area. The colors in the table should appear in order of importance. This helps a display driver render a bitmap on a device that cannot display as many colors as there are in the bitmap.
Bitmap Bits
Immediately following the color table there is an array of byte values representing consecutive rows or scan lines of the bitmap. Each scan line consists of consecutive bytes representing the pixels in the scan line in left-to-right order. The number of bytes representing a scan line depends on the color format and the width in pixels of the bitmap. If necessary, a scan line must be zero-padded to end on a 32-bit boundary. However, segment boundaries can appear anywhere in the bitmap. The scan lines are stored from bottom up. This means that the first byte in the array represents the pixels in the lower-left corner of the bitmap and the last byte represents the pixels in the upper right corner.