Image File Structure - Online Article


Firstly an idea comes into mind and then it is necessary to decide its structure according to the utility of an idea. After seeing anything, our eyes also form a structure and then we come to know what is this. If you want to change or modify the previous one, you have to change or make an amendment in the �STRUCTURE� of the existing one.

Similarly in Computer every IMAGE FILE has its own basic structure and it is defined according to the utility of the file used. Staring at the options, you may have wondered if it really makes a difference whether the file is saved as a JPEG, a TIFF, an EPS, or other format, as long as it looks good on screen. In short, yes. For although it might seem like an inconsequential detail, different file types are best suited to different uses. While some formats are optimal for saving Web-navigation icons, for instance, they may not be the best choice for high-resolution photographs. And just because a certain format works well for online graphics doesn't always mean it is ideal for print jobs.

Common Graphics File Formats

  • Vector- EPS, WMF


Bitmap, or raster, graphics basically consist of dots of color. Some of the formats available are:-

  • TIFF: The Tagged Image File Format was designed for portability but unfortunately many variations exist - you should always make an initial test to ensure that the TIFF format produced by your graphics program is the TIFF format that can be read by any other software you wish to use the image with. The most common TIFF variations are uncompressed and LZW compressed; both support up to 24-bit color. The compression used is lossless - this means that no information is lost from the picture during the compression process. TIFF can be used on Windows, Mac and UNIX but not on the Web.
  • JPEG: This format is most commonly used for photographs or other complex images because it supports millions of colors in a small file size. JPEG is a universal format which is used on Windows, Mac and Unix. The small file size is achieved by discarding information from the image during compression (lossy compression) - the greater the compression, the more the image is degraded, although to the naked eye, compression has to be very great before degradation is noticeable. It is worth experimenting with a particular image to find the optimum compression/quality. Archivists never use JPEG to save the master copy of an image, but most other users need not have the concerns of archivists.
  • GIF: The Graphics Interchange Format is used primarily for simple images and is restricted in that it only supports 256 colors, although they can be any 256 colors of the millions available. GIF uses lossless compression to achieve small file sizes and comes in two flavors, 87a and 89a, the latter supporting animation and interlacing on the Web. GIF can be used on Windows, Mac and UNIX.
  • PNG: As its name suggests, the relatively new Portable Network Graphics format is one designed with the Web in mind, although only newer browsers recognize it. It supports 24-bit color and provides the best lossless compression available. PNG is a cross-platform format but because it is new you should check whether all the applications that you want to use will support it.
  • BMP & PCX (Windows), PICT (Macintosh): These formats are platform-specific bitmap formats -- that is, every individual pixel in the image is recorded; this makes for very large files. These formats are virtually obsolete, and there is rarely a case for using them now. They cannot be used on the Web. All use lossless compression. BMP comes in two flavours: RGB, which supports up to 24-bit colors but is not compressed, and RLE, which supports 4- or 8-bit colors and is compressed. PCX version 5, which is supported by most software, supports up to 24-bit color; PICT supports up to 32-bit color.


Simply, vector graphics consist of lines rather than dots, and have the advantage that they are resolution-independent and infinitely scaleable. There is little difference in quality between different vector formats.

  • EPS: Encapsulated PostScript is a cross-platform format but requires a PostScript interpreter for the screen preview of images. Because this is often not available, it is common for a bitmap screen preview to be included in the EPS file and this preview may not be platform-independent. If a preview is not included, the image will display on the screen as a grey box but will still print correctly. Use of EPS should be considered if you are using a PostScript printer such as those provided by ISS. EPS cannot be used on the Web, although it is possible to use a graphics program such as PhotoShop to rasterize an EPS image and save it as another format; beware that some 'conversion' programs merely extract the preview from the file.
  • WMF: Windows Metafile is a vector format that can only be used on Windows platforms.

Why only BMP files ?

First off all we have to know what is this BMP stands for:- BMP stands for Bitmap.

Bitmaps are images where each pixel is mapped with a bit value. Bitmaps are able to support an infinite number of color per pixel, and are not palette based. Bitmaps are unable to store transparencies or alpha channels, and the only form of compression they are able to use is run length encoding.

Run Length Encoding: RLE compresses in a lossless nature by replacing consecutive values with a single codeword. For example, if a sequence of values existed like 34 34 34 34 34 34, it could be RLE encoded as 6 34, because there are 6 "34"s. This is good for images that are low color depth and have a lot of similar blocks. This works at a low level and is lossless, so it can be used with almost any form of data.

Bitmap (BMP) files are the default image format used by Microsoft operating systems and by Windows' built-in Paint accessory. BMPs are raster-based, meaning that they use thousands or millions of pixels to compose an image. Typically, BMPs do not use compression � resulting in very large file sizes� and range in resolution from one bit (black and white) to 24 bits (16.7 million color).

Bitmap file format

Internal Structure of a 24- bit Uncompressed Bitmap file:

Bitmap pixel properties

