Display of GIF pictures in GDI +

Source: Internet
Author: User
Tags header

A netizen has asked me GDI + in GIF image display problem, has no time to write to you, in this apology. I gave this article to him.

First, GIF format introduction

1. Overview

GIF (Graphics Interchange Format, Graphics Interchange formats) file is a graphic file format developed by the CompuServe Company, All rights reserved, the use of any commercial purposes shall be CompuServe authorized by the company.

A GIF image is based on a color list (the stored data is the index value of the point that corresponds to the color list) and supports up to 8 bits (256 colors). GIF files are divided into a number of storage blocks, used to store multiple images or to determine the behavior of the image of the control block for animation and interactive applications. GIF files also compress image data by compressing the LZW algorithm to reduce the image size.

2.GIF file storage structure

GIF files are divided into chunks, including control blocks and data blocks (sub-blocks). The control block is the control data block behavior, according to the different control block contains some different control parameters; The data block contains only some 8-bit character streams, which are determined by the control blocks in front of it, each block size from 0 to 255 bytes, and the first byte of the block indicates the block size (in bytes). This byte is not included when calculating the size of a block of data, so an empty block of data has a byte, which is the size of the block of data 0x00. The following table is the structure of a block of data:

BYTE 7 6 5 4 3 2 1 0 BIT
0

Block size

Block size-blocks, excluding this byte (not counting the block size itself)
1 Data Values-Blocks, 8-bit strings
2
...
254
255

The structure of a GIF file can be divided into three parts of the file header, the GIF stream (GIF data stream), and the file Terminator (Trailer). The file header contains the GIF file signature (Signature) and version number (edition); The GIF data stream consists of a control identifier, an image block, and some other extension blocks; The file Terminator has only one character ('; ') with a value of 0x3b. ) indicates the end of the file. The following table shows the constituent structure of a GIF file:

GIF signature File header
Version number
Logical screen Identifier GIF Data flow
Global Color List
...
Image identifiers Image block                      
Image local Color list diagram
                    Image data based on color list
...
GIF end End of File

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.