| 1 |
|
| 2 |
|
| 3 |
Cover Sheet for the GIF89a Specification |
| 4 |
|
| 5 |
|
| 6 |
DEFERRED CLEAR CODE IN LZW COMPRESSION |
| 7 |
|
| 8 |
There has been confusion about where clear codes can be found in the |
| 9 |
data stream. As the specification says, they may appear at anytime. There |
| 10 |
is not a requirement to send a clear code when the string table is full. |
| 11 |
|
| 12 |
It is the encoder's decision as to when the table should be cleared. When |
| 13 |
the table is full, the encoder can chose to use the table as is, making no |
| 14 |
changes to it until the encoder chooses to clear it. The encoder during |
| 15 |
this time sends out codes that are of the maximum Code Size. |
| 16 |
|
| 17 |
As we can see from the above, when the decoder's table is full, it must |
| 18 |
not change the table until a clear code is received. The Code Size is that |
| 19 |
of the maximum Code Size. Processing other than this is done normally. |
| 20 |
|
| 21 |
Because of a large base of decoders that do not handle the decompression in |
| 22 |
this manner, we ask developers of GIF encoding software to NOT implement |
| 23 |
this feature until at least January 1991 and later if they see that their |
| 24 |
particular market is not ready for it. This will give developers of GIF |
| 25 |
decoding software time to implement this feature and to get it into the |
| 26 |
hands of their clients before the decoders start "breaking" on the new |
| 27 |
GIF's. It is not required that encoders change their software to take |
| 28 |
advantage of the deferred clear code, but it is for decoders. |
| 29 |
|
| 30 |
APPLICATION EXTENSION BLOCK - APPLICATION IDENTIFIER |
| 31 |
|
| 32 |
There will be a Courtesy Directory file located on CompuServe in the PICS |
| 33 |
forum. This directory will contain Application Identifiers for Application |
| 34 |
Extension Blocks that have been used by developers of GIF applications. |
| 35 |
This file is intended to help keep developers that wish to create |
| 36 |
Application Extension Blocks from using the same Application Identifiers. |
| 37 |
This is not an official directory; it is for voluntary participation only |
| 38 |
and does not guarantee that someone will not use the same identifier. |
| 39 |
|
| 40 |
E-Mail can be sent to Larry Wood (forum manager of PICS) indicating the |
| 41 |
request for inclusion in this file with an identifier. |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
GRAPHICS INTERCHANGE FORMAT(sm) |
| 84 |
|
| 85 |
Version 89a |
| 86 |
|
| 87 |
(c)1987,1988,1989,1990 |
| 88 |
|
| 89 |
Copyright |
| 90 |
CompuServe Incorporated |
| 91 |
Columbus, Ohio |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
CompuServe Incorporated Graphics Interchange Format |
| 123 |
Document Date : 31 July 1990 Programming Reference |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
Table of Contents |
| 135 |
|
| 136 |
Disclaimer................................................................. 1 |
| 137 |
|
| 138 |
Foreword................................................................... 1 |
| 139 |
|
| 140 |
Licensing.................................................................. 1 |
| 141 |
|
| 142 |
About the Document......................................................... 2 |
| 143 |
|
| 144 |
General Description........................................................ 2 |
| 145 |
|
| 146 |
Version Numbers............................................................ 2 |
| 147 |
|
| 148 |
The Encoder................................................................ 3 |
| 149 |
|
| 150 |
The Decoder................................................................ 3 |
| 151 |
|
| 152 |
Compliance................................................................. 3 |
| 153 |
|
| 154 |
About Recommendations...................................................... 4 |
| 155 |
|
| 156 |
About Color Tables......................................................... 4 |
| 157 |
|
| 158 |
Blocks, Extensions and Scope............................................... 4 |
| 159 |
|
| 160 |
Block Sizes................................................................ 5 |
| 161 |
|
| 162 |
Using GIF as an embedded protocol.......................................... 5 |
| 163 |
|
| 164 |
Data Sub-blocks............................................................ 5 |
| 165 |
|
| 166 |
Block Terminator........................................................... 6 |
| 167 |
|
| 168 |
Header..................................................................... 7 |
| 169 |
|
| 170 |
Logical Screen Descriptor.................................................. 8 |
| 171 |
|
| 172 |
Global Color Table......................................................... 10 |
| 173 |
|
| 174 |
Image Descriptor........................................................... 11 |
| 175 |
|
| 176 |
Local Color Table.......................................................... 13 |
| 177 |
|
| 178 |
Table Based Image Data..................................................... 14 |
| 179 |
|
| 180 |
Graphic Control Extension.................................................. 15 |
| 181 |
|
| 182 |
Comment Extension.......................................................... 17 |
| 183 |
|
| 184 |
Plain Text Extension....................................................... 18 |
| 185 |
|
| 186 |
Application Extension...................................................... 21 |
| 187 |
|
| 188 |
Trailer.................................................................... 23 |
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
Quick Reference Table...................................................... 24 |
| 201 |
|
| 202 |
GIF Grammar................................................................ 25 |
| 203 |
|
| 204 |
Glossary................................................................... 27 |
| 205 |
|
| 206 |
Conventions................................................................ 28 |
| 207 |
|
| 208 |
Interlaced Images.......................................................... 29 |
| 209 |
|
| 210 |
Variable-Length-Code LZW Compression....................................... 30 |
| 211 |
|
| 212 |
On-line Capabilities Dialogue.............................................. 33 |
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
1 |
| 264 |
|
| 265 |
|
| 266 |
1. Disclaimer. |
| 267 |
|
| 268 |
The information provided herein is subject to change without notice. In no |
| 269 |
event will CompuServe Incorporated be liable for damages, including any loss of |
| 270 |
revenue, loss of profits or other incidental or consequential damages arising |
| 271 |
out of the use or inability to use the information; CompuServe Incorporated |
| 272 |
makes no claim as to the suitability of the information. |
| 273 |
|
| 274 |
|
| 275 |
2. Foreword. |
| 276 |
|
| 277 |
This document defines the Graphics Interchange Format(sm). The specification |
| 278 |
given here defines version 89a, which is an extension of version 87a. |
| 279 |
|
| 280 |
The Graphics Interchange Format(sm) as specified here should be considered |
| 281 |
complete; any deviation from it should be considered invalid, including but not |
| 282 |
limited to, the use of reserved or undefined fields within control or data |
| 283 |
blocks, the inclusion of extraneous data within or between blocks, the use of |
| 284 |
methods or algorithms not specifically listed as part of the format, etc. In |
| 285 |
general, any and all deviations, extensions or modifications not specified in |
| 286 |
this document should be considered to be in violation of the format and should |
| 287 |
be avoided. |
| 288 |
|
| 289 |
|
| 290 |
3. Licensing. |
| 291 |
|
| 292 |
The Graphics Interchange Format(c) is the copyright property of CompuServe |
| 293 |
Incorporated. Only CompuServe Incorporated is authorized to define, redefine, |
| 294 |
enhance, alter, modify or change in any way the definition of the format. |
| 295 |
|
| 296 |
CompuServe Incorporated hereby grants a limited, non-exclusive, royalty-free |
| 297 |
license for the use of the Graphics Interchange Format(sm) in computer |
| 298 |
software; computer software utilizing GIF(sm) must acknowledge ownership of the |
| 299 |
Graphics Interchange Format and its Service Mark by CompuServe Incorporated, in |
| 300 |
User and Technical Documentation. Computer software utilizing GIF, which is |
| 301 |
distributed or may be distributed without User or Technical Documentation must |
| 302 |
display to the screen or printer a message acknowledging ownership of the |
| 303 |
Graphics Interchange Format and the Service Mark by CompuServe Incorporated; in |
| 304 |
this case, the acknowledgement may be displayed in an opening screen or leading |
| 305 |
banner, or a closing screen or trailing banner. A message such as the following |
| 306 |
may be used: |
| 307 |
|
| 308 |
"The Graphics Interchange Format(c) is the Copyright property of |
| 309 |
CompuServe Incorporated. GIF(sm) is a Service Mark property of |
| 310 |
CompuServe Incorporated." |
| 311 |
|
| 312 |
For further information, please contact : |
| 313 |
|
| 314 |
CompuServe Incorporated |
| 315 |
Graphics Technology Department |
| 316 |
5000 Arlington Center Boulevard |
| 317 |
Columbus, Ohio 43220 |
| 318 |
U. S. A. |
| 319 |
|
| 320 |
CompuServe Incorporated maintains a mailing list with all those individuals and |
| 321 |
organizations who wish to receive copies of this document when it is corrected |
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
2 |
| 330 |
|
| 331 |
|
| 332 |
or revised. This service is offered free of charge; please provide us with your |
| 333 |
mailing address. |
| 334 |
|
| 335 |
|
| 336 |
4. About the Document. |
| 337 |
|
| 338 |
This document describes in detail the definition of the Graphics Interchange |
| 339 |
Format. This document is intended as a programming reference; it is |
| 340 |
recommended that the entire document be read carefully before programming, |
| 341 |
because of the interdependence of the various parts. There is an individual |
| 342 |
section for each of the Format blocks. Within each section, the sub-section |
| 343 |
labeled Required Version refers to the version number that an encoder will have |
| 344 |
to use if the corresponding block is used in the Data Stream. Within each |
| 345 |
section, a diagram describes the individual fields in the block; the diagrams |
| 346 |
are drawn vertically; top bytes in the diagram appear first in the Data Stream. |
| 347 |
Bits within a byte are drawn most significant on the left end. Multi-byte |
| 348 |
numeric fields are ordered Least Significant Byte first. Numeric constants are |
| 349 |
represented as Hexadecimal numbers, preceded by "0x". Bit fields within a byte |
| 350 |
are described in order from most significant bits to least significant bits. |
| 351 |
|
| 352 |
|
| 353 |
5. General Description. |
| 354 |
|
| 355 |
The Graphics Interchange Format(sm) defines a protocol intended for the on-line |
| 356 |
transmission and interchange of raster graphic data in a way that is |
| 357 |
independent of the hardware used in their creation or display. |
| 358 |
|
| 359 |
The Graphics Interchange Format is defined in terms of blocks and sub-blocks |
| 360 |
which contain relevant parameters and data used in the reproduction of a |
| 361 |
graphic. A GIF Data Stream is a sequence of protocol blocks and sub-blocks |
| 362 |
representing a collection of graphics. In general, the graphics in a Data |
| 363 |
Stream are assumed to be related to some degree, and to share some control |
| 364 |
information; it is recommended that encoders attempt to group together related |
| 365 |
graphics in order to minimize hardware changes during processing and to |
| 366 |
minimize control information overhead. For the same reason, unrelated graphics |
| 367 |
or graphics which require resetting hardware parameters should be encoded |
| 368 |
separately to the extent possible. |
| 369 |
|
| 370 |
A Data Stream may originate locally, as when read from a file, or it may |
| 371 |
originate remotely, as when transmitted over a data communications line. The |
| 372 |
Format is defined with the assumption that an error-free Transport Level |
| 373 |
Protocol is used for communications; the Format makes no provisions for |
| 374 |
error-detection and error-correction. |
| 375 |
|
| 376 |
The GIF Data Stream must be interpreted in context, that is, the application |
| 377 |
program must rely on information external to the Data Stream to invoke the |
| 378 |
decoder process. |
| 379 |
|
| 380 |
|
| 381 |
6. Version Numbers. |
| 382 |
|
| 383 |
The version number in the Header of a Data Stream is intended to identify the |
| 384 |
minimum set of capabilities required of a decoder in order to fully process the |
| 385 |
Data Stream. An encoder should use the earliest possible version number that |
| 386 |
includes all the blocks used in the Data Stream. Within each block section in |
| 387 |
this document, there is an entry labeled Required Version which specifies the |
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
3 |
| 396 |
|
| 397 |
|
| 398 |
earliest version number that includes the corresponding block. The encoder |
| 399 |
should make every attempt to use the earliest version number covering all the |
| 400 |
blocks in the Data Stream; the unnecessary use of later version numbers will |
| 401 |
hinder processing by some decoders. |
| 402 |
|
| 403 |
|
| 404 |
7. The Encoder. |
| 405 |
|
| 406 |
The Encoder is the program used to create a GIF Data Stream. From raster data |
| 407 |
and other information, the encoder produces the necessary control and data |
| 408 |
blocks needed for reproducing the original graphics. |
| 409 |
|
| 410 |
The encoder has the following primary responsibilities. |
| 411 |
|
| 412 |
- Include in the Data Stream all the necessary information to |
| 413 |
reproduce the graphics. |
| 414 |
|
| 415 |
- Insure that a Data Stream is labeled with the earliest possible |
| 416 |
Version Number that will cover the definition of all the blocks in |
| 417 |
it; this is to ensure that the largest number of decoders can |
| 418 |
process the Data Stream. |
| 419 |
|
| 420 |
- Ensure encoding of the graphics in such a way that the decoding |
| 421 |
process is optimized. Avoid redundant information as much as |
| 422 |
possible. |
| 423 |
|
| 424 |
- To the extent possible, avoid grouping graphics which might |
| 425 |
require resetting hardware parameters during the decoding process. |
| 426 |
|
| 427 |
- Set to zero (off) each of the bits of each and every field |
| 428 |
designated as reserved. Note that some fields in the Logical Screen |
| 429 |
Descriptor and the Image Descriptor were reserved under Version |
| 430 |
87a, but are used under version 89a. |
| 431 |
|
| 432 |
|
| 433 |
8. The Decoder. |
| 434 |
|
| 435 |
The Decoder is the program used to process a GIF Data Stream. It processes the |
| 436 |
Data Stream sequentially, parsing the various blocks and sub-blocks, using the |
| 437 |
control information to set hardware and process parameters and interpreting the |
| 438 |
data to render the graphics. |
| 439 |
|
| 440 |
The decoder has the following primary responsibilities. |
| 441 |
|
| 442 |
- Process each graphic in the Data Stream in sequence, without |
| 443 |
delays other than those specified in the control information. |
| 444 |
|
| 445 |
- Set its hardware parameters to fit, as closely as possible, the |
| 446 |
control information contained in the Data Stream. |
| 447 |
|
| 448 |
|
| 449 |
9. Compliance. |
| 450 |
|
| 451 |
An encoder or a decoder is said to comply with a given version of the Graphics |
| 452 |
Interchange Format if and only if it fully conforms with and correctly |
| 453 |
implements the definition of the standard associated with that version. An |
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
4 |
| 462 |
|
| 463 |
|
| 464 |
encoder or a decoder may be compliant with a given version number and not |
| 465 |
compliant with some subsequent version. |
| 466 |
|
| 467 |
|
| 468 |
10. About Recommendations. |
| 469 |
|
| 470 |
Each block section in this document contains an entry labeled Recommendation; |
| 471 |
this section lists a set of recommendations intended to guide and organize the |
| 472 |
use of the particular blocks. Such recommendations are geared towards making |
| 473 |
the functions of encoders and decoders more efficient, as well as making |
| 474 |
optimal use of the communications bandwidth. It is advised that these |
| 475 |
recommendations be followed. |
| 476 |
|
| 477 |
|
| 478 |
11. About Color Tables. |
| 479 |
|
| 480 |
The GIF format utilizes color tables to render raster-based graphics. A color |
| 481 |
table can have one of two different scopes: global or local. A Global Color |
| 482 |
Table is used by all those graphics in the Data Stream which do not have a |
| 483 |
Local Color Table associated with them. The scope of the Global Color Table is |
| 484 |
the entire Data Stream. A Local Color Table is always associated with the |
| 485 |
graphic that immediately follows it; the scope of a Local Color Table is |
| 486 |
limited to that single graphic. A Local Color Table supersedes a Global Color |
| 487 |
Table, that is, if a Data Stream contains a Global Color Table, and an image |
| 488 |
has a Local Color Table associated with it, the decoder must save the Global |
| 489 |
Color Table, use the Local Color Table to render the image, and then restore |
| 490 |
the Global Color Table. Both types of color tables are optional, making it |
| 491 |
possible for a Data Stream to contain numerous graphics without a color table |
| 492 |
at all. For this reason, it is recommended that the decoder save the last |
| 493 |
Global Color Table used until another Global Color Table is encountered. In |
| 494 |
this way, a Data Stream which does not contain either a Global Color Table or |
| 495 |
a Local Color Table may be processed using the last Global Color Table saved. |
| 496 |
If a Global Color Table from a previous Stream is used, that table becomes the |
| 497 |
Global Color Table of the present Stream. This is intended to reduce the |
| 498 |
overhead incurred by color tables. In particular, it is recommended that an |
| 499 |
encoder use only one Global Color Table if all the images in related Data |
| 500 |
Streams can be rendered with the same table. If no color table is available at |
| 501 |
all, the decoder is free to use a system color table or a table of its own. In |
| 502 |
that case, the decoder may use a color table with as many colors as its |
| 503 |
hardware is able to support; it is recommended that such a table have black and |
| 504 |
white as its first two entries, so that monochrome images can be rendered |
| 505 |
adequately. |
| 506 |
|
| 507 |
The Definition of the GIF Format allows for a Data Stream to contain only the |
| 508 |
Header, the Logical Screen Descriptor, a Global Color Table and the GIF |
| 509 |
Trailer. Such a Data Stream would be used to load a decoder with a Global Color |
| 510 |
Table, in preparation for subsequent Data Streams without a color table at all. |
| 511 |
|
| 512 |
|
| 513 |
12. Blocks, Extensions and Scope. |
| 514 |
|
| 515 |
Blocks can be classified into three groups : Control, Graphic-Rendering and |
| 516 |
Special Purpose. Control blocks, such as the Header, the Logical Screen |
| 517 |
Descriptor, the Graphic Control Extension and the Trailer, contain information |
| 518 |
used to control the process of the Data Stream or information used in setting |
| 519 |
hardware parameters. Graphic-Rendering blocks such as the Image Descriptor and |
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
5 |
| 528 |
|
| 529 |
|
| 530 |
the Plain Text Extension contain information and data used to render a graphic |
| 531 |
on the display device. Special Purpose blocks such as the Comment Extension and |
| 532 |
the Application Extension are neither used to control the process of the Data |
| 533 |
Stream nor do they contain information or data used to render a graphic on the |
| 534 |
display device. With the exception of the Logical Screen Descriptor and the |
| 535 |
Global Color Table, whose scope is the entire Data Stream, all other Control |
| 536 |
blocks have a limited scope, restricted to the Graphic-Rendering block that |
| 537 |
follows them. Special Purpose blocks do not delimit the scope of any Control |
| 538 |
blocks; Special Purpose blocks are transparent to the decoding process. |
| 539 |
Graphic-Rendering blocks and extensions are used as scope delimiters for |
| 540 |
Control blocks and extensions. The labels used to identify labeled blocks fall |
| 541 |
into three ranges : 0x00-0x7F (0-127) are the Graphic Rendering blocks, |
| 542 |
excluding the Trailer (0x3B); 0x80-0xF9 (128-249) are the Control blocks; |
| 543 |
0xFA-0xFF (250-255) are the Special Purpose blocks. These ranges are defined so |
| 544 |
that decoders can handle block scope by appropriately identifying block labels, |
| 545 |
even when the block itself cannot be processed. |
| 546 |
|
| 547 |
|
| 548 |
13. Block Sizes. |
| 549 |
|
| 550 |
The Block Size field in a block, counts the number of bytes remaining in the |
| 551 |
block, not counting the Block Size field itself, and not counting the Block |
| 552 |
Terminator, if one is to follow. Blocks other than Data Blocks are intended to |
| 553 |
be of fixed length; the Block Size field is provided in order to facilitate |
| 554 |
skipping them, not to allow their size to change in the future. Data blocks |
| 555 |
and sub-blocks are of variable length to accommodate the amount of data. |
| 556 |
|
| 557 |
|
| 558 |
14. Using GIF as an embedded protocol. |
| 559 |
|
| 560 |
As an embedded protocol, GIF may be part of larger application protocols, |
| 561 |
within which GIF is used to render graphics. In such a case, the application |
| 562 |
protocol could define a block within which the GIF Data Stream would be |
| 563 |
contained. The application program would then invoke a GIF decoder upon |
| 564 |
encountering a block of type GIF. This approach is recommended in favor of |
| 565 |
using Application Extensions, which become overhead for all other applications |
| 566 |
that do not process them. Because a GIF Data Stream must be processed in |
| 567 |
context, the application must rely on some means of identifying the GIF Data |
| 568 |
Stream outside of the Stream itself. |
| 569 |
|
| 570 |
|
| 571 |
15. Data Sub-blocks. |
| 572 |
|
| 573 |
a. Description. Data Sub-blocks are units containing data. They do not |
| 574 |
have a label, these blocks are processed in the context of control |
| 575 |
blocks, wherever data blocks are specified in the format. The first byte |
| 576 |
of the Data sub-block indicates the number of data bytes to follow. A |
| 577 |
data sub-block may contain from 0 to 255 data bytes. The size of the |
| 578 |
block does not account for the size byte itself, therefore, the empty |
| 579 |
sub-block is one whose size field contains 0x00. |
| 580 |
|
| 581 |
b. Required Version. 87a. |
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
6 |
| 594 |
|
| 595 |
|
| 596 |
c. Syntax. |
| 597 |
|
| 598 |
7 6 5 4 3 2 1 0 Field Name Type |
| 599 |
+---------------+ |
| 600 |
0 | | Block Size Byte |
| 601 |
+---------------+ |
| 602 |
1 | | |
| 603 |
+- -+ |
| 604 |
2 | | |
| 605 |
+- -+ |
| 606 |
3 | | |
| 607 |
+- -+ |
| 608 |
| | Data Values Byte |
| 609 |
+- -+ |
| 610 |
up | | |
| 611 |
+- . . . . -+ |
| 612 |
to | | |
| 613 |
+- -+ |
| 614 |
| | |
| 615 |
+- -+ |
| 616 |
255 | | |
| 617 |
+---------------+ |
| 618 |
|
| 619 |
i) Block Size - Number of bytes in the Data Sub-block; the size |
| 620 |
must be within 0 and 255 bytes, inclusive. |
| 621 |
|
| 622 |
ii) Data Values - Any 8-bit value. There must be exactly as many |
| 623 |
Data Values as specified by the Block Size field. |
| 624 |
|
| 625 |
d. Extensions and Scope. This type of block always occurs as part of a |
| 626 |
larger unit. It does not have a scope of itself. |
| 627 |
|
| 628 |
e. Recommendation. None. |
| 629 |
|
| 630 |
|
| 631 |
16. Block Terminator. |
| 632 |
|
| 633 |
a. Description. This zero-length Data Sub-block is used to terminate a |
| 634 |
sequence of Data Sub-blocks. It contains a single byte in the position of |
| 635 |
the Block Size field and does not contain data. |
| 636 |
|
| 637 |
b. Required Version. 87a. |
| 638 |
|
| 639 |
c. Syntax. |
| 640 |
|
| 641 |
7 6 5 4 3 2 1 0 Field Name Type |
| 642 |
+---------------+ |
| 643 |
0 | | Block Size Byte |
| 644 |
+---------------+ |
| 645 |
|
| 646 |
i) Block Size - Number of bytes in the Data Sub-block; this field |
| 647 |
contains the fixed value 0x00. |
| 648 |
|
| 649 |
ii) Data Values - This block does not contain any data. |
| 650 |
|
| 651 |
|
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
7 |
| 660 |
|
| 661 |
|
| 662 |
d. Extensions and Scope. This block terminates the immediately preceding |
| 663 |
sequence of Data Sub-blocks. This block cannot be modified by any |
| 664 |
extension. |
| 665 |
|
| 666 |
e. Recommendation. None. |
| 667 |
|
| 668 |
|
| 669 |
17. Header. |
| 670 |
|
| 671 |
a. Description. The Header identifies the GIF Data Stream in context. The |
| 672 |
Signature field marks the beginning of the Data Stream, and the Version |
| 673 |
field identifies the set of capabilities required of a decoder to fully |
| 674 |
process the Data Stream. This block is REQUIRED; exactly one Header must |
| 675 |
be present per Data Stream. |
| 676 |
|
| 677 |
b. Required Version. Not applicable. This block is not subject to a |
| 678 |
version number. This block must appear at the beginning of every Data |
| 679 |
Stream. |
| 680 |
|
| 681 |
c. Syntax. |
| 682 |
|
| 683 |
|
| 684 |
7 6 5 4 3 2 1 0 Field Name Type |
| 685 |
+---------------+ |
| 686 |
0 | | Signature 3 Bytes |
| 687 |
+- -+ |
| 688 |
1 | | |
| 689 |
+- -+ |
| 690 |
2 | | |
| 691 |
+---------------+ |
| 692 |
3 | | Version 3 Bytes |
| 693 |
+- -+ |
| 694 |
4 | | |
| 695 |
+- -+ |
| 696 |
5 | | |
| 697 |
+---------------+ |
| 698 |
|
| 699 |
i) Signature - Identifies the GIF Data Stream. This field contains |
| 700 |
the fixed value 'GIF'. |
| 701 |
|
| 702 |
ii) Version - Version number used to format the data stream. |
| 703 |
Identifies the minimum set of capabilities necessary to a decoder |
| 704 |
to fully process the contents of the Data Stream. |
| 705 |
|
| 706 |
Version Numbers as of 10 July 1990 : "87a" - May 1987 |
| 707 |
"89a" - July 1989 |
| 708 |
|
| 709 |
Version numbers are ordered numerically increasing on the first two |
| 710 |
digits starting with 87 (87,88,...,99,00,...,85,86) and |
| 711 |
alphabetically increasing on the third character (a,...,z). |
| 712 |
|
| 713 |
iii) Extensions and Scope. The scope of this block is the entire |
| 714 |
Data Stream. This block cannot be modified by any extension. |
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
8 |
| 726 |
|
| 727 |
|
| 728 |
d. Recommendations. |
| 729 |
|
| 730 |
i) Signature - This field identifies the beginning of the GIF Data |
| 731 |
Stream; it is not intended to provide a unique signature for the |
| 732 |
identification of the data. It is recommended that the GIF Data |
| 733 |
Stream be identified externally by the application. (Refer to |
| 734 |
Appendix G for on-line identification of the GIF Data Stream.) |
| 735 |
|
| 736 |
ii) Version - ENCODER : An encoder should use the earliest possible |
| 737 |
version number that defines all the blocks used in the Data Stream. |
| 738 |
When two or more Data Streams are combined, the latest of the |
| 739 |
individual version numbers should be used for the resulting Data |
| 740 |
Stream. DECODER : A decoder should attempt to process the data |
| 741 |
stream to the best of its ability; if it encounters a version |
| 742 |
number which it is not capable of processing fully, it should |
| 743 |
nevertheless, attempt to process the data stream to the best of its |
| 744 |
ability, perhaps after warning the user that the data may be |
| 745 |
incomplete. |
| 746 |
|
| 747 |
|
| 748 |
18. Logical Screen Descriptor. |
| 749 |
|
| 750 |
a. Description. The Logical Screen Descriptor contains the parameters |
| 751 |
necessary to define the area of the display device within which the |
| 752 |
images will be rendered. The coordinates in this block are given with |
| 753 |
respect to the top-left corner of the virtual screen; they do not |
| 754 |
necessarily refer to absolute coordinates on the display device. This |
| 755 |
implies that they could refer to window coordinates in a window-based |
| 756 |
environment or printer coordinates when a printer is used. |
| 757 |
|
| 758 |
This block is REQUIRED; exactly one Logical Screen Descriptor must be |
| 759 |
present per Data Stream. |
| 760 |
|
| 761 |
b. Required Version. Not applicable. This block is not subject to a |
| 762 |
version number. This block must appear immediately after the Header. |
| 763 |
|
| 764 |
c. Syntax. |
| 765 |
|
| 766 |
7 6 5 4 3 2 1 0 Field Name Type |
| 767 |
+---------------+ |
| 768 |
0 | | Logical Screen Width Unsigned |
| 769 |
+- -+ |
| 770 |
1 | | |
| 771 |
+---------------+ |
| 772 |
2 | | Logical Screen Height Unsigned |
| 773 |
+- -+ |
| 774 |
3 | | |
| 775 |
+---------------+ |
| 776 |
4 | | | | | <Packed Fields> See below |
| 777 |
+---------------+ |
| 778 |
5 | | Background Color Index Byte |
| 779 |
+---------------+ |
| 780 |
6 | | Pixel Aspect Ratio Byte |
| 781 |
+---------------+ |
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
|
| 790 |
|
| 791 |
9 |
| 792 |
|
| 793 |
|
| 794 |
<Packed Fields> = Global Color Table Flag 1 Bit |
| 795 |
Color Resolution 3 Bits |
| 796 |
Sort Flag 1 Bit |
| 797 |
Size of Global Color Table 3 Bits |
| 798 |
|
| 799 |
i) Logical Screen Width - Width, in pixels, of the Logical Screen |
| 800 |
where the images will be rendered in the displaying device. |
| 801 |
|
| 802 |
ii) Logical Screen Height - Height, in pixels, of the Logical |
| 803 |
Screen where the images will be rendered in the displaying device. |
| 804 |
|
| 805 |
iii) Global Color Table Flag - Flag indicating the presence of a |
| 806 |
Global Color Table; if the flag is set, the Global Color Table will |
| 807 |
immediately follow the Logical Screen Descriptor. This flag also |
| 808 |
selects the interpretation of the Background Color Index; if the |
| 809 |
flag is set, the value of the Background Color Index field should |
| 810 |
be used as the table index of the background color. (This field is |
| 811 |
the most significant bit of the byte.) |
| 812 |
|
| 813 |
Values : 0 - No Global Color Table follows, the Background |
| 814 |
Color Index field is meaningless. |
| 815 |
1 - A Global Color Table will immediately follow, the |
| 816 |
Background Color Index field is meaningful. |
| 817 |
|
| 818 |
iv) Color Resolution - Number of bits per primary color available |
| 819 |
to the original image, minus 1. This value represents the size of |
| 820 |
the entire palette from which the colors in the graphic were |
| 821 |
selected, not the number of colors actually used in the graphic. |
| 822 |
For example, if the value in this field is 3, then the palette of |
| 823 |
the original image had 4 bits per primary color available to create |
| 824 |
the image. This value should be set to indicate the richness of |
| 825 |
the original palette, even if not every color from the whole |
| 826 |
palette is available on the source machine. |
| 827 |
|
| 828 |
v) Sort Flag - Indicates whether the Global Color Table is sorted. |
| 829 |
If the flag is set, the Global Color Table is sorted, in order of |
| 830 |
decreasing importance. Typically, the order would be decreasing |
| 831 |
frequency, with most frequent color first. This assists a decoder, |
| 832 |
with fewer available colors, in choosing the best subset of colors; |
| 833 |
the decoder may use an initial segment of the table to render the |
| 834 |
graphic. |
| 835 |
|
| 836 |
Values : 0 - Not ordered. |
| 837 |
1 - Ordered by decreasing importance, most |
| 838 |
important color first. |
| 839 |
|
| 840 |
vi) Size of Global Color Table - If the Global Color Table Flag is |
| 841 |
set to 1, the value in this field is used to calculate the number |
| 842 |
of bytes contained in the Global Color Table. To determine that |
| 843 |
actual size of the color table, raise 2 to [the value of the field |
| 844 |
+ 1]. Even if there is no Global Color Table specified, set this |
| 845 |
field according to the above formula so that decoders can choose |
| 846 |
the best graphics mode to display the stream in. (This field is |
| 847 |
made up of the 3 least significant bits of the byte.) |
| 848 |
|
| 849 |
vii) Background Color Index - Index into the Global Color Table for |
| 850 |
|
| 851 |
|
| 852 |
|
| 853 |
|
| 854 |
|
| 855 |
|
| 856 |
|
| 857 |
10 |
| 858 |
|
| 859 |
|
| 860 |
the Background Color. The Background Color is the color used for |
| 861 |
those pixels on the screen that are not covered by an image. If the |
| 862 |
Global Color Table Flag is set to (zero), this field should be zero |
| 863 |
and should be ignored. |
| 864 |
|
| 865 |
viii) Pixel Aspect Ratio - Factor used to compute an approximation |
| 866 |
of the aspect ratio of the pixel in the original image. If the |
| 867 |
value of the field is not 0, this approximation of the aspect ratio |
| 868 |
is computed based on the formula: |
| 869 |
|
| 870 |
Aspect Ratio = (Pixel Aspect Ratio + 15) / 64 |
| 871 |
|
| 872 |
The Pixel Aspect Ratio is defined to be the quotient of the pixel's |
| 873 |
width over its height. The value range in this field allows |
| 874 |
specification of the widest pixel of 4:1 to the tallest pixel of |
| 875 |
1:4 in increments of 1/64th. |
| 876 |
|
| 877 |
Values : 0 - No aspect ratio information is given. |
| 878 |
1..255 - Value used in the computation. |
| 879 |
|
| 880 |
d. Extensions and Scope. The scope of this block is the entire Data |
| 881 |
Stream. This block cannot be modified by any extension. |
| 882 |
|
| 883 |
e. Recommendations. None. |
| 884 |
|
| 885 |
|
| 886 |
19. Global Color Table. |
| 887 |
|
| 888 |
a. Description. This block contains a color table, which is a sequence of |
| 889 |
bytes representing red-green-blue color triplets. The Global Color Table |
| 890 |
is used by images without a Local Color Table and by Plain Text |
| 891 |
Extensions. Its presence is marked by the Global Color Table Flag being |
| 892 |
set to 1 in the Logical Screen Descriptor; if present, it immediately |
| 893 |
follows the Logical Screen Descriptor and contains a number of bytes |
| 894 |
equal to |
| 895 |
3 x 2^(Size of Global Color Table+1). |
| 896 |
|
| 897 |
This block is OPTIONAL; at most one Global Color Table may be present |
| 898 |
per Data Stream. |
| 899 |
|
| 900 |
b. Required Version. 87a |
| 901 |
|
| 902 |
|
| 903 |
|
| 904 |
|
| 905 |
|
| 906 |
|
| 907 |
|
| 908 |
|
| 909 |
|
| 910 |
|
| 911 |
|
| 912 |
|
| 913 |
|
| 914 |
|
| 915 |
|
| 916 |
|
| 917 |
|
| 918 |
|
| 919 |
|
| 920 |
|
| 921 |
|
| 922 |
|
| 923 |
11 |
| 924 |
|
| 925 |
|
| 926 |
c. Syntax. |
| 927 |
|
| 928 |
7 6 5 4 3 2 1 0 Field Name Type |
| 929 |
+===============+ |
| 930 |
0 | | Red 0 Byte |
| 931 |
+- -+ |
| 932 |
1 | | Green 0 Byte |
| 933 |
+- -+ |
| 934 |
2 | | Blue 0 Byte |
| 935 |
+- -+ |
| 936 |
3 | | Red 1 Byte |
| 937 |
+- -+ |
| 938 |
| | Green 1 Byte |
| 939 |
+- -+ |
| 940 |
up | | |
| 941 |
+- . . . . -+ ... |
| 942 |
to | | |
| 943 |
+- -+ |
| 944 |
| | Green 255 Byte |
| 945 |
+- -+ |
| 946 |
767 | | Blue 255 Byte |
| 947 |
+===============+ |
| 948 |
|
| 949 |
|
| 950 |
d. Extensions and Scope. The scope of this block is the entire Data |
| 951 |
Stream. This block cannot be modified by any extension. |
| 952 |
|
| 953 |
e. Recommendation. None. |
| 954 |
|
| 955 |
|
| 956 |
20. Image Descriptor. |
| 957 |
|
| 958 |
a. Description. Each image in the Data Stream is composed of an Image |
| 959 |
Descriptor, an optional Local Color Table, and the image data. Each |
| 960 |
image must fit within the boundaries of the Logical Screen, as defined |
| 961 |
in the Logical Screen Descriptor. |
| 962 |
|
| 963 |
The Image Descriptor contains the parameters necessary to process a table |
| 964 |
based image. The coordinates given in this block refer to coordinates |
| 965 |
within the Logical Screen, and are given in pixels. This block is a |
| 966 |
Graphic-Rendering Block, optionally preceded by one or more Control |
| 967 |
blocks such as the Graphic Control Extension, and may be optionally |
| 968 |
followed by a Local Color Table; the Image Descriptor is always followed |
| 969 |
by the image data. |
| 970 |
|
| 971 |
This block is REQUIRED for an image. Exactly one Image Descriptor must |
| 972 |
be present per image in the Data Stream. An unlimited number of images |
| 973 |
may be present per Data Stream. |
| 974 |
|
| 975 |
b. Required Version. 87a. |
| 976 |
|
| 977 |
|
| 978 |
|
| 979 |
|
| 980 |
|
| 981 |
|
| 982 |
|
| 983 |
|
| 984 |
|
| 985 |
|
| 986 |
|
| 987 |
|
| 988 |
|
| 989 |
12 |
| 990 |
|
| 991 |
|
| 992 |
c. Syntax. |
| 993 |
|
| 994 |
7 6 5 4 3 2 1 0 Field Name Type |
| 995 |
+---------------+ |
| 996 |
0 | | Image Separator Byte |
| 997 |
+---------------+ |
| 998 |
1 | | Image Left Position Unsigned |
| 999 |
+- -+ |
| 1000 |
2 | | |
| 1001 |
+---------------+ |
| 1002 |
3 | | Image Top Position Unsigned |
| 1003 |
+- -+ |
| 1004 |
4 | | |
| 1005 |
+---------------+ |
| 1006 |
5 | | Image Width Unsigned |
| 1007 |
+- -+ |
| 1008 |
6 | | |
| 1009 |
+---------------+ |
| 1010 |
7 | | Image Height Unsigned |
| 1011 |
+- -+ |
| 1012 |
8 | | |
| 1013 |
+---------------+ |
| 1014 |
9 | | | | | | <Packed Fields> See below |
| 1015 |
+---------------+ |
| 1016 |
|
| 1017 |
<Packed Fields> = Local Color Table Flag 1 Bit |
| 1018 |
Interlace Flag 1 Bit |
| 1019 |
Sort Flag 1 Bit |
| 1020 |
Reserved 2 Bits |
| 1021 |
Size of Local Color Table 3 Bits |
| 1022 |
|
| 1023 |
i) Image Separator - Identifies the beginning of an Image |
| 1024 |
Descriptor. This field contains the fixed value 0x2C. |
| 1025 |
|
| 1026 |
ii) Image Left Position - Column number, in pixels, of the left edge |
| 1027 |
of the image, with respect to the left edge of the Logical Screen. |
| 1028 |
Leftmost column of the Logical Screen is 0. |
| 1029 |
|
| 1030 |
iii) Image Top Position - Row number, in pixels, of the top edge of |
| 1031 |
the image with respect to the top edge of the Logical Screen. Top |
| 1032 |
row of the Logical Screen is 0. |
| 1033 |
|
| 1034 |
iv) Image Width - Width of the image in pixels. |
| 1035 |
|
| 1036 |
v) Image Height - Height of the image in pixels. |
| 1037 |
|
| 1038 |
vi) Local Color Table Flag - Indicates the presence of a Local Color |
| 1039 |
Table immediately following this Image Descriptor. (This field is |
| 1040 |
the most significant bit of the byte.) |
| 1041 |
|
| 1042 |
|
| 1043 |
Values : 0 - Local Color Table is not present. Use |
| 1044 |
Global Color Table if available. |
| 1045 |
1 - Local Color Table present, and to follow |
| 1046 |
immediately after this Image Descriptor. |
| 1047 |
|
| 1048 |
|
| 1049 |
|
| 1050 |
|
| 1051 |
|
| 1052 |
|
| 1053 |
|
| 1054 |
|
| 1055 |
13 |
| 1056 |
|
| 1057 |
|
| 1058 |
vii) Interlace Flag - Indicates if the image is interlaced. An image |
| 1059 |
is interlaced in a four-pass interlace pattern; see Appendix E for |
| 1060 |
details. |
| 1061 |
|
| 1062 |
Values : 0 - Image is not interlaced. |
| 1063 |
1 - Image is interlaced. |
| 1064 |
|
| 1065 |
viii) Sort Flag - Indicates whether the Local Color Table is |
| 1066 |
sorted. If the flag is set, the Local Color Table is sorted, in |
| 1067 |
order of decreasing importance. Typically, the order would be |
| 1068 |
decreasing frequency, with most frequent color first. This assists |
| 1069 |
a decoder, with fewer available colors, in choosing the best subset |
| 1070 |
of colors; the decoder may use an initial segment of the table to |
| 1071 |
render the graphic. |
| 1072 |
|
| 1073 |
Values : 0 - Not ordered. |
| 1074 |
1 - Ordered by decreasing importance, most |
| 1075 |
important color first. |
| 1076 |
|
| 1077 |
ix) Size of Local Color Table - If the Local Color Table Flag is |
| 1078 |
set to 1, the value in this field is used to calculate the number |
| 1079 |
of bytes contained in the Local Color Table. To determine that |
| 1080 |
actual size of the color table, raise 2 to the value of the field |
| 1081 |
+ 1. This value should be 0 if there is no Local Color Table |
| 1082 |
specified. (This field is made up of the 3 least significant bits |
| 1083 |
of the byte.) |
| 1084 |
|
| 1085 |
d. Extensions and Scope. The scope of this block is the Table-based Image |
| 1086 |
Data Block that follows it. This block may be modified by the Graphic |
| 1087 |
Control Extension. |
| 1088 |
|
| 1089 |
e. Recommendation. None. |
| 1090 |
|
| 1091 |
|
| 1092 |
21. Local Color Table. |
| 1093 |
|
| 1094 |
a. Description. This block contains a color table, which is a sequence of |
| 1095 |
bytes representing red-green-blue color triplets. The Local Color Table |
| 1096 |
is used by the image that immediately follows. Its presence is marked by |
| 1097 |
the Local Color Table Flag being set to 1 in the Image Descriptor; if |
| 1098 |
present, the Local Color Table immediately follows the Image Descriptor |
| 1099 |
and contains a number of bytes equal to |
| 1100 |
3x2^(Size of Local Color Table+1). |
| 1101 |
If present, this color table temporarily becomes the active color table |
| 1102 |
and the following image should be processed using it. This block is |
| 1103 |
OPTIONAL; at most one Local Color Table may be present per Image |
| 1104 |
Descriptor and its scope is the single image associated with the Image |
| 1105 |
Descriptor that precedes it. |
| 1106 |
|
| 1107 |
b. Required Version. 87a. |
| 1108 |
|
| 1109 |
|
| 1110 |
|
| 1111 |
|
| 1112 |
|
| 1113 |
|
| 1114 |
|
| 1115 |
|
| 1116 |
|
| 1117 |
|
| 1118 |
|
| 1119 |
|
| 1120 |
|
| 1121 |
14 |
| 1122 |
|
| 1123 |
|
| 1124 |
c. Syntax. |
| 1125 |
|
| 1126 |
7 6 5 4 3 2 1 0 Field Name Type |
| 1127 |
+===============+ |
| 1128 |
0 | | Red 0 Byte |
| 1129 |
+- -+ |
| 1130 |
1 | | Green 0 Byte |
| 1131 |
+- -+ |
| 1132 |
2 | | Blue 0 Byte |
| 1133 |
+- -+ |
| 1134 |
3 | | Red 1 Byte |
| 1135 |
+- -+ |
| 1136 |
| | Green 1 Byte |
| 1137 |
+- -+ |
| 1138 |
up | | |
| 1139 |
+- . . . . -+ ... |
| 1140 |
to | | |
| 1141 |
+- -+ |
| 1142 |
| | Green 255 Byte |
| 1143 |
+- -+ |
| 1144 |
767 | | Blue 255 Byte |
| 1145 |
+===============+ |
| 1146 |
|
| 1147 |
|
| 1148 |
d. Extensions and Scope. The scope of this block is the Table-based Image |
| 1149 |
Data Block that immediately follows it. This block cannot be modified by |
| 1150 |
any extension. |
| 1151 |
|
| 1152 |
e. Recommendations. None. |
| 1153 |
|
| 1154 |
|
| 1155 |
22. Table Based Image Data. |
| 1156 |
|
| 1157 |
a. Description. The image data for a table based image consists of a |
| 1158 |
sequence of sub-blocks, of size at most 255 bytes each, containing an |
| 1159 |
index into the active color table, for each pixel in the image. Pixel |
| 1160 |
indices are in order of left to right and from top to bottom. Each index |
| 1161 |
must be within the range of the size of the active color table, starting |
| 1162 |
at 0. The sequence of indices is encoded using the LZW Algorithm with |
| 1163 |
variable-length code, as described in Appendix F |
| 1164 |
|
| 1165 |
b. Required Version. 87a. |
| 1166 |
|
| 1167 |
c. Syntax. The image data format is as follows: |
| 1168 |
|
| 1169 |
7 6 5 4 3 2 1 0 Field Name Type |
| 1170 |
+---------------+ |
| 1171 |
| | LZW Minimum Code Size Byte |
| 1172 |
+---------------+ |
| 1173 |
|
| 1174 |
+===============+ |
| 1175 |
| | |
| 1176 |
/ / Image Data Data Sub-blocks |
| 1177 |
| | |
| 1178 |
+===============+ |
| 1179 |
|
| 1180 |
|
| 1181 |
|
| 1182 |
|
| 1183 |
|
| 1184 |
|
| 1185 |
|
| 1186 |
|
| 1187 |
15 |
| 1188 |
|
| 1189 |
|
| 1190 |
i) LZW Minimum Code Size. This byte determines the initial number |
| 1191 |
of bits used for LZW codes in the image data, as described in |
| 1192 |
Appendix F. |
| 1193 |
|
| 1194 |
d. Extensions and Scope. This block has no scope, it contains raster |
| 1195 |
data. Extensions intended to modify a Table-based image must appear |
| 1196 |
before the corresponding Image Descriptor. |
| 1197 |
|
| 1198 |
e. Recommendations. None. |
| 1199 |
|
| 1200 |
|
| 1201 |
23. Graphic Control Extension. |
| 1202 |
|
| 1203 |
a. Description. The Graphic Control Extension contains parameters used |
| 1204 |
when processing a graphic rendering block. The scope of this extension is |
| 1205 |
the first graphic rendering block to follow. The extension contains only |
| 1206 |
one data sub-block. |
| 1207 |
|
| 1208 |
This block is OPTIONAL; at most one Graphic Control Extension may precede |
| 1209 |
a graphic rendering block. This is the only limit to the number of |
| 1210 |
Graphic Control Extensions that may be contained in a Data Stream. |
| 1211 |
|
| 1212 |
b. Required Version. 89a. |
| 1213 |
|
| 1214 |
c. Syntax. |
| 1215 |
|
| 1216 |
7 6 5 4 3 2 1 0 Field Name Type |
| 1217 |
+---------------+ |
| 1218 |
0 | | Extension Introducer Byte |
| 1219 |
+---------------+ |
| 1220 |
1 | | Graphic Control Label Byte |
| 1221 |
+---------------+ |
| 1222 |
|
| 1223 |
+---------------+ |
| 1224 |
0 | | Block Size Byte |
| 1225 |
+---------------+ |
| 1226 |
1 | | | | | <Packed Fields> See below |
| 1227 |
+---------------+ |
| 1228 |
2 | | Delay Time Unsigned |
| 1229 |
+- -+ |
| 1230 |
3 | | |
| 1231 |
+---------------+ |
| 1232 |
4 | | Transparent Color Index Byte |
| 1233 |
+---------------+ |
| 1234 |
|
| 1235 |
+---------------+ |
| 1236 |
0 | | Block Terminator Byte |
| 1237 |
+---------------+ |
| 1238 |
|
| 1239 |
|
| 1240 |
<Packed Fields> = Reserved 3 Bits |
| 1241 |
Disposal Method 3 Bits |
| 1242 |
User Input Flag 1 Bit |
| 1243 |
Transparent Color Flag 1 Bit |
| 1244 |
|
| 1245 |
i) Extension Introducer - Identifies the beginning of an extension |
| 1246 |
|
| 1247 |
|
| 1248 |
|
| 1249 |
|
| 1250 |
|
| 1251 |
|
| 1252 |
|
| 1253 |
16 |
| 1254 |
|
| 1255 |
|
| 1256 |
block. This field contains the fixed value 0x21. |
| 1257 |
|
| 1258 |
ii) Graphic Control Label - Identifies the current block as a |
| 1259 |
Graphic Control Extension. This field contains the fixed value |
| 1260 |
0xF9. |
| 1261 |
|
| 1262 |
iii) Block Size - Number of bytes in the block, after the Block |
| 1263 |
Size field and up to but not including the Block Terminator. This |
| 1264 |
field contains the fixed value 4. |
| 1265 |
|
| 1266 |
iv) Disposal Method - Indicates the way in which the graphic is to |
| 1267 |
be treated after being displayed. |
| 1268 |
|
| 1269 |
Values : 0 - No disposal specified. The decoder is |
| 1270 |
not required to take any action. |
| 1271 |
1 - Do not dispose. The graphic is to be left |
| 1272 |
in place. |
| 1273 |
2 - Restore to background color. The area used by the |
| 1274 |
graphic must be restored to the background color. |
| 1275 |
3 - Restore to previous. The decoder is required to |
| 1276 |
restore the area overwritten by the graphic with |
| 1277 |
what was there prior to rendering the graphic. |
| 1278 |
4-7 - To be defined. |
| 1279 |
|
| 1280 |
v) User Input Flag - Indicates whether or not user input is |
| 1281 |
expected before continuing. If the flag is set, processing will |
| 1282 |
continue when user input is entered. The nature of the User input |
| 1283 |
is determined by the application (Carriage Return, Mouse Button |
| 1284 |
Click, etc.). |
| 1285 |
|
| 1286 |
Values : 0 - User input is not expected. |
| 1287 |
1 - User input is expected. |
| 1288 |
|
| 1289 |
When a Delay Time is used and the User Input Flag is set, |
| 1290 |
processing will continue when user input is received or when the |
| 1291 |
delay time expires, whichever occurs first. |
| 1292 |
|
| 1293 |
vi) Transparency Flag - Indicates whether a transparency index is |
| 1294 |
given in the Transparent Index field. (This field is the least |
| 1295 |
significant bit of the byte.) |
| 1296 |
|
| 1297 |
Values : 0 - Transparent Index is not given. |
| 1298 |
1 - Transparent Index is given. |
| 1299 |
|
| 1300 |
vii) Delay Time - If not 0, this field specifies the number of |
| 1301 |
hundredths (1/100) of a second to wait before continuing with the |
| 1302 |
processing of the Data Stream. The clock starts ticking immediately |
| 1303 |
after the graphic is rendered. This field may be used in |
| 1304 |
conjunction with the User Input Flag field. |
| 1305 |
|
| 1306 |
viii) Transparency Index - The Transparency Index is such that when |
| 1307 |
encountered, the corresponding pixel of the display device is not |
| 1308 |
modified and processing goes on to the next pixel. The index is |
| 1309 |
present if and only if the Transparency Flag is set to 1. |
| 1310 |
|
| 1311 |
ix) Block Terminator - This zero-length data block marks the end of |
| 1312 |
|
| 1313 |
|
| 1314 |
|
| 1315 |
|
| 1316 |
|
| 1317 |
|
| 1318 |
|
| 1319 |
17 |
| 1320 |
|
| 1321 |
the Graphic Control Extension. |
| 1322 |
|
| 1323 |
d. Extensions and Scope. The scope of this Extension is the graphic |
| 1324 |
rendering block that follows it; it is possible for other extensions to |
| 1325 |
be present between this block and its target. This block can modify the |
| 1326 |
Image Descriptor Block and the Plain Text Extension. |
| 1327 |
|
| 1328 |
e. Recommendations. |
| 1329 |
|
| 1330 |
i) Disposal Method - The mode Restore To Previous is intended to be |
| 1331 |
used in small sections of the graphic; the use of this mode imposes |
| 1332 |
severe demands on the decoder to store the section of the graphic |
| 1333 |
that needs to be saved. For this reason, this mode should be used |
| 1334 |
sparingly. This mode is not intended to save an entire graphic or |
| 1335 |
large areas of a graphic; when this is the case, the encoder should |
| 1336 |
make every attempt to make the sections of the graphic to be |
| 1337 |
restored be separate graphics in the data stream. In the case where |
| 1338 |
a decoder is not capable of saving an area of a graphic marked as |
| 1339 |
Restore To Previous, it is recommended that a decoder restore to |
| 1340 |
the background color. |
| 1341 |
|
| 1342 |
ii) User Input Flag - When the flag is set, indicating that user |
| 1343 |
input is expected, the decoder may sound the bell (0x07) to alert |
| 1344 |
the user that input is being expected. In the absence of a |
| 1345 |
specified Delay Time, the decoder should wait for user input |
| 1346 |
indefinitely. It is recommended that the encoder not set the User |
| 1347 |
Input Flag without a Delay Time specified. |
| 1348 |
|
| 1349 |
|
| 1350 |
24. Comment Extension. |
| 1351 |
|
| 1352 |
a. Description. The Comment Extension contains textual information which |
| 1353 |
is not part of the actual graphics in the GIF Data Stream. It is suitable |
| 1354 |
for including comments about the graphics, credits, descriptions or any |
| 1355 |
other type of non-control and non-graphic data. The Comment Extension |
| 1356 |
may be ignored by the decoder, or it may be saved for later processing; |
| 1357 |
under no circumstances should a Comment Extension disrupt or interfere |
| 1358 |
with the processing of the Data Stream. |
| 1359 |
|
| 1360 |
This block is OPTIONAL; any number of them may appear in the Data Stream. |
| 1361 |
|
| 1362 |
b. Required Version. 89a. |
| 1363 |
|
| 1364 |
|
| 1365 |
|
| 1366 |
|
| 1367 |
|
| 1368 |
|
| 1369 |
|
| 1370 |
|
| 1371 |
|
| 1372 |
|
| 1373 |
|
| 1374 |
|
| 1375 |
|
| 1376 |
|
| 1377 |
|
| 1378 |
|
| 1379 |
|
| 1380 |
|
| 1381 |
|
| 1382 |
|
| 1383 |
|
| 1384 |
|
| 1385 |
18 |
| 1386 |
|
| 1387 |
|
| 1388 |
c. Syntax. |
| 1389 |
|
| 1390 |
7 6 5 4 3 2 1 0 Field Name Type |
| 1391 |
+---------------+ |
| 1392 |
0 | | Extension Introducer Byte |
| 1393 |
+---------------+ |
| 1394 |
1 | | Comment Label Byte |
| 1395 |
+---------------+ |
| 1396 |
|
| 1397 |
+===============+ |
| 1398 |
| | |
| 1399 |
N | | Comment Data Data Sub-blocks |
| 1400 |
| | |
| 1401 |
+===============+ |
| 1402 |
|
| 1403 |
+---------------+ |
| 1404 |
0 | | Block Terminator Byte |
| 1405 |
+---------------+ |
| 1406 |
|
| 1407 |
i) Extension Introducer - Identifies the beginning of an extension |
| 1408 |
block. This field contains the fixed value 0x21. |
| 1409 |
|
| 1410 |
ii) Comment Label - Identifies the block as a Comment Extension. |
| 1411 |
This field contains the fixed value 0xFE. |
| 1412 |
|
| 1413 |
iii) Comment Data - Sequence of sub-blocks, each of size at most |
| 1414 |
255 bytes and at least 1 byte, with the size in a byte preceding |
| 1415 |
the data. The end of the sequence is marked by the Block |
| 1416 |
Terminator. |
| 1417 |
|
| 1418 |
iv) Block Terminator - This zero-length data block marks the end of |
| 1419 |
the Comment Extension. |
| 1420 |
|
| 1421 |
d. Extensions and Scope. This block does not have scope. This block |
| 1422 |
cannot be modified by any extension. |
| 1423 |
|
| 1424 |
e. Recommendations. |
| 1425 |
|
| 1426 |
i) Data - This block is intended for humans. It should contain |
| 1427 |
text using the 7-bit ASCII character set. This block should |
| 1428 |
not be used to store control information for custom processing. |
| 1429 |
|
| 1430 |
ii) Position - This block may appear at any point in the Data |
| 1431 |
Stream at which a block can begin; however, it is recommended that |
| 1432 |
Comment Extensions do not interfere with Control or Data blocks; |
| 1433 |
they should be located at the beginning or at the end of the Data |
| 1434 |
Stream to the extent possible. |
| 1435 |
|
| 1436 |
|
| 1437 |
25. Plain Text Extension. |
| 1438 |
|
| 1439 |
a. Description. The Plain Text Extension contains textual data and the |
| 1440 |
parameters necessary to render that data as a graphic, in a simple form. |
| 1441 |
The textual data will be encoded with the 7-bit printable ASCII |
| 1442 |
characters. Text data are rendered using a grid of character cells |
| 1443 |
|
| 1444 |
|
| 1445 |
|
| 1446 |
|
| 1447 |
|
| 1448 |
|
| 1449 |
|
| 1450 |
|
| 1451 |
19 |
| 1452 |
|
| 1453 |
|
| 1454 |
defined by the parameters in the block fields. Each character is rendered |
| 1455 |
in an individual cell. The textual data in this block is to be rendered |
| 1456 |
as mono-spaced characters, one character per cell, with a best fitting |
| 1457 |
font and size. For further information, see the section on |
| 1458 |
Recommendations below. The data characters are taken sequentially from |
| 1459 |
the data portion of the block and rendered within a cell, starting with |
| 1460 |
the upper left cell in the grid and proceeding from left to right and |
| 1461 |
from top to bottom. Text data is rendered until the end of data is |
| 1462 |
reached or the character grid is filled. The Character Grid contains an |
| 1463 |
integral number of cells; in the case that the cell dimensions do not |
| 1464 |
allow for an integral number, fractional cells must be discarded; an |
| 1465 |
encoder must be careful to specify the grid dimensions accurately so that |
| 1466 |
this does not happen. This block requires a Global Color Table to be |
| 1467 |
available; the colors used by this block reference the Global Color Table |
| 1468 |
in the Stream if there is one, or the Global Color Table from a previous |
| 1469 |
Stream, if one was saved. This block is a graphic rendering block, |
| 1470 |
therefore it may be modified by a Graphic Control Extension. This block |
| 1471 |
is OPTIONAL; any number of them may appear in the Data Stream. |
| 1472 |
|
| 1473 |
b. Required Version. 89a. |
| 1474 |
|
| 1475 |
|
| 1476 |
|
| 1477 |
|
| 1478 |
|
| 1479 |
|
| 1480 |
|
| 1481 |
|
| 1482 |
|
| 1483 |
|
| 1484 |
|
| 1485 |
|
| 1486 |
|
| 1487 |
|
| 1488 |
|
| 1489 |
|
| 1490 |
|
| 1491 |
|
| 1492 |
|
| 1493 |
|
| 1494 |
|
| 1495 |
|
| 1496 |
|
| 1497 |
|
| 1498 |
|
| 1499 |
|
| 1500 |
|
| 1501 |
|
| 1502 |
|
| 1503 |
|
| 1504 |
|
| 1505 |
|
| 1506 |
|
| 1507 |
|
| 1508 |
|
| 1509 |
|
| 1510 |
|
| 1511 |
|
| 1512 |
|
| 1513 |
|
| 1514 |
|
| 1515 |
|
| 1516 |
|
| 1517 |
20 |
| 1518 |
|
| 1519 |
|
| 1520 |
c. Syntax. |
| 1521 |
|
| 1522 |
7 6 5 4 3 2 1 0 Field Name Type |
| 1523 |
+---------------+ |
| 1524 |
0 | | Extension Introducer Byte |
| 1525 |
+---------------+ |
| 1526 |
1 | | Plain Text Label Byte |
| 1527 |
+---------------+ |
| 1528 |
|
| 1529 |
+---------------+ |
| 1530 |
0 | | Block Size Byte |
| 1531 |
+---------------+ |
| 1532 |
1 | | Text Grid Left Position Unsigned |
| 1533 |
+- -+ |
| 1534 |
2 | | |
| 1535 |
+---------------+ |
| 1536 |
3 | | Text Grid Top Position Unsigned |
| 1537 |
+- -+ |
| 1538 |
4 | | |
| 1539 |
+---------------+ |
| 1540 |
5 | | Text Grid Width Unsigned |
| 1541 |
+- -+ |
| 1542 |
6 | | |
| 1543 |
+---------------+ |
| 1544 |
7 | | Text Grid Height Unsigned |
| 1545 |
+- -+ |
| 1546 |
8 | | |
| 1547 |
+---------------+ |
| 1548 |
9 | | Character Cell Width Byte |
| 1549 |
+---------------+ |
| 1550 |
10 | | Character Cell Height Byte |
| 1551 |
+---------------+ |
| 1552 |
11 | | Text Foreground Color Index Byte |
| 1553 |
+---------------+ |
| 1554 |
12 | | Text Background Color Index Byte |
| 1555 |
+---------------+ |
| 1556 |
|
| 1557 |
+===============+ |
| 1558 |
| | |
| 1559 |
N | | Plain Text Data Data Sub-blocks |
| 1560 |
| | |
| 1561 |
+===============+ |
| 1562 |
|
| 1563 |
+---------------+ |
| 1564 |
0 | | Block Terminator Byte |
| 1565 |
+---------------+ |
| 1566 |
|
| 1567 |
i) Extension Introducer - Identifies the beginning of an extension |
| 1568 |
block. This field contains the fixed value 0x21. |
| 1569 |
|
| 1570 |
ii) Plain Text Label - Identifies the current block as a Plain Text |
| 1571 |
Extension. This field contains the fixed value 0x01. |
| 1572 |
|
| 1573 |
iii) Block Size - Number of bytes in the extension, after the Block |
| 1574 |
Size field and up to but not including the beginning of the data |
| 1575 |
portion. This field contains the fixed value 12. |
| 1576 |
|
| 1577 |
|
| 1578 |
|
| 1579 |
|
| 1580 |
|
| 1581 |
|
| 1582 |
|
| 1583 |
21 |
| 1584 |
|
| 1585 |
|
| 1586 |
iv) Text Grid Left Position - Column number, in pixels, of the left |
| 1587 |
edge of the text grid, with respect to the left edge of the Logical |
| 1588 |
Screen. |
| 1589 |
|
| 1590 |
v) Text Grid Top Position - Row number, in pixels, of the top edge |
| 1591 |
of the text grid, with respect to the top edge of the Logical |
| 1592 |
Screen. |
| 1593 |
|
| 1594 |
vi) Image Grid Width - Width of the text grid in pixels. |
| 1595 |
|
| 1596 |
vii) Image Grid Height - Height of the text grid in pixels. |
| 1597 |
|
| 1598 |
viii) Character Cell Width - Width, in pixels, of each cell in the |
| 1599 |
grid. |
| 1600 |
|
| 1601 |
ix) Character Cell Height - Height, in pixels, of each cell in the |
| 1602 |
grid. |
| 1603 |
|
| 1604 |
x) Text Foreground Color Index - Index into the Global Color Table |
| 1605 |
to be used to render the text foreground. |
| 1606 |
|
| 1607 |
xi) Text Background Color Index - Index into the Global Color Table |
| 1608 |
to be used to render the text background. |
| 1609 |
|
| 1610 |
xii) Plain Text Data - Sequence of sub-blocks, each of size at most |
| 1611 |
255 bytes and at least 1 byte, with the size in a byte preceding |
| 1612 |
the data. The end of the sequence is marked by the Block |
| 1613 |
Terminator. |
| 1614 |
|
| 1615 |
xiii) Block Terminator - This zero-length data block marks the end |
| 1616 |
of the Plain Text Data Blocks. |
| 1617 |
|
| 1618 |
d. Extensions and Scope. The scope of this block is the Plain Text Data |
| 1619 |
Block contained in it. This block may be modified by the Graphic Control |
| 1620 |
Extension. |
| 1621 |
|
| 1622 |
e. Recommendations. The data in the Plain Text Extension is assumed to be |
| 1623 |
preformatted. The selection of font and size is left to the discretion of |
| 1624 |
the decoder. If characters less than 0x20 or greater than 0xf7 are |
| 1625 |
encountered, it is recommended that the decoder display a Space character |
| 1626 |
(0x20). The encoder should use grid and cell dimensions such that an |
| 1627 |
integral number of cells fit in the grid both horizontally as well as |
| 1628 |
vertically. For broadest compatibility, character cell dimensions should |
| 1629 |
be around 8x8 or 8x16 (width x height); consider an image for unusual |
| 1630 |
sized text. |
| 1631 |
|
| 1632 |
|
| 1633 |
26. Application Extension. |
| 1634 |
|
| 1635 |
a. Description. The Application Extension contains application-specific |
| 1636 |
information; it conforms with the extension block syntax, as described |
| 1637 |
below, and its block label is 0xFF. |
| 1638 |
|
| 1639 |
b. Required Version. 89a. |
| 1640 |
|
| 1641 |
|
| 1642 |
|
| 1643 |
|
| 1644 |
|
| 1645 |
|
| 1646 |
|
| 1647 |
|
| 1648 |
|
| 1649 |
22 |
| 1650 |
|
| 1651 |
|
| 1652 |
c. Syntax. |
| 1653 |
|
| 1654 |
7 6 5 4 3 2 1 0 Field Name Type |
| 1655 |
+---------------+ |
| 1656 |
0 | | Extension Introducer Byte |
| 1657 |
+---------------+ |
| 1658 |
1 | | Extension Label Byte |
| 1659 |
+---------------+ |
| 1660 |
|
| 1661 |
+---------------+ |
| 1662 |
0 | | Block Size Byte |
| 1663 |
+---------------+ |
| 1664 |
1 | | |
| 1665 |
+- -+ |
| 1666 |
2 | | |
| 1667 |
+- -+ |
| 1668 |
3 | | Application Identifier 8 Bytes |
| 1669 |
+- -+ |
| 1670 |
4 | | |
| 1671 |
+- -+ |
| 1672 |
5 | | |
| 1673 |
+- -+ |
| 1674 |
6 | | |
| 1675 |
+- -+ |
| 1676 |
7 | | |
| 1677 |
+- -+ |
| 1678 |
8 | | |
| 1679 |
+---------------+ |
| 1680 |
9 | | |
| 1681 |
+- -+ |
| 1682 |
10 | | Appl. Authentication Code 3 Bytes |
| 1683 |
+- -+ |
| 1684 |
11 | | |
| 1685 |
+---------------+ |
| 1686 |
|
| 1687 |
+===============+ |
| 1688 |
| | |
| 1689 |
| | Application Data Data Sub-blocks |
| 1690 |
| | |
| 1691 |
| | |
| 1692 |
+===============+ |
| 1693 |
|
| 1694 |
+---------------+ |
| 1695 |
0 | | Block Terminator Byte |
| 1696 |
+---------------+ |
| 1697 |
|
| 1698 |
i) Extension Introducer - Defines this block as an extension. This |
| 1699 |
field contains the fixed value 0x21. |
| 1700 |
|
| 1701 |
ii) Application Extension Label - Identifies the block as an |
| 1702 |
Application Extension. This field contains the fixed value 0xFF. |
| 1703 |
|
| 1704 |
iii) Block Size - Number of bytes in this extension block, |
| 1705 |
following the Block Size field, up to but not including the |
| 1706 |
beginning of the Application Data. This field contains the fixed |
| 1707 |
value 11. |
| 1708 |
|
| 1709 |
|
| 1710 |
|
| 1711 |
|
| 1712 |
|
| 1713 |
|
| 1714 |
|
| 1715 |
23 |
| 1716 |
|
| 1717 |
|
| 1718 |
iv) Application Identifier - Sequence of eight printable ASCII |
| 1719 |
characters used to identify the application owning the Application |
| 1720 |
Extension. |
| 1721 |
|
| 1722 |
v) Application Authentication Code - Sequence of three bytes used |
| 1723 |
to authenticate the Application Identifier. An Application program |
| 1724 |
may use an algorithm to compute a binary code that uniquely |
| 1725 |
identifies it as the application owning the Application Extension. |
| 1726 |
|
| 1727 |
|
| 1728 |
d. Extensions and Scope. This block does not have scope. This block |
| 1729 |
cannot be modified by any extension. |
| 1730 |
|
| 1731 |
e. Recommendation. None. |
| 1732 |
|
| 1733 |
|
| 1734 |
27. Trailer. |
| 1735 |
|
| 1736 |
a. Description. This block is a single-field block indicating the end of |
| 1737 |
the GIF Data Stream. It contains the fixed value 0x3B. |
| 1738 |
|
| 1739 |
b. Required Version. 87a. |
| 1740 |
|
| 1741 |
c. Syntax. |
| 1742 |
|
| 1743 |
7 6 5 4 3 2 1 0 Field Name Type |
| 1744 |
+---------------+ |
| 1745 |
0 | | GIF Trailer Byte |
| 1746 |
+---------------+ |
| 1747 |
|
| 1748 |
d. Extensions and Scope. This block does not have scope, it terminates |
| 1749 |
the GIF Data Stream. This block may not be modified by any extension. |
| 1750 |
|
| 1751 |
e. Recommendations. None. |
| 1752 |
|
| 1753 |
|
| 1754 |
|
| 1755 |
|
| 1756 |
|
| 1757 |
|
| 1758 |
|
| 1759 |
|
| 1760 |
|
| 1761 |
|
| 1762 |
|
| 1763 |
|
| 1764 |
|
| 1765 |
|
| 1766 |
|
| 1767 |
|
| 1768 |
|
| 1769 |
|
| 1770 |
|
| 1771 |
|
| 1772 |
|
| 1773 |
|
| 1774 |
|
| 1775 |
|
| 1776 |
|
| 1777 |
|
| 1778 |
|
| 1779 |
|
| 1780 |
|
| 1781 |
24 |
| 1782 |
|
| 1783 |
|
| 1784 |
Appendix |
| 1785 |
A. Quick Reference Table. |
| 1786 |
|
| 1787 |
Block Name Required Label Ext. Vers. |
| 1788 |
Application Extension Opt. (*) 0xFF (255) yes 89a |
| 1789 |
Comment Extension Opt. (*) 0xFE (254) yes 89a |
| 1790 |
Global Color Table Opt. (1) none no 87a |
| 1791 |
Graphic Control Extension Opt. (*) 0xF9 (249) yes 89a |
| 1792 |
Header Req. (1) none no N/A |
| 1793 |
Image Descriptor Opt. (*) 0x2C (044) no 87a (89a) |
| 1794 |
Local Color Table Opt. (*) none no 87a |
| 1795 |
Logical Screen Descriptor Req. (1) none no 87a (89a) |
| 1796 |
Plain Text Extension Opt. (*) 0x01 (001) yes 89a |
| 1797 |
Trailer Req. (1) 0x3B (059) no 87a |
| 1798 |
|
| 1799 |
Unlabeled Blocks |
| 1800 |
Header Req. (1) none no N/A |
| 1801 |
Logical Screen Descriptor Req. (1) none no 87a (89a) |
| 1802 |
Global Color Table Opt. (1) none no 87a |
| 1803 |
Local Color Table Opt. (*) none no 87a |
| 1804 |
|
| 1805 |
Graphic-Rendering Blocks |
| 1806 |
Plain Text Extension Opt. (*) 0x01 (001) yes 89a |
| 1807 |
Image Descriptor Opt. (*) 0x2C (044) no 87a (89a) |
| 1808 |
|
| 1809 |
Control Blocks |
| 1810 |
Graphic Control Extension Opt. (*) 0xF9 (249) yes 89a |
| 1811 |
|
| 1812 |
Special Purpose Blocks |
| 1813 |
Trailer Req. (1) 0x3B (059) no 87a |
| 1814 |
Comment Extension Opt. (*) 0xFE (254) yes 89a |
| 1815 |
Application Extension Opt. (*) 0xFF (255) yes 89a |
| 1816 |
|
| 1817 |
legend: (1) if present, at most one occurrence |
| 1818 |
(*) zero or more occurrences |
| 1819 |
(+) one or more occurrences |
| 1820 |
|
| 1821 |
Notes : The Header is not subject to Version Numbers. |
| 1822 |
(89a) The Logical Screen Descriptor and the Image Descriptor retained their |
| 1823 |
syntax from version 87a to version 89a, but some fields reserved under version |
| 1824 |
87a are used under version 89a. |
| 1825 |
|
| 1826 |
|
| 1827 |
|
| 1828 |
|
| 1829 |
|
| 1830 |
|
| 1831 |
|
| 1832 |
|
| 1833 |
|
| 1834 |
|
| 1835 |
|
| 1836 |
|
| 1837 |
|
| 1838 |
|
| 1839 |
|
| 1840 |
|
| 1841 |
|
| 1842 |
|
| 1843 |
|
| 1844 |
|
| 1845 |
|
| 1846 |
|
| 1847 |
25 |
| 1848 |
|
| 1849 |
|
| 1850 |
Appendix |
| 1851 |
B. GIF Grammar. |
| 1852 |
|
| 1853 |
A Grammar is a form of notation to represent the sequence in which certain |
| 1854 |
objects form larger objects. A grammar is also used to represent the number of |
| 1855 |
objects that can occur at a given position. The grammar given here represents |
| 1856 |
the sequence of blocks that form the GIF Data Stream. A grammar is given by |
| 1857 |
listing its rules. Each rule consists of the left-hand side, followed by some |
| 1858 |
form of equals sign, followed by the right-hand side. In a rule, the |
| 1859 |
right-hand side describes how the left-hand side is defined. The right-hand |
| 1860 |
side consists of a sequence of entities, with the possible presence of special |
| 1861 |
symbols. The following legend defines the symbols used in this grammar for GIF. |
| 1862 |
|
| 1863 |
Legend: <> grammar word |
| 1864 |
::= defines symbol |
| 1865 |
* zero or more occurrences |
| 1866 |
+ one or more occurrences |
| 1867 |
| alternate element |
| 1868 |
[] optional element |
| 1869 |
|
| 1870 |
Example: |
| 1871 |
|
| 1872 |
<GIF Data Stream> ::= Header <Logical Screen> <Data>* Trailer |
| 1873 |
|
| 1874 |
This rule defines the entity <GIF Data Stream> as follows. It must begin with a |
| 1875 |
Header. The Header is followed by an entity called Logical Screen, which is |
| 1876 |
defined below by another rule. The Logical Screen is followed by the entity |
| 1877 |
Data, which is also defined below by another rule. Finally, the entity Data is |
| 1878 |
followed by the Trailer. Since there is no rule defining the Header or the |
| 1879 |
Trailer, this means that these blocks are defined in the document. The entity |
| 1880 |
Data has a special symbol (*) following it which means that, at this position, |
| 1881 |
the entity Data may be repeated any number of times, including 0 times. For |
| 1882 |
further reading on this subject, refer to a standard text on Programming |
| 1883 |
Languages. |
| 1884 |
|
| 1885 |
|
| 1886 |
The Grammar. |
| 1887 |
|
| 1888 |
<GIF Data Stream> ::= Header <Logical Screen> <Data>* Trailer |
| 1889 |
|
| 1890 |
<Logical Screen> ::= Logical Screen Descriptor [Global Color Table] |
| 1891 |
|
| 1892 |
<Data> ::= <Graphic Block> | |
| 1893 |
<Special-Purpose Block> |
| 1894 |
|
| 1895 |
<Graphic Block> ::= [Graphic Control Extension] <Graphic-Rendering Block> |
| 1896 |
|
| 1897 |
<Graphic-Rendering Block> ::= <Table-Based Image> | |
| 1898 |
Plain Text Extension |
| 1899 |
|
| 1900 |
<Table-Based Image> ::= Image Descriptor [Local Color Table] Image Data |
| 1901 |
|
| 1902 |
<Special-Purpose Block> ::= Application Extension | |
| 1903 |
Comment Extension |
| 1904 |
|
| 1905 |
|
| 1906 |
|
| 1907 |
|
| 1908 |
|
| 1909 |
|
| 1910 |
|
| 1911 |
|
| 1912 |
|
| 1913 |
26 |
| 1914 |
|
| 1915 |
|
| 1916 |
NOTE : The grammar indicates that it is possible for a GIF Data Stream to |
| 1917 |
contain the Header, the Logical Screen Descriptor, a Global Color Table and the |
| 1918 |
GIF Trailer. This special case is used to load a GIF decoder with a Global |
| 1919 |
Color Table, in preparation for subsequent Data Streams without color tables at |
| 1920 |
all. |
| 1921 |
|
| 1922 |
|
| 1923 |
|
| 1924 |
|
| 1925 |
|
| 1926 |
|
| 1927 |
|
| 1928 |
|
| 1929 |
|
| 1930 |
|
| 1931 |
|
| 1932 |
|
| 1933 |
|
| 1934 |
|
| 1935 |
|
| 1936 |
|
| 1937 |
|
| 1938 |
|
| 1939 |
|
| 1940 |
|
| 1941 |
|
| 1942 |
|
| 1943 |
|
| 1944 |
|
| 1945 |
|
| 1946 |
|
| 1947 |
|
| 1948 |
|
| 1949 |
|
| 1950 |
|
| 1951 |
|
| 1952 |
|
| 1953 |
|
| 1954 |
|
| 1955 |
|
| 1956 |
|
| 1957 |
|
| 1958 |
|
| 1959 |
|
| 1960 |
|
| 1961 |
|
| 1962 |
|
| 1963 |
|
| 1964 |
|
| 1965 |
|
| 1966 |
|
| 1967 |
|
| 1968 |
|
| 1969 |
|
| 1970 |
|
| 1971 |
|
| 1972 |
|
| 1973 |
|
| 1974 |
|
| 1975 |
|
| 1976 |
|
| 1977 |
|
| 1978 |
|
| 1979 |
27 |
| 1980 |
|
| 1981 |
|
| 1982 |
Appendix |
| 1983 |
C. Glossary. |
| 1984 |
|
| 1985 |
Active Color Table - Color table used to render the next graphic. If the next |
| 1986 |
graphic is an image which has a Local Color Table associated with it, the |
| 1987 |
active color table becomes the Local Color Table associated with that image. |
| 1988 |
If the next graphic is an image without a Local Color Table, or a Plain Text |
| 1989 |
Extension, the active color table is the Global Color Table associated with the |
| 1990 |
Data Stream, if there is one; if there is no Global Color Table in the Data |
| 1991 |
Stream, the active color table is a color table saved from a previous Data |
| 1992 |
Stream, or one supplied by the decoder. |
| 1993 |
|
| 1994 |
Block - Collection of bytes forming a protocol unit. In general, the term |
| 1995 |
includes labeled and unlabeled blocks, as well as Extensions. |
| 1996 |
|
| 1997 |
Data Stream - The GIF Data Stream is composed of blocks and sub-blocks |
| 1998 |
representing images and graphics, together with control information to render |
| 1999 |
them on a display device. All control and data blocks in the Data Stream must |
| 2000 |
follow the Header and must precede the Trailer. |
| 2001 |
|
| 2002 |
Decoder - A program capable of processing a GIF Data Stream to render the |
| 2003 |
images and graphics contained in it. |
| 2004 |
|
| 2005 |
Encoder - A program capable of capturing and formatting image and graphic |
| 2006 |
raster data, following the definitions of the Graphics Interchange Format. |
| 2007 |
|
| 2008 |
Extension - A protocol block labeled by the Extension Introducer 0x21. |
| 2009 |
|
| 2010 |
Extension Introducer - Label (0x21) defining an Extension. |
| 2011 |
|
| 2012 |
Graphic - Data which can be rendered on the screen by virtue of some algorithm. |
| 2013 |
The term graphic is more general than the term image; in addition to images, |
| 2014 |
the term graphic also includes data such as text, which is rendered using |
| 2015 |
character bit-maps. |
| 2016 |
|
| 2017 |
Image - Data representing a picture or a drawing; an image is represented by an |
| 2018 |
array of pixels called the raster of the image. |
| 2019 |
|
| 2020 |
Raster - Array of pixel values representing an image. |
| 2021 |
|
| 2022 |
|
| 2023 |
|
| 2024 |
|
| 2025 |
|
| 2026 |
|
| 2027 |
|
| 2028 |
|
| 2029 |
|
| 2030 |
|
| 2031 |
|
| 2032 |
|
| 2033 |
|
| 2034 |
|
| 2035 |
|
| 2036 |
|
| 2037 |
|
| 2038 |
|
| 2039 |
|
| 2040 |
|
| 2041 |
|
| 2042 |
|
| 2043 |
|
| 2044 |
|
| 2045 |
28 |
| 2046 |
|
| 2047 |
|
| 2048 |
Appendix |
| 2049 |
D. Conventions. |
| 2050 |
|
| 2051 |
Animation - The Graphics Interchange Format is not intended as a platform for |
| 2052 |
animation, even though it can be done in a limited way. |
| 2053 |
|
| 2054 |
Byte Ordering - Unless otherwise stated, multi-byte numeric fields are ordered |
| 2055 |
with the Least Significant Byte first. |
| 2056 |
|
| 2057 |
Color Indices - Color indices always refer to the active color table, either |
| 2058 |
the Global Color Table or the Local Color Table. |
| 2059 |
|
| 2060 |
Color Order - Unless otherwise stated, all triple-component RGB color values |
| 2061 |
are specified in Red-Green-Blue order. |
| 2062 |
|
| 2063 |
Color Tables - Both color tables, the Global and the Local, are optional; if |
| 2064 |
present, the Global Color Table is to be used with every image in the Data |
| 2065 |
Stream for which a Local Color Table is not given; if present, a Local Color |
| 2066 |
Table overrides the Global Color Table. However, if neither color table is |
| 2067 |
present, the application program is free to use an arbitrary color table. If |
| 2068 |
the graphics in several Data Streams are related and all use the same color |
| 2069 |
table, an encoder could place the color table as the Global Color Table in the |
| 2070 |
first Data Stream and leave subsequent Data Streams without a Global Color |
| 2071 |
Table or any Local Color Tables; in this way, the overhead for the table is |
| 2072 |
eliminated. It is recommended that the decoder save the previous Global Color |
| 2073 |
Table to be used with the Data Stream that follows, in case it does not contain |
| 2074 |
either a Global Color Table or any Local Color Tables. In general, this allows |
| 2075 |
the application program to use past color tables, significantly reducing |
| 2076 |
transmission overhead. |
| 2077 |
|
| 2078 |
Extension Blocks - Extensions are defined using the Extension Introducer code |
| 2079 |
to mark the beginning of the block, followed by a block label, identifying the |
| 2080 |
type of extension. Extension Codes are numbers in the range from 0x00 to 0xFF, |
| 2081 |
inclusive. Special purpose extensions are transparent to the decoder and may be |
| 2082 |
omitted when transmitting the Data Stream on-line. The GIF capabilities |
| 2083 |
dialogue makes the provision for the receiver to request the transmission of |
| 2084 |
all blocks; the default state in this regard is no transmission of Special |
| 2085 |
purpose blocks. |
| 2086 |
|
| 2087 |
Reserved Fields - All Reserved Fields are expected to have each bit set to zero |
| 2088 |
(off). |
| 2089 |
|
| 2090 |
|
| 2091 |
|
| 2092 |
|
| 2093 |
|
| 2094 |
|
| 2095 |
|
| 2096 |
|
| 2097 |
|
| 2098 |
|
| 2099 |
|
| 2100 |
|
| 2101 |
|
| 2102 |
|
| 2103 |
|
| 2104 |
|
| 2105 |
|
| 2106 |
|
| 2107 |
|
| 2108 |
|
| 2109 |
|
| 2110 |
|
| 2111 |
29 |
| 2112 |
|
| 2113 |
|
| 2114 |
Appendix |
| 2115 |
E. Interlaced Images. |
| 2116 |
|
| 2117 |
The rows of an Interlaced images are arranged in the following order: |
| 2118 |
|
| 2119 |
Group 1 : Every 8th. row, starting with row 0. (Pass 1) |
| 2120 |
Group 2 : Every 8th. row, starting with row 4. (Pass 2) |
| 2121 |
Group 3 : Every 4th. row, starting with row 2. (Pass 3) |
| 2122 |
Group 4 : Every 2nd. row, starting with row 1. (Pass 4) |
| 2123 |
|
| 2124 |
The Following example illustrates how the rows of an interlaced image are |
| 2125 |
ordered. |
| 2126 |
|
| 2127 |
Row Number Interlace Pass |
| 2128 |
|
| 2129 |
0 ----------------------------------------- 1 |
| 2130 |
1 ----------------------------------------- 4 |
| 2131 |
2 ----------------------------------------- 3 |
| 2132 |
3 ----------------------------------------- 4 |
| 2133 |
4 ----------------------------------------- 2 |
| 2134 |
5 ----------------------------------------- 4 |
| 2135 |
6 ----------------------------------------- 3 |
| 2136 |
7 ----------------------------------------- 4 |
| 2137 |
8 ----------------------------------------- 1 |
| 2138 |
9 ----------------------------------------- 4 |
| 2139 |
10 ----------------------------------------- 3 |
| 2140 |
11 ----------------------------------------- 4 |
| 2141 |
12 ----------------------------------------- 2 |
| 2142 |
13 ----------------------------------------- 4 |
| 2143 |
14 ----------------------------------------- 3 |
| 2144 |
15 ----------------------------------------- 4 |
| 2145 |
16 ----------------------------------------- 1 |
| 2146 |
17 ----------------------------------------- 4 |
| 2147 |
18 ----------------------------------------- 3 |
| 2148 |
19 ----------------------------------------- 4 |
| 2149 |
|
| 2150 |
|
| 2151 |
|
| 2152 |
|
| 2153 |
|
| 2154 |
|
| 2155 |
|
| 2156 |
|
| 2157 |
|
| 2158 |
|
| 2159 |
|
| 2160 |
|
| 2161 |
|
| 2162 |
|
| 2163 |
|
| 2164 |
|
| 2165 |
|
| 2166 |
|
| 2167 |
|
| 2168 |
|
| 2169 |
|
| 2170 |
|
| 2171 |
|
| 2172 |
|
| 2173 |
|
| 2174 |
|
| 2175 |
|
| 2176 |
|
| 2177 |
30 |
| 2178 |
|
| 2179 |
|
| 2180 |
Appendix |
| 2181 |
F. Variable-Length-Code LZW Compression. |
| 2182 |
|
| 2183 |
The Variable-Length-Code LZW Compression is a variation of the Lempel-Ziv |
| 2184 |
Compression algorithm in which variable-length codes are used to replace |
| 2185 |
patterns detected in the original data. The algorithm uses a code or |
| 2186 |
translation table constructed from the patterns encountered in the original |
| 2187 |
data; each new pattern is entered into the table and its index is used to |
| 2188 |
replace it in the compressed stream. |
| 2189 |
|
| 2190 |
The compressor takes the data from the input stream and builds a code or |
| 2191 |
translation table with the patterns as it encounters them; each new pattern is |
| 2192 |
entered into the code table and its index is added to the output stream; when a |
| 2193 |
pattern is encountered which had been detected since the last code table |
| 2194 |
refresh, its index from the code table is put on the output stream, thus |
| 2195 |
achieving the data compression. The expander takes input from the compressed |
| 2196 |
data stream and builds the code or translation table from it; as the compressed |
| 2197 |
data stream is processed, codes are used to index into the code table and the |
| 2198 |
corresponding data is put on the decompressed output stream, thus achieving |
| 2199 |
data decompression. The details of the algorithm are explained below. The |
| 2200 |
Variable-Length-Code aspect of the algorithm is based on an initial code size |
| 2201 |
(LZW-initial code size), which specifies the initial number of bits used for |
| 2202 |
the compression codes. When the number of patterns detected by the compressor |
| 2203 |
in the input stream exceeds the number of patterns encodable with the current |
| 2204 |
number of bits, the number of bits per LZW code is increased by one. |
| 2205 |
|
| 2206 |
The Raster Data stream that represents the actual output image can be |
| 2207 |
represented as: |
| 2208 |
|
| 2209 |
7 6 5 4 3 2 1 0 |
| 2210 |
+---------------+ |
| 2211 |
| LZW code size | |
| 2212 |
+---------------+ |
| 2213 |
|
| 2214 |
+---------------+ ----+ |
| 2215 |
| block size | | |
| 2216 |
+---------------+ | |
| 2217 |
| | +-- Repeated as many |
| 2218 |
| data bytes | | times as necessary. |
| 2219 |
| | | |
| 2220 |
+---------------+ ----+ |
| 2221 |
|
| 2222 |
. . . . . . ------- The code that terminates the LZW |
| 2223 |
compressed data must appear before |
| 2224 |
Block Terminator. |
| 2225 |
+---------------+ |
| 2226 |
|0 0 0 0 0 0 0 0| Block Terminator |
| 2227 |
+---------------+ |
| 2228 |
|
| 2229 |
The conversion of the image from a series of pixel values to a transmitted or |
| 2230 |
stored character stream involves several steps. In brief these steps are: |
| 2231 |
|
| 2232 |
1. Establish the Code Size - Define the number of bits needed to represent the |
| 2233 |
actual data. |
| 2234 |
|
| 2235 |
2. Compress the Data - Compress the series of image pixels to a series of |
| 2236 |
|
| 2237 |
|
| 2238 |
|
| 2239 |
|
| 2240 |
|
| 2241 |
|
| 2242 |
|
| 2243 |
31 |
| 2244 |
|
| 2245 |
|
| 2246 |
compression codes. |
| 2247 |
|
| 2248 |
3. Build a Series of Bytes - Take the set of compression codes and convert to a |
| 2249 |
string of 8-bit bytes. |
| 2250 |
|
| 2251 |
4. Package the Bytes - Package sets of bytes into blocks preceded by character |
| 2252 |
counts and output. |
| 2253 |
|
| 2254 |
ESTABLISH CODE SIZE |
| 2255 |
|
| 2256 |
The first byte of the Compressed Data stream is a value indicating the minimum |
| 2257 |
number of bits required to represent the set of actual pixel values. Normally |
| 2258 |
this will be the same as the number of color bits. Because of some algorithmic |
| 2259 |
constraints however, black & white images which have one color bit must be |
| 2260 |
indicated as having a code size of 2. |
| 2261 |
This code size value also implies that the compression codes must start out one |
| 2262 |
bit longer. |
| 2263 |
|
| 2264 |
COMPRESSION |
| 2265 |
|
| 2266 |
The LZW algorithm converts a series of data values into a series of codes which |
| 2267 |
may be raw values or a code designating a series of values. Using text |
| 2268 |
characters as an analogy, the output code consists of a character or a code |
| 2269 |
representing a string of characters. |
| 2270 |
|
| 2271 |
The LZW algorithm used in GIF matches algorithmically with the standard LZW |
| 2272 |
algorithm with the following differences: |
| 2273 |
|
| 2274 |
1. A special Clear code is defined which resets all compression/decompression |
| 2275 |
parameters and tables to a start-up state. The value of this code is 2**<code |
| 2276 |
size>. For example if the code size indicated was 4 (image was 4 bits/pixel) |
| 2277 |
the Clear code value would be 16 (10000 binary). The Clear code can appear at |
| 2278 |
any point in the image data stream and therefore requires the LZW algorithm to |
| 2279 |
process succeeding codes as if a new data stream was starting. Encoders should |
| 2280 |
output a Clear code as the first code of each image data stream. |
| 2281 |
|
| 2282 |
2. An End of Information code is defined that explicitly indicates the end of |
| 2283 |
the image data stream. LZW processing terminates when this code is encountered. |
| 2284 |
It must be the last code output by the encoder for an image. The value of this |
| 2285 |
code is <Clear code>+1. |
| 2286 |
|
| 2287 |
3. The first available compression code value is <Clear code>+2. |
| 2288 |
|
| 2289 |
4. The output codes are of variable length, starting at <code size>+1 bits per |
| 2290 |
code, up to 12 bits per code. This defines a maximum code value of 4095 |
| 2291 |
(0xFFF). Whenever the LZW code value would exceed the current code length, the |
| 2292 |
code length is increased by one. The packing/unpacking of these codes must then |
| 2293 |
be altered to reflect the new code length. |
| 2294 |
|
| 2295 |
BUILD 8-BIT BYTES |
| 2296 |
|
| 2297 |
Because the LZW compression used for GIF creates a series of variable length |
| 2298 |
codes, of between 3 and 12 bits each, these codes must be reformed into a |
| 2299 |
series of 8-bit bytes that will be the characters actually stored or |
| 2300 |
transmitted. This provides additional compression of the image. The codes are |
| 2301 |
formed into a stream of bits as if they were packed right to left and then |
| 2302 |
|
| 2303 |
|
| 2304 |
|
| 2305 |
|
| 2306 |
|
| 2307 |
|
| 2308 |
|
| 2309 |
32 |
| 2310 |
|
| 2311 |
|
| 2312 |
picked off 8 bits at a time to be output. |
| 2313 |
|
| 2314 |
Assuming a character array of 8 bits per character and using 5 bit codes to be |
| 2315 |
packed, an example layout would be similar to: |
| 2316 |
|
| 2317 |
|
| 2318 |
+---------------+ |
| 2319 |
0 | | bbbaaaaa |
| 2320 |
+---------------+ |
| 2321 |
1 | | dcccccbb |
| 2322 |
+---------------+ |
| 2323 |
2 | | eeeedddd |
| 2324 |
+---------------+ |
| 2325 |
3 | | ggfffffe |
| 2326 |
+---------------+ |
| 2327 |
4 | | hhhhhggg |
| 2328 |
+---------------+ |
| 2329 |
. . . |
| 2330 |
+---------------+ |
| 2331 |
N | | |
| 2332 |
+---------------+ |
| 2333 |
|
| 2334 |
|
| 2335 |
Note that the physical packing arrangement will change as the number of bits |
| 2336 |
per compression code change but the concept remains the same. |
| 2337 |
|
| 2338 |
PACKAGE THE BYTES |
| 2339 |
|
| 2340 |
Once the bytes have been created, they are grouped into blocks for output by |
| 2341 |
preceding each block of 0 to 255 bytes with a character count byte. A block |
| 2342 |
with a zero byte count terminates the Raster Data stream for a given image. |
| 2343 |
These blocks are what are actually output for the GIF image. This block format |
| 2344 |
has the side effect of allowing a decoding program the ability to read past the |
| 2345 |
actual image data if necessary by reading block counts and then skipping over |
| 2346 |
the data. |
| 2347 |
|
| 2348 |
|
| 2349 |
|
| 2350 |
FURTHER READING |
| 2351 |
|
| 2352 |
[1] Ziv, J. and Lempel, A. : "A Universal Algorithm for Sequential Data |
| 2353 |
Compression", IEEE Transactions on Information Theory, May 1977. |
| 2354 |
[2] Welch, T. : "A Technique for High-Performance Data Compression", Computer, |
| 2355 |
June 1984. |
| 2356 |
[3] Nelson, M.R. : "LZW Data Compression", Dr. Dobb's Journal, October 1989. |
| 2357 |
|
| 2358 |
|
| 2359 |
|
| 2360 |
|
| 2361 |
|
| 2362 |
|
| 2363 |
|
| 2364 |
|
| 2365 |
|
| 2366 |
|
| 2367 |
|
| 2368 |
|
| 2369 |
|
| 2370 |
|
| 2371 |
|
| 2372 |
|
| 2373 |
|
| 2374 |
|
| 2375 |
33 |
| 2376 |
|
| 2377 |
|
| 2378 |
Appendix |
| 2379 |
G. On-line Capabilities Dialogue. |
| 2380 |
|
| 2381 |
NOTE : This section is currently (10 July 1990) under revision; the information |
| 2382 |
provided here should be used as general guidelines. Code written based on this |
| 2383 |
information should be designed in a flexible way to accommodate any changes |
| 2384 |
resulting from the revisions. |
| 2385 |
|
| 2386 |
The following sequences are defined for use in mediating control between a GIF |
| 2387 |
sender and GIF receiver over an interactive communications line. These |
| 2388 |
sequences do not apply to applications that involve downloading of static GIF |
| 2389 |
files and are not considered part of a GIF file. |
| 2390 |
|
| 2391 |
GIF CAPABILITIES ENQUIRY |
| 2392 |
|
| 2393 |
The GIF Capabilities Enquiry sequence is issued from a host and requests an |
| 2394 |
interactive GIF decoder to return a response message that defines the graphics |
| 2395 |
parameters for the decoder. This involves returning information about available |
| 2396 |
screen sizes, number of bits/color supported and the amount of color detail |
| 2397 |
supported. The escape sequence for the GIF Capabilities Enquiry is defined as: |
| 2398 |
|
| 2399 |
ESC[>0g 0x1B 0x5B 0x3E 0x30 0x67 |
| 2400 |
|
| 2401 |
GIF CAPABILITIES RESPONSE |
| 2402 |
|
| 2403 |
The GIF Capabilities Response message is returned by an interactive GIF decoder |
| 2404 |
and defines the decoder's display capabilities for all graphics modes that are |
| 2405 |
supported by the software. Note that this can also include graphics printers as |
| 2406 |
well as a monitor screen. The general format of this message is: |
| 2407 |
|
| 2408 |
#version;protocol{;dev, width, height, color-bits, color-res}...<CR> |
| 2409 |
|
| 2410 |
|
| 2411 |
'#' GIF Capabilities Response identifier character. |
| 2412 |
version GIF format version number; initially '87a'. |
| 2413 |
protocol='0' No end-to-end protocol supported by decoder Transfer as direct |
| 2414 |
8-bit data stream. |
| 2415 |
protocol='1' Can use CIS B+ error correction protocol to transfer GIF data |
| 2416 |
interactively from the host directly to the display. |
| 2417 |
dev = '0' Screen parameter set follows. |
| 2418 |
dev = '1' Printer parameter set follows. |
| 2419 |
width Maximum supported display width in pixels. |
| 2420 |
height Maximum supported display height in pixels. |
| 2421 |
color-bits Number of bits per pixel supported. The number of supported |
| 2422 |
colors is therefore 2**color-bits. |
| 2423 |
color-res Number of bits per color component supported in the hardware |
| 2424 |
color palette. If color-res is '0' then no hardware palette |
| 2425 |
table is available. |
| 2426 |
|
| 2427 |
Note that all values in the GIF Capabilities Response are returned as ASCII |
| 2428 |
decimal numbers and the message is terminated by a Carriage Return character. |
| 2429 |
|
| 2430 |
The following GIF Capabilities Response message describes three standard IBM PC |
| 2431 |
Enhanced Graphics Adapter configurations with no printer; the GIF data stream |
| 2432 |
|
| 2433 |
|
| 2434 |
|
| 2435 |
|
| 2436 |
|
| 2437 |
|
| 2438 |
|
| 2439 |
|
| 2440 |
|
| 2441 |
34 |
| 2442 |
|
| 2443 |
|
| 2444 |
can be processed within an error correcting protocol: |
| 2445 |
|
| 2446 |
#87a;1;0,320,200,4,0;0,640,200,2,2;0,640,350,4,2<CR> |
| 2447 |
|
| 2448 |
ENTER GIF GRAPHICS MODE |
| 2449 |
|
| 2450 |
Two sequences are currently defined to invoke an interactive GIF decoder into |
| 2451 |
action. The only difference between them is that different output media are |
| 2452 |
selected. These sequences are: |
| 2453 |
|
| 2454 |
ESC[>1g Display GIF image on screen |
| 2455 |
|
| 2456 |
0x1B 0x5B 0x3E 0x31 0x67 |
| 2457 |
|
| 2458 |
ESC[>2g Display image directly to an attached graphics printer. The image may |
| 2459 |
optionally be displayed on the screen as well. |
| 2460 |
|
| 2461 |
0x1B 0x5B 0x3E 0x32 0x67 |
| 2462 |
|
| 2463 |
Note that the 'g' character terminating each sequence is in lowercase. |
| 2464 |
|
| 2465 |
INTERACTIVE ENVIRONMENT |
| 2466 |
|
| 2467 |
The assumed environment for the transmission of GIF image data from an |
| 2468 |
interactive application is a full 8-bit data stream from host to micro. All |
| 2469 |
256 character codes must be transferrable. The establishing of an 8-bit data |
| 2470 |
path for communications will normally be taken care of by the host application |
| 2471 |
programs. It is however up to the receiving communications programs supporting |
| 2472 |
GIF to be able to receive and pass on all 256 8-bit codes to the GIF decoder |
| 2473 |
software. |
| 2474 |
|
| 2475 |
|