A probe into the interior of the bit graphic parts

Source: Internet
Author: User

The most commonly used image file formats how to store images since I bought my first PC 14 years ago, I have been interested in storing the complex information in the data streams composed of 1 and 0 of computers. What started my attention was the very popular list of basic programs printed in magazines, with lots of data segments that you can type and run to create other programs. From here I understand that any program, however complex it may be, is simply a series of instructions for a computer microprocessor. Then I got interested in the ASCII code, then the word processing file format, and later, you see the image.

The one technology that still fascinates me today is bitmap file storage. A bitmap stores the information that is required on a computer to reproduce an image. We often see images on a monitor, such as a beautiful sunset, but in the eyes of the computer it's just a bunch of 0 and 1 combinations. In the final analysis, these bits and bytes in the bitmap file tell the computer what color each pixel in the image is, and then the computer converts the color in the bitmap into a format compatible with its display card, and finally outputs it to the monitor.

What is interesting about this process is how the computer interprets the data in the bitmap, the bitmap file has many formats, each format has its own method object element data encoding and gives some other information required by the format. Windows95 can read a. bmp file and cannot read a. gif file because his designer enables the paint program to decode image data stored in. bmp format instead of. gif.

Come here. You must be wondering what is in a bitmap file, and what is the difference between one format and another? So let's simply look at the six kinds of bitmap file formats that are commonly used on PCs. Of course, there are other file formats, for example, for vector graphics, which is to store some of the instructions to reproduce the image rather than the color data for each pixel, but the six kinds of bitmap file formats discussed here are the most likely to be used in your work.

BMP file

The BMP (bitmap) file format is the bitmap file format of Windows itself, which is the format used to refer to Windows internal storage bitmaps. A. bmp-formatted file usually has a. bmp extension, but some of the. RLE is extended, and rle means the stroke length encoding (runlengthencoding). Such a file means that the data compression method used is one of two RLE methods supported by the. bmp format file.

BMP files can encode color information in 1, 4, 8, 16, or 24 bits per pixel, which is called the color depth of the image, which determines the maximum number of colors contained in the image. An image of a 1-bpp (bits per pixel, bitperpixel) can only have two colors. And a 24-BPP image can have more than 16 trillion different colors.

The diagram on the next page illustrates the structure of a typical. bmp file. It is an example of a 256-color 8-BPP, the file is divided into four main parts: a bitmap file header, a bitmap information header, a color table and bitmap data itself. The bitmap file header contains information about the file. such as where to start is the location of bitmap data information, bitmap information header contains information about the image, such as pixel in pixels of width and height. The RGB value of the image color in the color table. For a display card, if it cannot display more than 256 colors at a time, the program that reads and displays the. bmp file can convert these RGB values to the palette of the display card to produce an accurate color.

The bitmap data format of a BMP file depends on the number of digits that are used to encode each pixel color. For a 256-color image, each pixel occupies one byte of the bitmap data portion of the file. The pixel value is not an RGB color value, but an index of the color table in the file. So in the color table if the first r/g/b value is 255/0/0, then the pixel value of 0 indicates that it is red and the pixel values are stored in left-to-right order, usually starting at the last line. So in a 256-color file, the first byte in the bitmap data is the color index of the pixel in the lower-left corner of the image, and the second is the color index of the pixel on the right. If the number of bytes per row in the bitmap data is odd, add an additional byte to each row to resize the bitmap data boundary to 16-bit integer multiples.

Not all BMP file structure as listed in the table, such as 16 and 24-BPP, the file does not have a color table, pixel values directly represent the RGB value, the other file private part of the internal storage format can also be changed. For example, in 16 and 256 colors. bmp file Bitmap data using RLE algorithm to compress, this algorithm uses color plus pixel number to replace a string of the same color sequence, and, Windows also supports the OS/2 under the. bmp file, although it uses a different bitmap information header and color table format.

PCX file

. PCX is the first image file format to be the standard for bitmap file storage on PCs. It first appeared in the ZSoft company's paintbrush package, authorizing Microsoft to bundle offerings with its products in the early 80, and then into Microsoftpaintbrush, which became part of Windows. Although there are fewer people using this format, the file with the. pcx extension is still very common today.

The PCX file is divided into three parts, followed by: PCX file header, bitmap data, and an optional color table. The file header is 128 bytes long and is divided into several fields, including the size of the image and the number of digits of each pixel color. Bitmap data is compressed using a simple RLE algorithm, the final optional color table has 256 RGB values, the PCX format was originally designed for CGA and EGA, and later modified to support VGA and true color display cards, now PCX image can be used 1, 4, 8 or 24-BPP to encode color data.

TIFF file

The PCX format is the simplest of all bitmap file formats, and TIFF (Taggedimagefileformat) is the hardest.

The TIFF file contains a. tif extension. It starts with a 8-byte long image file Header (IFH), and the most important member of this file header is a pointer to a data structure named image file directory (IFD). An IFD is a table called tag (tag) that distinguishes one or more variable-length blocks of data, and the tag contains information about the image. The TIFF file format defines more than 70 different types of tags, some are used to store pixels in pixel width and height, and some for the color table (if necessary), of course, there must be a bitmap data to hold the tag, a TIFF format file is entirely determined by its tag, And this kind of file structure is very easy to expand, because you have to attach some features only need to add some additional tags.

What exactly makes a TIFF file so complex? On the one hand, it is difficult to write a software that recognizes the different tags used. Most TIFF readers only recognize part of the tag, so this can happen when one application creates a TIFF file and another application is not available. The program that creates the TIFF file may also add some tags that are only recognizable to the file, although the TIFF reader can skip tags that they do not recognize, but this can always affect the quality of the image.

On the other hand, a TIFF file can contain multiple images, each with its own IFD and a series of tags. The bitmap data in the TIFF file may be compressed in several ways, so a complete TIFF reader should have a RLE decompression program, LZW decompression program and some other algorithms of the decompression program. What is worse, however, is that the use of LZW decoding must be approved by the Unisys company and is usually paid royalties. So even some pretty good tiff readers are powerless when they encounter an image that LZW algorithm compresses.

Although TIFF is so complex, it is still one of the best cross-platform formats. Because it is very flexible, it is possible to encode any image into binary form without losing any attributes, visually or otherwise.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.