#REFACTORING by exept
class: GIFReader
comment/format in: #readImage:
changed:
#fromStream:
#writeHeaderFor:
--- a/GIFReader.st Sun Feb 23 15:12:23 2020 +0100
+++ b/GIFReader.st Sun Feb 23 16:01:31 2020 +0100
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
"
COPYRIGHT (c) 1991 by Claus Gittinger
All Rights Reserved
@@ -290,7 +288,7 @@
photometric := #palette.
samplesPerPixel := 1.
- bitsPerSample := #(8).
+ bitsPerSample := #[8].
imageCount := 0.
atEnd := false.
@@ -638,7 +636,7 @@
codeLen:(codeLen + 1).
interlaced ifTrue:[
- "/ 'GIFREADER: deinterlacing ...' infoPrintCR.
+ "/ 'GIFREADER: deinterlacing ...' infoPrintCR.
tmp := ByteArray new:(data size).
"phase 1: 0, 8, 16, 24, ..."
@@ -966,8 +964,10 @@
bitsPerPixel := image bitsPerPixel.
outStream nextPutAll: 'GIF89a' asByteArray.
- self writeShort:width. "/ screen size
- self writeShort:height.
+
+ "/ local screen descriptor
+ outStream nextPutInt16:width MSB:(byteOrder ~~ #lsb). "/ screen size
+ outStream nextPutInt16:height MSB:(byteOrder ~~ #lsb).
t1 := 128.
t1 := t1 bitOr:(bitsPerPixel - 1 bitShift:5).
t1 := t1 bitOr:(bitsPerPixel - 1).
@@ -976,19 +976,19 @@
outStream nextPut:0. "/ aspect ratio
0 to:(1 bitShift:bitsPerPixel)-1 do:[:pixel |
- |clr red green blue|
+ |clr red green blue|
- clr := image colorFromValue:pixel.
- clr isNil ifTrue:[
- "/ unused colorMap slot
- red := green := blue := 0.
- ] ifFalse:[
- red := (clr redByte).
- green := (clr greenByte).
- blue := (clr blueByte).
- ].
- outStream
- nextPut:red; nextPut:green; nextPut:blue.
+ clr := image colorFromValue:pixel.
+ clr isNil ifTrue:[
+ "/ unused colorMap slot
+ red := green := blue := 0.
+ ] ifFalse:[
+ red := (clr redByte).
+ green := (clr greenByte).
+ blue := (clr blueByte).
+ ].
+ outStream
+ nextPut:red; nextPut:green; nextPut:blue.
].
"Created: / 14.10.1997 / 17:41:28 / cg"