8 be provided or otherwise made available to, or used by, any |
8 be provided or otherwise made available to, or used by, any |
9 other person. No title to or ownership of the software is |
9 other person. No title to or ownership of the software is |
10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
12 |
12 |
|
13 'From Smalltalk/X, Version:3.2.1 on 21-oct-1997 at 5:07:17 pm' ! |
|
14 |
13 ImageReader subclass:#GIFReader |
15 ImageReader subclass:#GIFReader |
14 instanceVariableNames:'redMap greenMap blueMap pass xpos ypos rowByteSize remainBitCount |
16 instanceVariableNames:'redMap greenMap blueMap pass xpos ypos rowByteSize remainBitCount |
15 bufByte bufStream prefixTable suffixTable clearCode eoiCode |
17 bufByte bufStream prefixTable suffixTable clearCode eoiCode |
16 freeCode codeSize maxCode interlace' |
18 freeCode codeSize maxCode interlace' |
17 classVariableNames:'ImageSeparator Extension Terminator' |
19 classVariableNames:'ImageSeparator Extension Terminator' |
81 |
83 |
82 "Modified: 14.10.1997 / 18:47:27 / cg" |
84 "Modified: 14.10.1997 / 18:47:27 / cg" |
83 ! ! |
85 ! ! |
84 |
86 |
85 !GIFReader class methodsFor:'testing'! |
87 !GIFReader class methodsFor:'testing'! |
|
88 |
|
89 canRepresent:anImage |
|
90 "return true, if anImage can be represented in my file format. |
|
91 GIF supports depth 8 images only." |
|
92 |
|
93 ^ anImage depth == 8 |
|
94 |
|
95 "Created: 17.10.1997 / 20:19:20 / cg" |
|
96 ! |
86 |
97 |
87 isValidImageFile:aFileName |
98 isValidImageFile:aFileName |
88 "return true, if aFileName contains a GIF image" |
99 "return true, if aFileName contains a GIF image" |
89 |
100 |
90 |id inStream| |
101 |id inStream| |
802 t1 := t1 bitOr:(bitsPerPixel - 1). |
813 t1 := t1 bitOr:(bitsPerPixel - 1). |
803 outStream nextPut:t1. "/ flag |
814 outStream nextPut:t1. "/ flag |
804 outStream nextPut:0. "/ background (not used) |
815 outStream nextPut:0. "/ background (not used) |
805 outStream nextPut:0. "/ aspect ratio |
816 outStream nextPut:0. "/ aspect ratio |
806 |
817 |
807 n := 0. |
818 0 to:(1 bitShift:bitsPerPixel)-1 do:[:pixel | |
808 image colorMap notNil ifTrue:[ |
819 |clr red green blue| |
809 image colorMap do:[:clr | |
820 |
810 |red green blue| |
821 clr := image colorFromValue:pixel. |
811 |
822 clr isNil ifTrue:[ |
812 clr isNil ifTrue:[ |
823 "/ unused colorMap slot |
813 "/ unused colorMap slot |
824 red := green := blue := 0. |
814 red := green := blue := 0. |
825 ] ifFalse:[ |
815 ] ifFalse:[ |
826 red := (clr redByte). |
816 red := (clr redByte). |
827 green := (clr greenByte). |
817 green := (clr greenByte). |
828 blue := (clr blueByte). |
818 blue := (clr blueByte). |
829 ]. |
819 ]. |
830 outStream |
820 outStream |
831 nextPut:red; nextPut:green; nextPut:blue. |
821 nextPut:red; nextPut:green; nextPut:blue. |
832 ]. |
822 n := n + 1. |
833 "/ n := 0. |
823 ] |
834 "/ image colorMap notNil ifTrue:[ |
824 ]. |
835 "/ image colorMap do:[:clr | |
825 n+1 to:(1 bitShift:bitsPerPixel) do:[:i | |
836 "/ |red green blue| |
826 outStream nextPut:0; nextPut:0; nextPut:0 |
837 "/ |
827 ]. |
838 "/ clr isNil ifTrue:[ |
|
839 "/ "/ unused colorMap slot |
|
840 "/ red := green := blue := 0. |
|
841 "/ ] ifFalse:[ |
|
842 "/ red := (clr redByte). |
|
843 "/ green := (clr greenByte). |
|
844 "/ blue := (clr blueByte). |
|
845 "/ ]. |
|
846 "/ outStream |
|
847 "/ nextPut:red; nextPut:green; nextPut:blue. |
|
848 "/ n := n + 1. |
|
849 "/ ] |
|
850 "/ ]. |
|
851 "/ n+1 to:(1 bitShift:bitsPerPixel) do:[:i | |
|
852 "/ outStream nextPut:0; nextPut:0; nextPut:0 |
|
853 "/ ]. |
828 outStream nextPut:ImageSeparator. |
854 outStream nextPut:ImageSeparator. |
829 self writeShort:0. "/ |
855 self writeShort:0. "/ |
830 self writeShort:0. "/ |
856 self writeShort:0. "/ |
831 self writeShort:width. "/ image size |
857 self writeShort:width. "/ image size |
832 self writeShort:height. |
858 self writeShort:height. |
837 t1 := 0 |
863 t1 := 0 |
838 ]. |
864 ]. |
839 outStream nextPut:t1 "/ another flag |
865 outStream nextPut:t1 "/ another flag |
840 |
866 |
841 "Created: 14.10.1997 / 17:41:28 / cg" |
867 "Created: 14.10.1997 / 17:41:28 / cg" |
842 "Modified: 15.10.1997 / 19:54:30 / cg" |
868 "Modified: 21.10.1997 / 04:52:18 / cg" |
843 ! ! |
869 ! ! |
844 |
870 |
845 !GIFReader class methodsFor:'documentation'! |
871 !GIFReader class methodsFor:'documentation'! |
846 |
872 |
847 version |
873 version |
848 ^ '$Header: /cvs/stx/stx/libview2/GIFReader.st,v 1.59 1997-10-15 17:58:09 cg Exp $' |
874 ^ '$Header: /cvs/stx/stx/libview2/GIFReader.st,v 1.60 1997-10-21 18:26:40 cg Exp $' |
849 ! ! |
875 ! ! |
850 GIFReader initialize! |
876 GIFReader initialize! |