⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gif87.htm

📁 各种文件格式说明及程序描述
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<html>

<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>gif graphics interchange format</title>
<meta name="generator" content="microsoft frontpage 3.0">
</head>

<body background="../jpg/di1.JPG">

<p align="center"><font size="6" color="#0000ff">gif graphics interchange format</font></p>
<div align="center"><center>

<table border="0" width="88%">
  <tr>
    <td width="100%"><br>
    a standard defining a mechanism<br>
    for the storage and transmission<br>
    of raster-based graphics information<br>
    june 15, 1987<br>
    (c) compuserve incorporated, 1987<br>
    all rights reserved<br>
    while this document is copyrighted, the information<br>
    contained within is made available for use in computer<br>
    software without royalties, or licensing restrictions.<br>
    gif and 'graphics interchange format' are trademarks of<br>
    compuserve, incorporated.<br>
    an h&amp;r block company<br>
    5000 arlington centre blvd.<br>
    columbus, ohio 43220<br>
    (614) 457-8600<br>
    page 2<br>
    graphics interchange format (gif) specification<br>
    table of contents<br>
    introduction . . . . . . . . . . . . . . . . . page 3<br>
    general file format . . . . . . . . . . . . . page 3<br>
    gif signature . . . . . . . . . . . . . . . . page 4<br>
    screen descriptor . . . . . . . . . . . . . . page 4<br>
    global color map . . . . . . . . . . . . . . . page 5<br>
    image descriptor . . . . . . . . . . . . . . . page 6<br>
    local color map . . . . . . . . . . . . . . . page 7<br>
    raster data . . . . . . . . . . . . . . . . . page 7<br>
    gif terminator . . . . . . . . . . . . . . . . page 8<br>
    gif extension blocks . . . . . . . . . . . . . page 8<br>
    appendix a - glossary . . . . . . . . . . . . page 9<br>
    appendix b - interactive sequences . . . . . . page 10<br>
    appendix c - image packaging &amp; compression . . page 12<br>
    appendix d - multiple image processing . . . . page 15<br>
    graphics interchange format (gif) page 3<br>
    specification<br>
    introduction<br>
    'gif' (tm) is compuserve's standard for defining generalized color<br>
    raster images. this 'graphics interchange format' (tm) allows<br>
    high-quality, high-resolution graphics to be displayed on a variety of<br>
    graphics hardware and is intended as an exchange and display mechanism<br>
    for graphics images. the image format described in this document is<br>
    designed to support current and future image technology and will in<br>
    addition serve as a basis for future compuserve graphics products.<br>
    the main focus of this document is to provide the technical<br>
    information necessary for a programmer to implement gif encoders and<br>
    decoders. as such, some assumptions are made as to terminology relavent<br>
    to graphics and programming in general.<br>
    the first section of this document describes the gif data format<br>
    and its components and applies to all gif decoders, either as standalone<br>
    programs or as part of a communications package. appendix b is a<br>
    section relavent to decoders that are part of a communications software<br>
    package and describes the protocol requirements for entering and exiting<br>
    gif mode, and responding to host interrogations. a glossary in appendix<br>
    a defines some of the terminology used in this document. appendix c<br>
    gives a detailed explanation of how the graphics image itself is<br>
    packaged as a series of data bytes.<br>
    graphics interchange format data definition<br>
    general file format<br>
    +-----------------------+<br>
    | +-------------------+ |<br>
    | | gif signature | |<br>
    | +-------------------+ |<br>
    | +-------------------+ |<br>
    | | screen descriptor | |<br>
    | +-------------------+ |<br>
    | +-------------------+ |<br>
    | | global color map | |<br>
    | +-------------------+ |<br>
    . . . . . .<br>
    | +-------------------+ | ---+ <br>
    | | image descriptor | | | <br>
    | +-------------------+ | | <br>
    | +-------------------+ | | <br>
    | | local color map | | |- repeated 1 to n times<br>
    | +-------------------+ | | <br>
    | +-------------------+ | | <br>
    | | raster data | | | <br>
    | +-------------------+ | ---+ <br>
    . . . . . . <br>
    |- gif terminator -| <br>
    +-----------------------+<br>
    graphics interchange format (gif) page 4<br>
    specification<br>
    gif signature<br>
    the following gif signature identifies the data following as a<br>
    valid gif image stream. it consists of the following six characters:<br>
    g i f 8 7 a<br>
    the last three characters '87a' may be viewed as a version number<br>
    for this particular gif definition and will be used in general as a<br>
    reference in documents regarding gif that address any version<br>
    dependencies.<br>
    screen descriptor<br>
    the screen descriptor describes the overall parameters for all gif<br>
    images following. it defines the overall dimensions of the image space<br>
    or logical screen required, the existance of color mapping information,<br>
    background../jpg/di1.JPGn color, and color depth information. this information<br>
    is stored in a series of 8-bit bytes as described below.<br>
    bits<br>
    7 6 5 4 3 2 1 0 byte #<br>
    +---------------+<br>
    | | 1<br>
    +-screen width -+ raster width in pixels (lsb first)<br>
    | | 2<br>
    +---------------+<br>
    | | 3<br>
    +-screen height-+ raster height in pixels (lsb first)<br>
    | | 4<br>
    +-+-----+-+-----+ m = 1, global color map follows descriptor<br>
    |m| cr |0|pixel| 5 cr+1 = # bits of color resolution<br>
    +-+-----+-+-----+ pixel+1 = # bits/pixel in image<br>
    | background | 6 background=../jpg/di1.JPG index of screen background<br>
    +---------------+ (color is defined from the global color<br>
    |0 0 0 0 0 0 0 0| 7 map or default map if none specified)<br>
    +---------------+<br>
    the logical screen width and height can both be larger than the<br>
    physical display. how images larger than the physical display are<br>
    handled is implementation dependent and can take advantage of hardware<br>
    characteristics (e.g. macintosh scrolling windows). otherwise images<br>
    can be clipped to the edges of the display.<br>
    the value of 'pixel' also defines the maximum number of colors<br>
    within an image. the range of values for 'pixel' is 0 to 7 which<br>
    represents 1 to 8 bits. this translates to a range of 2 (b &amp; w) to 256<br>
    colors. bit 3 of word 5 is reserved for future definition and must be<br>
    zero.<br>
    graphics interchange format (gif) page 5<br>
    specification<br>
    global color map<br>
    the global color map is optional but recommended for images where<br>
    accurate color rendition is desired. the existence of this color map is<br>
    indicated in the 'm' field of byte 5 of the screen descriptor. a color<br>
    map can also be associated with each image in a gif file as described<br>
    later. however this global map will normally be used because of<br>
    hardware restrictions in equipment available today. in the individual<br>
    image descriptors the 'm' flag will normally be zero. if the global<br>
    color map is present, it's definition immediately follows the screen<br>
    descriptor. the number of color map entries following a screen<br>
    descriptor is equal to 2**(# bits per pixel), where each entry consists<br>
    of three byte values representing the relative intensities of red, green<br>
    and blue respectively. the structure of the color map block is:<br>
    bits<br>
    7 6 5 4 3 2 1 0 byte #<br>
    +---------------+<br>
    | red intensity | 1 red value for color index 0<br>
    +---------------+<br>
    |green intensity| 2 green value for color index 0<br>
    +---------------+<br>
    | blue intensity| 3 blue value for color index 0<br>
    +---------------+<br>
    | red intensity | 4 red value for color index 1<br>
    +---------------+<br>
    |green intensity| 5 green value for color index 1<br>
    +---------------+<br>
    | blue intensity| 6 blue value for color index 1<br>
    +---------------+<br>
    : : (continues for remaining colors)<br>
    each image pixel value received will be displayed according to its<br>
    closest match with an available color of the display based on this color<br>
    map. the color components represent a fractional intensity value from<br>
    none (0) to full (255). white would be represented as (255,255,255),<br>
    black as (0,0,0) and medium yellow as (180,180,0). for display, if the<br>
    device supports fewer than 8 bits per color component, the higher order<br>
    bits of each component are used. in the creation of a gif color map<br>
    entry with hardware supporting fewer than 8 bits per component, the<br>
    component values for the hardware should be converted to the 8-bit<br>
    format with the following calculation:<br>
    &lt;map_value&gt; = &lt;component_value&gt;*255/(2**&lt;nbits&gt; -1)<br>
    this assures accurate translation of colors for all displays. in<br>
    the cases of creating gif images from hardware without color palette<br>
    capability, a fixed palette should be created based on the available<br>
    display colors for that hardware. if no global color map is indicated,<br>
    a default color map is generated internally which maps each possible<br>
    incoming color index to the same hardware color index modulo &lt;n&gt; where<br>
    &lt;n&gt; is the number of available hardware colors.<br>
    graphics interchange format (gif) page 6<br>
    specification<br>
    image descriptor<br>
    the image descriptor defines the actual placement and extents of<br>
    the following image within the space defined in the screen descriptor.<br>
    also defined are flags to indicate the presence of a local color lookup<br>
    map, and to define the pixel display sequence. each image descriptor is<br>
    introduced by an image separator character. the role of the image<br>
    separator is simply to provide a synchronization character to introduce<br>
    an image descriptor. this is desirable if a gif file happens to contain<br>
    more than one image. this character is defined as 0x2c hex or ','<br>
    (comma). when this character is encountered between images, the image<br>
    descriptor will follow immediately.<br>
    any characters encountered between the end of a previous image and<br>
    the image separator character are to be ignored. this allows future gif<br>
    enhancements to be present in newer image formats and yet ignored safely<br>
    by older software decoders.<br>
    bits<br>
    7 6 5 4 3 2 1 0 byte #<br>
    +---------------+<br>
    |0 0 1 0 1 1 0 0| 1 ',' - image separator character<br>
    +---------------+<br>
    | | 2 start of image in pixels from the<br>
    +- image left -+ left side of the screen (lsb first)<br>
    | | 3<br>
    +---------------+<br>
    | | 4<br>
    +- image top -+ start of image in pixels from the<br>
    | | 5 top of the screen (lsb first)<br>
    +---------------+<br>
    | | 6<br>
    +- image width -+ width of the image in pixels (lsb first)<br>
    | | 7<br>
    +---------------+<br>
    | | 8<br>
    +- image height-+ height of the image in pixels (lsb first)<br>
    | | 9<br>
    +-+-+-+-+-+-----+ m=0 - use global color map, ignore 'pixel'<br>
    |m|i|0|0|0|pixel| 10 m=1 - local color map follows, use 'pixel'<br>
    +-+-+-+-+-+-----+ i=0 - image formatted in sequential order<br>
    i=1 - image formatted in interlaced order<br>
    pixel+1 - # bits per pixel for this image<br>
    the specifications for the image position and size must be confined<br>
    to the dimensions defined by the screen descriptor. on the other hand<br>
    it is not necessary that the image fill the entire screen defined.<br>
    local color map<br>
    graphics interchange format (gif) page 7<br>
    specification<br>
    a local color map is optional and defined here for future use. if<br>
    the 'm' bit of byte 10 of the image descriptor is set, then a color map<br>
    follows the image descriptor that applies only to the following image.<br>
    at the end of the image, the color map will revert to that defined after<br>
    the screen descriptor. note that the 'pixel' field of byte 10 of the<br>
    image descriptor is used only if a local color map is indicated. this<br>
    defines the parameters not only for the image pixel size, but determines<br>
    the number of color map entries that follow. the bits per pixel value<br>
    will also revert to the value specified in the screen descriptor when<br>
    processing of the image is complete.<br>
    raster data<br>
    the format of the actual image is defined as the series of pixel<br>
    color index values that make up the image. the pixels are stored left<br>
    to right sequentially for an image row. by default each image row is<br>
    written sequentially, top to bottom. in the case that the interlace or<br>
    'i' bit is set in byte 10 of the image descriptor then the row order of<br>
    the image display follows a four-pass process in which the image is<br>
    filled in by widely spaced rows. the first pass writes every 8th row,<br>
    starting with the top row of the image window. the second pass writes<br>
    every 8th row starting at the fifth row from the top. the third pass<br>
    writes every 4th row starting at the third row from the top. the fourth<br>
    pass completes the image, writing every other row, starting at the<br>
    second row from the top. a graphic description of this process follows:<br>
    image<br>
    row pass 1 pass 2 pass 3 pass 4 result<br>
    ---------------------------------------------------<br>
    0 **1a** **1a**<br>
    1 **4a** **4a**<br>
    2 **3a** **3a**<br>
    3 **4b** **4b**<br>
    4 **2a** **2a**<br>
    5 **4c** **4c**<br>
    6 **3b** **3b**<br>
    7 **4d** **4d**<br>
    8 **1b** **1b**<br>
    9 **4e** **4e**<br>
    10 **3c** **3c**<br>
    11 **4f** **4f**<br>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -