BMP file
BMP (Bitmap's abbreviation) file format is a bitmap file format of Windows itself, so-called it refers to this format in the Windows internal storage bitmap. One. BMP format file usually has .bmp extension, but some is to extension, RLLE means running length coding. Such a file means that the data compression method used is one of the two RLE methods supported by. BMP format file.
The BMP file can be encoded with color information per pixels 1, 4, 8, 16 or 24, 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 (bit per pixel, BitPerpixel) can only have two colors. And a 24-BPP image can have more than 16 megabytes of different colors.
The next page illustrates the structure of a typical .BMP file. It is 8-BPP with 256 colors, and the file is divided into four main parts: a bitmap file header, a bitmap information head, a color table and bitmap data itself. The bitmap file header contains information about this file. If you start from where the bitmap data is positioned, the bitmap information head contains information about this image, such as the width and height of pixels. There is an image color RGB value in the color table. For display cards, if it does not display more than 256 colors, read, and display. BMP files can convert these RGB values to the palette of the display card to generate accurate colors.
The bitmap data format of the BMP file depends on the number of bits used to encode each pixel color. For a 256-colored image, each pixel occupies a byte of the middle map data section. The value of the pixel is not RGB color value, but an index of the file Chinese color table. So in the color table if the first R / g / b value is 255/0/0, the pixel value is 0 indicates that it is bright red, and the pixel value is stored in the order from left to right, usually from the last line. Start. So in a 256-colored file, the first byte in bitmap data is the color index of the pixel in the lower left corner of the image, the second is the color index of the pixel on the right side. If the number of bytes per line in the bitmap data is an odd number, it is necessary to add an additional byte in each row to adjust the integer multiple of the bitmap data boundary to 16 bits.
Not all BMP file structures are like the tables listed in the table, such as 16 and 24-bpp, files without color tables, pixel values directly represent RGB values, and the internal storage format of private parts can also be variable. For example, at 16 and 256 color. Bitchart data in the BMP file is compressed by the RLE algorithm. This algorithm uses the color of the color to replace the same sequence as the color, and Windows also supports OS / 2. .bmp file, although it uses a different bitmap information head and color table format.
PCX file
.pcx is the first image file format of a bitmap file storage standard on a PC. It first appeared in the Paintbrush package of Zsoft, the early 80s authorized to Bundle to Microsoft and its product, and then transformed into MicrosoftPainTbrush and became part of Windows. Although people using this format are decreasing, this file with .pcx extension is still very common today.
The PCX file is divided into three parts, in turn: PCX file header, bitmap data, and an optional color table. The file header length is 128 bytes, divided into several domains, including the size of the image and the number of encoders of each pixel color. Bitmap data is compressed with a simple RLE algorithm. The last optional color table has 256 RGB values. The PCX format is originally designed for CGA and EGA. Later, it also supports VGA and true color display card, now PCX The image can be encoded with 1, 4, 8 or 24-bpl.
TIFF file
The PCX format is the simplest in all bitmap file formats, and TiffgedImageFileFormat is the hardest. TIFF files contain. TIF extension. It starts with 8-byte long image file (IFH), the most important member in this file header is a pointer to the data structure named IFD Directory (IFD). IFD is a table for distinguishing one or more variable length data blocks named mark (TAG), with information about the image. TIFF file format defines more than 70 different types of tags, and some are used to store image widths and heights in pixels, and some are used to store color tables (if needed), of course, they must also be used to store bitmaps. The data is tagged, and a TIFF format file is determined for its markup, and this file structure is extremely easy to expand because you have to add some additional tags.
What is the TIFF file so complicated? On the one hand, it is very difficult to write a software that can identify different markers used. Most TIFF readers can only identify part of the tag, so this will happen: sometimes an application created Tiff file, another application cannot be used. Creating a TIFF file may also add some markings you know, although Tiff's readers can skip those non-recognized tags, but doing so always affect the quality of the image.
On the other hand, a TIFF file can contain multiple images, each with your own IFD and a series of tags. Bitmap data in the TIFF file can be compressed in several ways, so a complete TIFF reader should have RLE decompression programs, LZW decompression programs, and other algorithms decompressed programs. However, something worse is to use the decoding of LZW, you must get the consent of Unisys, and usually need to pay. So even if some of the preferred TIFF readers are also powerful when they are compressed by the LZW algorithm.
Although TIFF is so complicated, it is still a best cross-platform format. Because it is very flexible, no matter whether it is visually or other aspects, any image can be encoded into binary form without losing any properties.
GIF file
When many images of authority think of LZW, they will also think of GIF (GraphicsInterchangeformat, reading JIFF) This is a common cross-platform bitmap file format, which was originally created by CompuServe. GIF files usually have .GIF extension and a large amount on Compuseve.
The structure of the GIF file depends on which version it belongs to. The current two versions are GIF87A and GIF89A, respectively, and the former is simpler. No matter which version, it starts with a 13-byte file header, and the file header contains this file is a gif file tag, version number, and some other information. If this file has only one image, the file is immediately following a global color table to define the color in the image. If the GIF and TIFF formats are included, allowing multiple images in a file), then the global color table is replaced by a partial color table that comes with each image.
In the GIF87A file, the file header and the global color table are the image, which may be the first one in the head-tail phase, each image consisting of three parts, a 10-byte length Image description, an optional topical color table and bitmap data. To effectively utilize space, bitmap data is compressed with the LZW algorithm.
The GIF89A structure is similar to this, but it also includes an optional extension block to store additional information for each image. GIF89A details four expansion blocks: The image controls the expansion block, which is used to describe how the image is displayed (for example, it should be like a transparent to overwrite an image, or simply replace it); simple text Expansion block, it contains text displayed in the image; comment expansion block, which stores comments in ASCII text; Apply Extension block, which stores private data generated by the application. These expansion blocks can appear anywhere in the full color table in the file. GIF most significant advantages is that it is widely used and its tightness. But it has two weaknesses, one is available in GIF formats to only contain 256 colors. Another possibility is more important, that is those software developers who use GIF formats must have a consent of CompuServe, and they have to pay for each of the COMPUSERVE. This policy is made by CompuServe, which inhibits those programmers to support GIF files in his image application.
PNG file
PNG (PortableNetworkGraphic, pronunciation PING) File format is developed as a replacement of GIF, which avoids common issues encountered by the GIF file. It inherits many features from GIF, and supports true color image. More importantly, in compressing bitmap data, it uses a variant of the Popular LZ77 algorithm, and LZ77 is the predecessor of LZW, and can be used free of charge. Due to the limit, it will not take time here to specifically discuss the PNG format.
JPEG file
JPEG (JointPhotographicExpertsGroup, pronounced JAY-PEG) file format is initially introduced by C-Cubemicrosystems, to provide an effective way to store depth bit pixels, such as a photo scan, a lot of colors and subtle (sometimes not fine). The maximum difference between JPEG and other formats discussed here is that JPEG uses a lossless compression algorithm that the lossless compression algorithm can accurately reproduce the image before decompression, and loss of compression sacrifices part of the image data to achieve more High compression ratio. But this loss is very small to be aware of people.
JPEG image compression is a complex process that often requires special hardware to help. First, the image is divided into pieces of 8 * 8 in pixels. Then, each block is divided into three steps being compressed. The first step using DCT (DiscretecosineTransform) discreating cosine transform to turn 8 * 8 of the pixel matrix of 8 * 8 (also the speed of color change) matrix. The second step is quantified to the value of the frequency matrix to quantify the quantization matrix, filtering out the portion that is not important to the image. In the third step, it is the final step, and the quantified frequency matrix uses lossless compression.
Because the quantified frequency matrix is missing a lot of high-frequency information, it is usually compressed to half or even less. Lossless compression generally does not compress the true photo image, so 50% compression is quite good, but on the other hand, lossless compression can reduce some image file size 90%, such image files are not suitable Compressed with JPEG.
The damaged portion of the JPEG produces the second step, the higher the value of the quantization matrix, the more information lost from the image, the higher the compression ratio, but the quality of the image is worse. When the JPEG is compressed, a quantization factor can be selected, and the value of this factor determines the value in the quantization matrix. The ideal quantization factor is equilibrated between compression ratios and image quality, so you can choose different quantization factors for different images, usually depends on several attempts.