Bitmap Tutorial What is the Bitmap image A
Bitmap Tutorial
What is the Bitmap image? • A type of graphics format that specifies a number of pixels and then specifies what color those pixels are. GIF, JPG, and BMP etc are bitmap images. • why BMP file -- • • • Simplicity Highly standardized Extremely widespread • BMP file created by Microsoft and IBM 1986 (Windows BMP and Device Independent Bitmap) • Different BMP format because of different bits stored per pixel. Such as 4 bits(16 color bitmap), 8 bits(256 color), 16 bits(high color bitmap), 24 bits(true color), 32 bits etc. 2
Bitmap Structure The structure of a 24 bit bmp file: • The file header: holds information about type, size and layout of the file. • The info header: holds information about dimension and color format of the image • The image data. holds pixel data and color table information 3
Bitmap File Header BMP File Header Contents (14 bytes) Field Name Size in Bytes Description bf. Type 2 The characters "BM" bf. Size 4 The size of the file in bytes bf. Reserved 1 2 Unused - must be zero bf. Reserved 2 2 Unused - must be zero bf. Off. Bits 4 Offset to start of Pixel Data 4
Bitmap File Header BMP File Header Contents (14 bytes) typedef struct { unsigned short int type; // Magic identifier unsigned int // File size in bytes size; unsigned short int reserved 1; unsigned short int reserved 2; unsigned int offset; // Offset to image data, bytes } BITMAPFILEHEADER ; 5
Bitmap Info Header Field Name Size in Bytes Description bi. Size 4 Header Size - Must be at least 40 bi. Width 4 Image width in pixels bi. Height 4 Image height in pixels bi. Planes 2 Must be 1 bi. Bit. Count 2 Bits per pixel - 1, 2, 4, 8, 16, 24, or 32 bi. Compression 4 Compression type (0 = uncompressed) bi. Size. Image 4 Image Size - may be zero for uncompressed images bi. XPels. Per. Meter 4 Preferred resolution in pixels per meter (set to 0) bi. YPels. Per. Meter 4 Preferred resolution in pixels per meter (set to 0) bi. Clr. Used 4 Number Color Map entries that are actually used bi. Clr. Important 4 Number of significant colors 6
Bitmap Info Header typedef struct { unsigned int size; // Header size in bytes int width, height; // width and height of image unsigned short int planes; // Number of colour planes unsigned short int bits; // Bits per pixel unsigned int compression; // compression type unsigned int imagesize; // image size in bytes int xresolution; // pixels per meter X int yresolution; // pixels per meter Y unsigned int ncolours; // number of colours unsigned int importantcolours; // important colours } BITMAPINFOHEADER; 7
Image Data typedef struct { BYTE red; green; blue; } RGBTriplet; RGBTriplet Bitmap_texture[image_Width][image_height] OR, GLubyte Bitmap_texture[image_Width][image_height][image_channels] Do texture mapping …. 8
Google “Bitmap tutorial, BMP format, code” http: //astronomy. swin. edu. au/~pbourke/dataformats/bmp/ 9
Thanks 10
- Slides: 10