GIFReader.st
changeset 4450 c07db2570587
parent 4374 9ee6defe2909
equal deleted inserted replaced
4449:1d8968d59997 4450:c07db2570587
     1 "{ Encoding: utf8 }"
       
     2 
       
     3 "
     1 "
     4  COPYRIGHT (c) 1991 by Claus Gittinger
     2  COPYRIGHT (c) 1991 by Claus Gittinger
     5 	      All Rights Reserved
     3 	      All Rights Reserved
     6 
     4 
     7  This software is furnished under a license and may be used
     5  This software is furnished under a license and may be used
   288     ].
   286     ].
   289     colorMap := fileColorMap.
   287     colorMap := fileColorMap.
   290 
   288 
   291     photometric := #palette.
   289     photometric := #palette.
   292     samplesPerPixel := 1.
   290     samplesPerPixel := 1.
   293     bitsPerSample := #(8).
   291     bitsPerSample := #[8].
   294 
   292 
   295     imageCount := 0.
   293     imageCount := 0.
   296     atEnd := false.
   294     atEnd := false.
   297     [atEnd] whileFalse:[
   295     [atEnd] whileFalse:[
   298         "gif89a extensions"
   296         "gif89a extensions"
   636                             into:data
   634                             into:data
   637                       startingAt:1
   635                       startingAt:1
   638                          codeLen:(codeLen + 1).
   636                          codeLen:(codeLen + 1).
   639 
   637 
   640     interlaced ifTrue:[
   638     interlaced ifTrue:[
   641     "/    'GIFREADER: deinterlacing ...' infoPrintCR.
   639         "/ 'GIFREADER: deinterlacing ...' infoPrintCR.
   642         tmp := ByteArray new:(data size).
   640         tmp := ByteArray new:(data size).
   643 
   641 
   644         "phase 1: 0, 8, 16, 24, ..."
   642         "phase 1: 0, 8, 16, 24, ..."
   645 
   643 
   646         srcOffset := 1.
   644         srcOffset := 1.
   964     |bitsPerPixel t1|
   962     |bitsPerPixel t1|
   965 
   963 
   966     bitsPerPixel := image bitsPerPixel.
   964     bitsPerPixel := image bitsPerPixel.
   967 
   965 
   968     outStream nextPutAll: 'GIF89a' asByteArray.
   966     outStream nextPutAll: 'GIF89a' asByteArray.
   969     self writeShort:width. "/ screen size
   967 
   970     self writeShort:height.
   968     "/ local screen descriptor
       
   969     outStream nextPutInt16:width MSB:(byteOrder ~~ #lsb).       "/ screen size
       
   970     outStream nextPutInt16:height MSB:(byteOrder ~~ #lsb).
   971     t1 := 128.
   971     t1 := 128.
   972     t1 := t1 bitOr:(bitsPerPixel - 1 bitShift:5).
   972     t1 := t1 bitOr:(bitsPerPixel - 1 bitShift:5).
   973     t1 := t1 bitOr:(bitsPerPixel - 1).
   973     t1 := t1 bitOr:(bitsPerPixel - 1).
   974     outStream nextPut:t1.  "/ flag
   974     outStream nextPut:t1.  "/ flag
   975     outStream nextPut:0.   "/ background (not used)
   975     outStream nextPut:0.   "/ background (not used)
   976     outStream nextPut:0.   "/ aspect ratio
   976     outStream nextPut:0.   "/ aspect ratio
   977 
   977 
   978     0 to:(1 bitShift:bitsPerPixel)-1 do:[:pixel |
   978     0 to:(1 bitShift:bitsPerPixel)-1 do:[:pixel |
   979 	|clr red green blue|
   979         |clr red green blue|
   980 
   980 
   981 	clr := image colorFromValue:pixel.
   981         clr := image colorFromValue:pixel.
   982 	clr isNil ifTrue:[
   982         clr isNil ifTrue:[
   983 	    "/ unused colorMap slot
   983             "/ unused colorMap slot
   984 	    red := green := blue := 0.
   984             red := green := blue := 0.
   985 	] ifFalse:[
   985         ] ifFalse:[
   986 	    red := (clr redByte).
   986             red := (clr redByte).
   987 	    green := (clr greenByte).
   987             green := (clr greenByte).
   988 	    blue := (clr blueByte).
   988             blue := (clr blueByte).
   989 	].
   989         ].
   990 	outStream
   990         outStream
   991 	    nextPut:red; nextPut:green; nextPut:blue.
   991             nextPut:red; nextPut:green; nextPut:blue.
   992     ].
   992     ].
   993 
   993 
   994     "Created: / 14.10.1997 / 17:41:28 / cg"
   994     "Created: / 14.10.1997 / 17:41:28 / cg"
   995     "Modified: / 31.10.1997 / 16:12:13 / cg"
   995     "Modified: / 31.10.1997 / 16:12:13 / cg"
   996 !
   996 !