GIFSTD.TXT

(30 KB) Pobierz

                                G I F (tm)

                     Graphics Interchange Format (tm)




                      A standard defining a mechanism
                     for the storage and transmission
                   of raster-based graphics information










                               June 15, 1987












                     (c) CompuServe Incorporated, 1987
                            All rights reserved

            While this document is copyrighted, the information
          contained within is made available for use in computer
          software without royalties, or licensing restrictions.






          GIF and 'Graphics Interchange Format' are trademarks of
                         CompuServe, Incorporated.
                           an H&R Block Company

                        5000 Arlington Centre Blvd.
                           Columbus, Ohio 43220
                              (614) 457-8600




                                                                     Page 2


              Graphics Interchange Format (GIF) Specification


                             Table of Contents

        INTRODUCTION . . . . . . . . . . . . . . . . . page 3

        GENERAL FILE FORMAT  . . . . . . . . . . . . . page 3

        GIF SIGNATURE  . . . . . . . . . . . . . . . . page 4

        SCREEN DESCRIPTOR  . . . . . . . . . . . . . . page 4

        GLOBAL COLOR MAP . . . . . . . . . . . . . . . page 5

        IMAGE DESCRIPTOR . . . . . . . . . . . . . . . page 6

        LOCAL COLOR MAP  . . . . . . . . . . . . . . . page 7

        RASTER DATA  . . . . . . . . . . . . . . . . . page 7

        GIF TERMINATOR . . . . . . . . . . . . . . . . page 8

        GIF EXTENSION BLOCKS . . . . . . . . . . . . . page 8

        APPENDIX A - GLOSSARY  . . . . . . . . . . . . page 9

        APPENDIX B - INTERACTIVE SEQUENCES . . . . . . page 10

        APPENDIX C - IMAGE PACKAGING & COMPRESSION . . page 12

        APPENDIX D - MULTIPLE IMAGE PROCESSING . . . . page 15













Graphics Interchange Format (GIF)                                    Page 3
Specification


INTRODUCTION

        'GIF' (tm) is CompuServe's standard for defining generalized  color
   raster   images.    This   'Graphics  Interchange  Format'  (tm)  allows
   high-quality, high-resolution graphics to be displayed on a  variety  of
   graphics  hardware  and is intended as an exchange and display mechanism
   for graphics images.  The image format described  in  this  document  is
   designed  to  support  current  and  future image technology and will in
   addition serve as a basis for future CompuServe graphics products.

        The main focus  of  this  document  is  to  provide  the  technical
   information  necessary  for  a  programmer to implement GIF encoders and
   decoders.  As such, some assumptions are made as to terminology relavent
   to graphics and programming in general.

        The first section of this document describes the  GIF  data  format
   and its components and applies to all GIF decoders, either as standalone
   programs or as part of  a  communications  package.   Appendix  B  is  a
   section  relavent to decoders that are part of a communications software
   package and describes the protocol requirements for entering and exiting
   GIF mode, and responding to host interrogations.  A glossary in Appendix
   A defines some of the terminology used in  this  document.   Appendix  C
   gives  a  detailed  explanation  of  how  the  graphics  image itself is
   packaged as a series of data bytes.


                Graphics Interchange Format Data Definition


 GENERAL FILE FORMAT

        +-----------------------+
        | +-------------------+ |
        | |   GIF Signature   | |
        | +-------------------+ |
        | +-------------------+ |
        | | Screen Descriptor | |
        | +-------------------+ |
        | +-------------------+ |
        | | Global Color Map  | |
        | +-------------------+ |
        . . .               . . .
        | +-------------------+ |    ---+   
        | |  Image Descriptor | |       |   
        | +-------------------+ |       |   
        | +-------------------+ |       |  
        | |  Local Color Map  | |       |-   Repeated 1 to n times
        | +-------------------+ |       |   
        | +-------------------+ |       |   
        | |    Raster Data    | |       |   
        | +-------------------+ |    ---+   
        . . .               . . .   
        |-    GIF Terminator   -|   
        +-----------------------+














