Gif89a Specification.docx
《Gif89a Specification.docx》由会员分享,可在线阅读,更多相关《Gif89a Specification.docx(66页珍藏版)》请在冰豆网上搜索。
Gif89aSpecification
CoverSheetfortheGIF89aSpecification
DEFERREDCLEARCODEINLZWCOMPRESSION
Therehasbeenconfusionaboutwhereclearcodescanbefoundinthe
datastream.Asthespecificationsays,theymayappearatanytime.There
isnotarequirementtosendaclearcodewhenthestringtableisfull.
Itistheencoder'sdecisionastowhenthetableshouldbecleared.When
thetableisfull,theencodercanchosetousethetableasis,makingno
changestoituntiltheencoderchoosestoclearit.Theencoderduring
thistimesendsoutcodesthatareofthemaximumCodeSize.
Aswecanseefromtheabove,whenthedecoder'stableisfull,itmust
notchangethetableuntilaclearcodeisreceived.TheCodeSizeisthat
ofthemaximumCodeSize.Processingotherthanthisisdonenormally.
Becauseofalargebaseofdecodersthatdonothandlethedecompressionin
thismanner,weaskdevelopersofGIFencodingsoftwaretoNOTimplement
thisfeatureuntilatleastJanuary1991andlateriftheyseethattheir
particularmarketisnotreadyforit.ThiswillgivedevelopersofGIF
decodingsoftwaretimetoimplementthisfeatureandtogetitintothe
handsoftheirclientsbeforethedecodersstart"breaking"onthenew
GIF's.Itisnotrequiredthatencoderschangetheirsoftwaretotake
advantageofthedeferredclearcode,butitisfordecoders.
APPLICATIONEXTENSIONBLOCK-APPLICATIONIDENTIFIER
TherewillbeaCourtesyDirectoryfilelocatedonCompuServeinthePICS
forum.ThisdirectorywillcontainApplicationIdentifiersforApplication
ExtensionBlocksthathavebeenusedbydevelopersofGIFapplications.
Thisfileisintendedtohelpkeepdevelopersthatwishtocreate
ApplicationExtensionBlocksfromusingthesameApplicationIdentifiers.
Thisisnotanofficialdirectory;itisforvoluntaryparticipationonly
anddoesnotguaranteethatsomeonewillnotusethesameidentifier.
E-MailcanbesenttoLarryWood(forummanagerofPICS)indicatingthe
requestforinclusioninthisfilewithanidentifier.
GRAPHICSINTERCHANGEFORMAT(sm)
Version89a
(c)1987,1988,1989,1990
Copyright
CompuServeIncorporated
Columbus,Ohio
CompuServeIncorporatedGraphicsInterchangeFormat
DocumentDate:
31July1990ProgrammingReference
TableofContents
Disclaimer.................................................................1
Foreword...................................................................1
Licensing..................................................................1
AbouttheDocument.........................................................2
GeneralDescription........................................................2
VersionNumbers............................................................2
TheEncoder................................................................3
TheDecoder................................................................3
Compliance.................................................................3
AboutRecommendations......................................................4
AboutColorTables.........................................................4
Blocks,ExtensionsandScope...............................................4
BlockSizes................................................................5
UsingGIFasanembeddedprotocol..........................................5
DataSub-blocks............................................................5
BlockTerminator...........................................................6
Header.....................................................................7
LogicalScreenDescriptor..................................................8
GlobalColorTable.........................................................10
ImageDescriptor...........................................................11
LocalColorTable..........................................................13
TableBasedImageData.....................................................14
GraphicControlExtension..................................................15
CommentExtension..........................................................17
PlainTextExtension.......................................................18
ApplicationExtension......................................................21
Trailer....................................................................23
QuickReferenceTable......................................................24
GIFGrammar................................................................25
Glossary...................................................................27
Conventions................................................................28
InterlacedImages..........................................................29
Variable-Length-CodeLZWCompression.......................................30
On-lineCapabilitiesDialogue..............................................33
1
1.Disclaimer.
Theinformationprovidedhereinissubjecttochangewithoutnotice.Inno
eventwillCompuServeIncorporatedbeliablefordamages,includinganylossof
revenue,lossofprofitsorotherincidentalorconsequentialdamagesarising
outoftheuseorinabilitytousetheinformation;CompuServeIncorporated
makesnoclaimastothesuitabilityoftheinformation.
2.Foreword.
ThisdocumentdefinestheGraphicsInterchangeFormat(sm).Thespecification
givenheredefinesversion89a,whichisanextensionofversion87a.
TheGraphicsInterchangeFormat(sm)asspecifiedhereshouldbeconsidered
complete;anydeviationfromitshouldbeconsideredinvalid,includingbutnot
limitedto,theuseofreservedorundefinedfieldswithincontrolordata
blocks,theinclusionofextraneousdatawithinorbetweenblocks,theuseof
methodsoralgorithmsnotspecificallylistedaspartoftheformat,etc.In
general,anyandalldeviations,extensionsormodificationsnotspecifiedin
thisdocumentshouldbeconsideredtobeinviolationoftheformatandshould
beavoided.
3.Licensing.
TheGraphicsInterchangeFormat(c)isthecopyrightpropertyofCompuServe
Incorporated.OnlyCompuServeIncorporatedisauthorizedtodefine,redefine,
enhance,alter,modifyorchangeinanywaythedefinitionoftheformat.
CompuServeIncorporatedherebygrantsalimited,non-exclusive,royalty-free
licensefortheuseoftheGraphicsInterchangeFormat(sm)incomputer
software;computersoftwareutilizingGIF(sm)mustacknowledgeownershipofthe
GraphicsInterchangeFormatanditsServiceMarkbyCompuServeIncorporated,in
UserandTechnicalDocumentation.ComputersoftwareutilizingGIF,whichis
distributedormaybedistributedwithoutUserorTechnicalDocumentationmust
displaytothescreenorprinteramessageacknowledgingownershipofthe
GraphicsInterchangeFormatandtheServiceMarkbyCompuServeIncorporated;in
thiscase,theacknowledgementmaybedisplayedinanopeningscreenorleading
banner,oraclosingscreenortrailingbanner.Amessagesuchasthefollowing
maybeused:
"TheGraphicsInterchangeFormat(c)istheCopyrightpropertyof
CompuServeIncorporated.GIF(sm)isaServiceMarkpropertyof
CompuServeIncorporated."
Forfurtherinformation,pleasecontact:
CompuServeIncorporated
GraphicsTechnologyDepartment
5000ArlingtonCenterBoulevard
Columbus,Ohio43220
U.S.A.
CompuServeIncorporatedmaintainsamailinglistwithallthoseindividualsand
organizationswhowishtoreceivecopiesofthisdocumentwhenitiscorrected
2
orrevised.Thisserviceisofferedfreeofcharge;pleaseprovideuswithyour
mailingaddress.
4.AbouttheDocument.
ThisdocumentdescribesindetailthedefinitionoftheGraphicsInterchange
Format.Thisdocumentisintendedasaprogrammingreference;itis
recommendedthattheentiredocumentbereadcarefullybeforeprogramming,
becauseoftheinterdependenceofthevariousparts.Thereisanindividual
sectionforeachoftheFormatblocks.Withineachsection,thesub-section
labeledRequiredVersionreferstotheversionnumberthatanencoderwillhave
touseifthecorrespondingblockisusedintheDataStream.Withineach
section,adiagramdescribestheindividualfieldsintheblock;thediagrams
aredrawnvertically;topbytesinthediagramappearfirstintheDataStream.
Bitswithinabytearedrawnmostsignificantontheleftend.Multi-byte
numericfieldsareorderedLeastSignificantBytefirst.Numericconstantsare
representedasHexadecimalnumbers,precededby"0x".Bitfieldswithinabyte
aredescribedinorderfrommostsignificantbitstoleastsignificantbits.
5.GeneralDescription.
TheGraphicsInterchangeFormat(sm)definesaprotocolintendedfortheon-line
transmissionandinterchangeofrastergraphicdatainawaythatis
independentofthehardwareusedintheircreationordisplay.
TheGraphicsInterchangeFormatisdefinedintermsofblocksandsub-blocks
whichcontainrelevantparametersanddatausedinthereproductionofa
graphic.AGIFDataStreamisasequenceofprotocolblocksandsub-blocks
representingacollectionofgraphics.Ingeneral,thegraphicsinaData
Streamareassumedtoberelatedtosomedegree,andtosharesomecontrol
information;itisrecommendedthatencodersattempttogrouptogetherrelated
graphicsinordertominimizehardwarechangesduringprocessingandto
minimizecontrolinformationoverhead.Forthesamereason,unrelatedgraphics
orgraphicswhichrequireresettinghardwareparametersshouldbeencoded
separatelytotheextentpossible.
ADataStreammayoriginatelocally,aswhenreadfromafile,oritmay
originateremotely,aswhentransmittedoverad