Windows BMP Bitmap file are characterized by the number of pixels and the color depth per pixel. The color depth of each pixel is always the same in a file. Figure 1 demonstrates the properties of a bitmap pixel, which consists of 24 bits in 3 contiguous bytes: 1 byte (8 bits) for Red, 1 byte for Green `and 1 byte for Blue. When reading bitmap data pixel information, designer has to first read the File Header, the Image Header Information, and then the Bitmap Pixel Data.

Bitmap file format

Header File: A Windows Bitmap Header File consists of 14 bytes of information:

  • bfType: This field occupies 2 bytes which are allocated for the ASCII �characters �BM�.����
  • bfSize: This field occupies 4 bytes which indicate the size of the Bitmap file.
  • bfReserved: This field occupies 4 bytes which are reserved for future use and should be 0.
  • bfOffBits: This field occupies 4 bytes which specify the number of bytes from the beginning of the file to the starting Pixel Data byte.

Header Information: The Header Information of a Windows BMP format occupies at least 40 bytes:

  • biSize: 4 Bytes � This field indicates the size of the Header Information structure given in bytes.
  • biWidth: 4 Bytes � indicates the width of the bitmap in pixels.
  • biHeight: 4 Bytes � indicates the height of the bitmap in pixels
  • biPlanes: 2 Bytes � indicates the number of planes contained in the bitmap and must be set to 1.
  • biBitCount: 2 Bytes � indicates the bit-depth of the bitmap pixel or bits per pixel.
  • biCompression: 4 Bytes � indicates whether the bitmap data is Run Length. Encoding or not. It should be 0 for uncompressed images
  • biSizeImage: 4 Bytes � contains the length of the bitmap image data in bytes. This value is not necessary equal to the width multiplied by the height.
  • biXPelsPerMeter: 4 Bytes � describes the resolution of the bitmap in pixels per meter.
  • biYPelsPerMeter: 4 Bytes � describes the resolution of the bitmap in pixels per meter.
  • biClrUsed: 4 Bytes � indicates the number of colors that is used in the bitmap.
  • biClrImportant: 4 Bytes � signifies the number of significant colors.

Pixel Data: Bitmap pixel data is stored upside down from its actual image as demonstrated in Figure 3 below.

Image orientation

Therefore, when reading or writing an image to a file, data starts at the bottom left corner and goes from left to right, bottom to top in pixel unit. Since the image is stored in inverted order, each RGB values are written in backward starting with blue, green and then red. One important issue that we have to pay careful attention to when manipulating bitmap image file is how to manage junk bytes. The red square below is used as an example to demonstrate the junk byte concept.


When saving this red square as a bitmap image file to any local directory in the computer, the file is 15 by 15 pixels, 24-bit uncompressed bitmap with its total size on disk of 774 bytes. As mentioned earlier, each 24-bit pixel consists of 3 bytes: 1 byte for red, one byte green, and 1 byte for blue plus 14 bytes for Header file and 40 bytes for Header information, the total of (15x15x3) + 14 + 40 = 729 bytes.

Compared to its actual size on disk, there are 45 bytes extra. The reason for junk bytes is that the number of bytes per row of a bitmap file is grouped into 4-byte block. Therefore, it has to be divisible by 4. When the amount of bytes per row in not divisible by 4, then the junk bytes are needed to add in at the end of the array of bytes to make it divisible by four. Therefore, there could be no junk byte, one �00�, two �00 00�, or three �00 00 00� junk bytes per row. Refer to the red square above again; there are 15 pixels per row. Therefore, each row has 3 junk bytes because 15%4 = 3. There are 15 rows. That is why there are 45 bytes extra on disk comparing to its actual size (15 * 3 = 45). Note that % is the modulo operator. It equals to the remainder of the division. For example, 7 / 3 = 2 with 1 remainder. In other words, 7 % 3 = 1.

Let�s use another example to illustrate the concept: we have a bitmap file of 5 columns and 4 rows. There are 3 bytes of RGB values for each pixel which are arbitrarily chosen below.


Pixel per column * 3 bytes = Total number of bytes per column

5 columns * 3 = 15 bytes

If we arrange these 15 bytes into 4-byte block, we have: FF00FFFF 00FF00FF FF00FF00 FFFF00

Notice that the last group has only 3 bytes and is not evenly divisible by 4. Therefore, one junk byte is needed to pad in to make it divisible by 4.


The following formula can be used to calculate junk bytes:

4 � ((pixel per column * 3) % 4) = junk bytes

4 � ((5 * 3)% 4) =4 � (15 % 4) = 4 � 3 = 1

junk byte.

BMP, Bitmap


Name: Microsoft Windows Bitmap
Extension: BMP
Type: Raster format
Colors: 1 to 32-bit
Versions: 1, 2, 3 and 4 (Windows 95)
Compressions: RLE or uncompressed
Standard: Microsoft
Platforms: DOS and Windows

Purpose: The format is used for store and display color and grayscale images. The format supports 24 bit color, which makes it suitable for photos. 

Advantages: Most Windows software can easily import and export BMP-files. The file format is very well defined in the standard.

Disadvantages: The file size usually gets large because the 24-bit images are often saved uncompressed.

About the Author:

No further information.


No comment yet. Be the first to post a comment.