Graphics Interchange Format (GIF)                                    Page 4
Specification


 GIF SIGNATURE

        The following GIF Signature identifies  the  data  following  as  a
   valid GIF image stream.  It consists of the following six characters:

             G I F 8 7 a

        The last three characters '87a' may be viewed as a  version  number
   for  this  particular  GIF  definition  and will be used in general as a
   reference  in  documents  regarding  GIF  that   address   any   version
   dependencies.

 SCREEN DESCRIPTOR

        The Screen Descriptor describes the overall parameters for all  GIF
   images  following.  It defines the overall dimensions of the image space
   or logical screen required, the existance of color mapping  information,
   background  screen color, and color depth information.  This information
   is stored in a series of 8-bit bytes as described below.

              bits
         7 6 5 4 3 2 1 0  Byte #
        +---------------+
        |               |  1
        +-Screen Width -+      Raster width in pixels (LSB first)
        |               |  2
        +---------------+
        |               |  3
        +-Screen Height-+      Raster height in pixels (LSB first)
        |               |  4
        +-+-----+-+-----+      M = 1, Global color map follows Descriptor
        |M|  cr |0|pixel|  5   cr+1 = # bits of color resolution
        +-+-----+-+-----+      pixel+1 = # bits/pixel in image
        |   background  |  6   background=Color index of screen background
        +---------------+          (color is defined from the Global color
        |0 0 0 0 0 0 0 0|  7        map or default map if none specified)
        +---------------+


        The logical screen width and height can both  be  larger  than  the
   physical  display.   How  images  larger  than  the physical display are
   handled is implementation dependent and can take advantage  of  hardware
   characteristics  (e.g.   Macintosh scrolling windows).  Otherwise images
   can be clipped to the edges of the display.

        The value of 'pixel' also defines  the  maximum  number  of  colors
   within  an  image.   The  range  of  values  for 'pixel' is 0 to 7 which
   represents 1 to 8 bits.  This translates to a range of 2 (B & W) to  256
   colors.   Bit  3 of word 5 is reserved for future definition and must be
   zero.


















Graphics Interchange Format (GIF)                                    Page 5
Specification


 GLOBAL COLOR MAP

        The Global Color Map is optional but recommended for  images  where
   accurate color rendition is desired.  The existence of this color map is
   indicated in the 'M' field of byte 5 of the Screen Descriptor.  A  color
   map  can  also  be associated with each image in a GIF file as described
   later.  However this  global  map  will  normally  be  used  because  of
   hardware  restrictions  in equipment available today.  In the individual
   Image Descriptors the 'M' flag will normally be  zero.   If  the  Global
   Color  Map  is  present,  it's definition immediately follows the Screen
   Descriptor.   The  number  of  color  map  entries  following  a  Screen
   Descriptor  is equal to 2**(# bits per pixel), where each entry consists
   of three byte values representing the relative intensities of red, green
   and blue respectively.  The structure of the Color Map block is:

              bits
         7 6 5 4 3 2 1 0  Byte #
        +---------------+
        | red intensity |  1    Red value for color index 0
        +---------------+
        |green intensity|  2    Green value for color index 0
        +---------------+
        | blue intensity|  3    Blue value for color index 0
        +---------------+
        | red intensity |  4    Red value for color index 1
        +---------------+
        |green intensity|  5    Green value for color index 1
        +---------------+
        | blue intensity|  6    Blue value for color index 1
        +---------------+
        :               :       (Continues for remaining colors)

        Each image pixel value received will be displayed according to  its
   closest match with an available color of the display based on this color
   map.  The color components represent a fractional intensity  value  from
   none  (0)  to  full (255).  White would be represented as (255,255,255),
   black as (0,0,0) and medium yellow as (180,180,0).  For display, if  the
   device  supports fewer than 8 bits per color component, the higher order
   bits of each component are used.  In the creation of  a  GIF  color  map
   entry  with  hardware  supporting  fewer  than 8 bits per component, the
   component values for the hardware  should  be  converted  to  the  8-bit
   format with the following calculation:

        <map_value> = <component_value>*255/(2**<nbits> -1)

        This assures accurate translation of colors for all  displays.   In
   the  cases  of  creating  GIF images from hardware without color palette
   capability, a fixed palette should be created  based  on  the  available
   display  colors for that hardware.  If no Global Color Map is indicated,
   a default color map is generated ...
Zgłoś jeśli naruszono regulamin