GIFReader.st
author Claus Gittinger <cg@exept.de>
Thu, 24 Jul 1997 18:03:58 +0200
changeset 670 6a7f628ee66c
parent 647 6f26c76aa0c9
child 691 bb5dfbec2a7a
permissions -rw-r--r--
oops - mask was only set for interlaced images (stupid typo)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
3f9277473954 Initial revision
claus
parents:
diff changeset
     1
"
6
4ac87e6bf82f *** empty log message ***
claus
parents: 5
diff changeset
     2
 COPYRIGHT (c) 1991 by Claus Gittinger
26
2fe6294ca833 *** empty log message ***
claus
parents: 25
diff changeset
     3
	      All Rights Reserved
0
3f9277473954 Initial revision
claus
parents:
diff changeset
     4
3f9277473954 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
3f9277473954 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
3f9277473954 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
3f9277473954 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
3f9277473954 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
3f9277473954 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
3f9277473954 Initial revision
claus
parents:
diff changeset
    11
"
3f9277473954 Initial revision
claus
parents:
diff changeset
    12
3f9277473954 Initial revision
claus
parents:
diff changeset
    13
ImageReader subclass:#GIFReader
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
    14
	instanceVariableNames:'redMap greenMap blueMap'
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
    15
	classVariableNames:''
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
    16
	poolDictionaries:''
259
62b1bbafd9ba category change
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
    17
	category:'Graphics-Images-Support'
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    18
!
3f9277473954 Initial revision
claus
parents:
diff changeset
    19
339
9b4ece782f6a removed an infoPrint.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
    20
!GIFReader class methodsFor:'documentation'!
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    21
21
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    22
copyright
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    23
"
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    24
 COPYRIGHT (c) 1991 by Claus Gittinger
26
2fe6294ca833 *** empty log message ***
claus
parents: 25
diff changeset
    25
	      All Rights Reserved
21
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    26
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    27
 This software is furnished under a license and may be used
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    28
 only in accordance with the terms of that license and with the
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    30
 be provided or otherwise made available to, or used by, any
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    31
 other person.  No title to or ownership of the software is
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    32
 hereby transferred.
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    33
"
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    34
!
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    35
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    36
documentation
3f9277473954 Initial revision
claus
parents:
diff changeset
    37
"
3f9277473954 Initial revision
claus
parents:
diff changeset
    38
    this class provides methods for loading and saving GIF pictures.
21
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    39
    It has been tested with some different GIF87a pictures, I dont
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    40
    know, if it works with other GIF versions.
3f9277473954 Initial revision
claus
parents:
diff changeset
    41
    GIF extension blocks are not handled.
3f9277473954 Initial revision
claus
parents:
diff changeset
    42
3f9277473954 Initial revision
claus
parents:
diff changeset
    43
    GIF file writing is not implemented (use TIFF).
3f9277473954 Initial revision
claus
parents:
diff changeset
    44
21
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    45
    legal stuff extracted from GIF87a documentation:
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    46
3f9277473954 Initial revision
claus
parents:
diff changeset
    47
    CompuServe Incorporated hereby grants a limited, non-exclusive, royalty-free
3f9277473954 Initial revision
claus
parents:
diff changeset
    48
    license for the use of the Graphics Interchange Format(sm) in computer
3f9277473954 Initial revision
claus
parents:
diff changeset
    49
    software; computer software utilizing GIF(sm) must acknowledge ownership of the
3f9277473954 Initial revision
claus
parents:
diff changeset
    50
    Graphics Interchange Format and its Service Mark by CompuServe Incorporated, in
3f9277473954 Initial revision
claus
parents:
diff changeset
    51
    User and Technical Documentation. 
3f9277473954 Initial revision
claus
parents:
diff changeset
    52
3f9277473954 Initial revision
claus
parents:
diff changeset
    53
      The Graphics Interchange Format(c) is the Copyright property of
3f9277473954 Initial revision
claus
parents:
diff changeset
    54
      CompuServe Incorporated. GIF(sm) is a Service Mark property of
3f9277473954 Initial revision
claus
parents:
diff changeset
    55
      CompuServe Incorporated.
194
d4ecb23d7163 commentary
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
    56
d4ecb23d7163 commentary
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
    57
    [See also:]
234
b6352d13e792 xrefs in documentation
Claus Gittinger <cg@exept.de>
parents: 220
diff changeset
    58
        Image Form Icon
194
d4ecb23d7163 commentary
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
    59
        BlitImageReader FaceReader JPEGReader PBMReader PCXReader 
210
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
    60
        ST80FormReader SunRasterReader TargaReader TIFFReader WindowsIconReader 
209
840ddcf12904 commentary
Claus Gittinger <cg@exept.de>
parents: 198
diff changeset
    61
        XBMReader XPMReader XWDReader 
220
4106d9ce7e02 documentation
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    62
4106d9ce7e02 documentation
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    63
    [author:]
4106d9ce7e02 documentation
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    64
        Claus Gittinger
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    65
"
3f9277473954 Initial revision
claus
parents:
diff changeset
    66
! !
3f9277473954 Initial revision
claus
parents:
diff changeset
    67
339
9b4ece782f6a removed an infoPrint.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
    68
!GIFReader class methodsFor:'initialization'!
26
2fe6294ca833 *** empty log message ***
claus
parents: 25
diff changeset
    69
2fe6294ca833 *** empty log message ***
claus
parents: 25
diff changeset
    70
initialize
198
6d76856aaa80 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
    71
    "install myself in the Image classes fileFormat table
398
aef700d15416 new suffix-table
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
    72
     for the `.gif' extensions."
198
6d76856aaa80 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
    73
647
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
    74
    MIMETypes defineImageType:'image/gif' suffix:'gif' reader:self.
198
6d76856aaa80 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
    75
398
aef700d15416 new suffix-table
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
    76
    "Modified: 1.2.1997 / 14:59:37 / cg"
26
2fe6294ca833 *** empty log message ***
claus
parents: 25
diff changeset
    77
! !
2fe6294ca833 *** empty log message ***
claus
parents: 25
diff changeset
    78
339
9b4ece782f6a removed an infoPrint.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
    79
!GIFReader class methodsFor:'testing'!
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    80
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    81
isValidImageFile:aFileName
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    82
    "return true, if aFileName contains a GIF image"
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    83
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    84
    |id inStream|
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    85
9
415b0178ecba *** empty log message ***
claus
parents: 6
diff changeset
    86
    inStream := self streamReadingFile:aFileName.
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    87
    inStream isNil ifTrue:[^ false].
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    88
332
86b45e0f9ec0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    89
    inStream text.
86b45e0f9ec0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    90
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    91
    id := String new:6.
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    92
    inStream nextBytes:6 into:id.
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    93
    inStream close.
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    94
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    95
    (id = 'GIF87a') ifFalse:[
174
7fafcc56378d nicer message
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
    96
        (id startsWith:'GIF') ifFalse:[^ false].
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    97
174
7fafcc56378d nicer message
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
    98
        id ~= 'GIF89a' ifTrue:[ 
355
05eb4e183394 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
    99
            'GIFReader [info]: not a GIF87a/GIF89a file - hope that works' infoPrintCR.
174
7fafcc56378d nicer message
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   100
        ]
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   101
    ].
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   102
    ^ true
174
7fafcc56378d nicer message
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   103
355
05eb4e183394 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   104
    "Modified: 10.1.1997 / 15:40:34 / cg"
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   105
! !
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   106
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   107
!GIFReader methodsFor:'reading from file'!
3f9277473954 Initial revision
claus
parents:
diff changeset
   108
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   109
checkGreyscaleColormap
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   110
    "return true, if colormap is actually a greymap.
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   111
     Could be used to convert it into a greyScale image - which is not yet done."
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   112
20
7fd1b1ec5f6d *** empty log message ***
claus
parents: 9
diff changeset
   113
    |sz "{ Class: SmallInteger }"
7fd1b1ec5f6d *** empty log message ***
claus
parents: 9
diff changeset
   114
     redVal|
7fd1b1ec5f6d *** empty log message ***
claus
parents: 9
diff changeset
   115
7fd1b1ec5f6d *** empty log message ***
claus
parents: 9
diff changeset
   116
    sz := redMap size.
7fd1b1ec5f6d *** empty log message ***
claus
parents: 9
diff changeset
   117
7fd1b1ec5f6d *** empty log message ***
claus
parents: 9
diff changeset
   118
    1 to:sz do:[:i |
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   119
        redVal := redMap at:i.
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   120
        redVal ~~ (greenMap at:i) ifTrue:[^ false].
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   121
        redVal ~~ (blueMap at:i) ifTrue:[^ false].
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   122
    ].
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   123
    ^ true
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   124
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   125
    "Modified: 2.5.1996 / 17:54:40 / cg"
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   126
!
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   127
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   128
fromStream:aStream
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   129
    "read a stream containing a GIF image.
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   130
     Leave image description in instance variables."
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   131
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   132
    |byte index flag count
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   133
     colorMapSize bitsPerPixel scrWidth scrHeight
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   134
     hasColorMap hasLocalColorMap interlaced id
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   135
     leftOffs topOffs codeLen
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   136
     compressedData compressedSize
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   137
     tmp srcOffset dstOffset isGif89 atEnd
64
claus
parents: 43
diff changeset
   138
     h "{ Class: SmallInteger }"|
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   139
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   140
    inStream := aStream.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   141
    aStream binary.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   142
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   143
    "GIF-files are always lsb (intel-world)"
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   144
    byteOrder := #lsb.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   145
331
304f9c439efa allow reading from ByteArray-readStreams
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   146
    id := ByteArray new:6.
304f9c439efa allow reading from ByteArray-readStreams
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   147
    aStream nextBytes:6 into:id startingAt:1.
304f9c439efa allow reading from ByteArray-readStreams
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   148
    id := id asString.
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   149
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   150
    "all I had for testing where GIF87a files;
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   151
     I hope later versions work too ..."
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   152
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   153
    isGif89 := false.
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   154
    (id ~= 'GIF87a') ifTrue:[
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   155
        (id startsWith:'GIF') ifFalse:[
355
05eb4e183394 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   156
            'GIFReader [info]: not a gif file' infoPrintCR.
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   157
            ^ nil
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   158
        ].
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   159
        id ~= 'GIF89a' ifTrue:[ 
355
05eb4e183394 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   160
            'GIFReader [info]: not a GIF87a/GIF89a file - hope that works' infoPrintCR.
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   161
        ]
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   162
    ].
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   163
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   164
    "get screen dimensions (not used)"
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   165
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   166
    scrWidth := aStream nextShortMSB:false.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   167
    scrHeight := aStream nextShortMSB:false.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   168
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   169
    "get flag byte"
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   170
    flag := aStream nextByte.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   171
    hasColorMap :=      (flag bitAnd:2r10000000) ~~ 0.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   172
    "bitsPerRGB :=     ((flag bitAnd:2r01110000) bitShift:-4) + 1. "
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   173
    "colorMapSorted := ((flag bitAnd:2r00001000) ~~ 0.             "
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   174
    bitsPerPixel :=     (flag bitAnd:2r00000111) + 1.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   175
    colorMapSize := 1 bitShift:bitsPerPixel.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   176
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   177
    "get background (not used)"
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   178
    aStream nextByte.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   179
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   180
    "aspect ratio (not used)"
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   181
    aStream nextByte.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   182
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   183
    "get colorMap"
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   184
    hasColorMap ifTrue:[
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   185
        self readColorMap:colorMapSize.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   186
        colorMap := Colormap 
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   187
                        redVector:redMap 
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   188
                        greenVector:greenMap 
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   189
                        blueVector:blueMap.
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   190
    ].
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   191
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   192
    photometric := #palette.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   193
    samplesPerPixel := 1.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   194
    bitsPerSample := #(8).
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   195
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   196
    atEnd := false.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   197
    [atEnd] whileFalse:[
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   198
        "gif89a extensions"
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   199
        byte := aStream nextByte.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   200
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   201
        byte == 16r21 ifTrue:[
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   202
            "/ extension
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   203
            self readExtension:aStream.
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   204
        ] ifFalse:[
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   205
            (byte == 16r3B) ifTrue:[ "trailer"
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   206
                atEnd := true
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   207
            ] ifFalse:[
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   208
                "must be image separator"
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   209
                (byte ~~ 16r2C) ifTrue:[
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   210
                    ('GIFReader [info]: corrupted gif file (no IMAGESEP): ' , (byte printStringRadix:16)) infoPrintCR.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   211
                    ^ nil
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   212
                ].
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   213
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   214
                "get image data"
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   215
                leftOffs := aStream nextShortMSB:false.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   216
                topOffs := aStream nextShortMSB:false.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   217
                width := aStream nextShortMSB:false.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   218
                height := aStream nextShortMSB:false.
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   219
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   220
                dimensionCallBack notNil ifTrue:[
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   221
                    dimensionCallBack value:self
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   222
                ].
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   223
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   224
"/
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   225
"/              'width ' print. width printNewline.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   226
"/              'height ' print. height printNewline.
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   227
"/
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   228
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   229
                "another flag byte"
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   230
                flag := aStream nextByte.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   231
                interlaced :=           (flag bitAnd:2r01000000) ~~ 0.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   232
                hasLocalColorMap :=     (flag bitAnd:2r10000000) ~~ 0.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   233
                "localColorMapSorted := (flag bitAnd:2r00100000) ~~ 0.      "
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   234
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   235
                "if image has a local colormap, this one is used"
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   236
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   237
                hasLocalColorMap ifTrue:[
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   238
                    "local descr. overwrites"
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   239
                    bitsPerPixel := (flag bitAnd:2r00000111) + 1.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   240
                    colorMapSize := 1 bitShift:bitsPerPixel.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   241
                    "overwrite colormap"
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   242
                    self readColorMap:colorMapSize.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   243
                    colorMap := Colormap 
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   244
                                    redVector:redMap 
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   245
                                    greenVector:greenMap 
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   246
                                    blueVector:blueMap.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   247
                ].
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   248
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   249
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   250
                "get codelen for decompression"
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   251
                codeLen := aStream nextByte.
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   252
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   253
                compressedData := ByteArray uninitializedNew:(aStream size).
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   254
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   255
                "get compressed data"
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   256
                index := 1.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   257
                count := aStream nextByte.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   258
                [count notNil and:[count ~~ 0]] whileTrue:[
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   259
                    aStream nextBytes:count into:compressedData startingAt:index blockSize:4096.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   260
                    index := index + count.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   261
                    count := aStream nextByte
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   262
                ].
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   263
                compressedSize := index - 1.
83
claus
parents: 79
diff changeset
   264
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   265
                h := height.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   266
                data := ByteArray new:((width + 1) * (h + 1)).
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   267
"/                'GIFReader: decompressing ...' infoPrintCR.
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   268
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   269
                self class decompressGIFFrom:compressedData
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   270
                                       count:compressedSize
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   271
                                        into:data
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   272
                                  startingAt:1
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   273
                                     codeLen:(codeLen + 1).
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   274
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   275
                interlaced ifTrue:[
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   276
"/                    'GIFREADER: deinterlacing ...' infoPrintCR.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   277
                    tmp := ByteArray new:(data size).
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   278
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   279
                    "phase 1: 0, 8, 16, 24, ..."
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   280
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   281
                    srcOffset := 1.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   282
                    0 to:(h - 1) by:8 do:[:dstRow |
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   283
                        dstOffset := dstRow * width + 1.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   284
                        tmp replaceFrom:dstOffset to:(dstOffset + width - 1)
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   285
                                   with:data startingAt:srcOffset.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   286
                        srcOffset := srcOffset + width.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   287
                    ].
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   288
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   289
                    "phase 2: 4, 12, 20, 28, ..."
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   290
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   291
                    4 to:(h - 1) by:8 do:[:dstRow |
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   292
                        dstOffset := dstRow * width + 1.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   293
                        tmp replaceFrom:dstOffset to:(dstOffset + width - 1)
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   294
                                   with:data startingAt:srcOffset.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   295
                        srcOffset := srcOffset + width.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   296
                    ].
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   297
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   298
                    "phase 3: 2, 6, 10, 14, ..."
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   299
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   300
                    2 to:(h - 1) by:4 do:[:dstRow |
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   301
                        dstOffset := dstRow * width + 1.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   302
                        tmp replaceFrom:dstOffset to:(dstOffset + width - 1)
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   303
                                   with:data startingAt:srcOffset.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   304
                        srcOffset := srcOffset + width.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   305
                    ].
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   306
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   307
                    "phase 4: 1, 3, 5, 7, ..."
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   308
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   309
                    1 to:(h - 1) by:2 do:[:dstRow |
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   310
                        dstOffset := dstRow * width + 1.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   311
                        tmp replaceFrom:dstOffset to:(dstOffset + width - 1)
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   312
                                   with:data startingAt:srcOffset.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   313
                        srcOffset := srcOffset + width.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   314
                    ].
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   315
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   316
                    data := tmp.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   317
                    tmp := nil.
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   318
                ].
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   319
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   320
                imageSequence isNil ifTrue:[
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   321
                    imageSequence := OrderedCollection new.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   322
                ].
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   323
                maskPixel notNil ifTrue:[
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   324
                    "/
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   325
                    "/ ok, there is a maskValue
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   326
                    "/ build a Depth1Image for it.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   327
                    "/
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   328
                    self buildMaskFromColor:maskPixel
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   329
                ].
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   330
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   331
                imageSequence add:(self image).
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   332
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   333
                aStream atEnd ifTrue:[
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   334
                    atEnd := true.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   335
                ]
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   336
            ]
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   337
        ].
307
9eaeaca798a5 create a mask-image, if present
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   338
    ].
9eaeaca798a5 create a mask-image, if present
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   339
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   340
    "
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   341
     GIFReader fromFile:'../fileIn/bitmaps/claus.gif
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   342
     GIFReader fromFile:'../fileIn/bitmaps/garfield.gif'
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   343
     GIFReader new fromStream:('/home2/cg/.misc/circum.gif' asFilename readStream)
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   344
    "
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   345
315
506e0ce38534 Moved #buildMask from GIFReader to ImageReader>>#buildMaskFromColor:
Stefan Vogel <sv@exept.de>
parents: 312
diff changeset
   346
    "Modified: 5.7.1996 / 17:32:01 / stefan"
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   347
    "Modified: 24.7.1997 / 18:02:44 / cg"
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   348
!
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   349
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   350
makeGreyscale
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   351
    "not yet implemented/needed"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   352
!
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   353
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   354
readColorMap:colorMapSize
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   355
    "get gif colormap consisting of colorMapSize entries"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   356
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   357
    |sz "{ Class: SmallInteger }"|
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   358
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   359
    redMap := ByteArray uninitializedNew:colorMapSize.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   360
    greenMap := ByteArray uninitializedNew:colorMapSize.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   361
    blueMap := ByteArray uninitializedNew:colorMapSize.
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   362
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   363
    sz := colorMapSize.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   364
    1 to:sz do:[:i |
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   365
        redMap at:i put:(inStream nextByte).
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   366
        greenMap at:i put:(inStream nextByte).
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   367
        blueMap at:i put:(inStream nextByte)
307
9eaeaca798a5 create a mask-image, if present
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   368
    ].
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   369
307
9eaeaca798a5 create a mask-image, if present
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   370
    "Modified: 21.6.1996 / 12:32:43 / cg"
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   371
!
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   372
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   373
readExtension:aStream
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   374
    "get gif89 extension - this is currently ignored"
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   375
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   376
    |type blockSize subBlockSize
304
c8078fb77706 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
   377
     aspNum aspDen left top width height cWidth cHeight fg bg
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   378
     animationType animationTime animationMask
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   379
     appID appAUTH
625
72c766a86a0e less info printing
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   380
     iterationCount b ok|
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   381
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   382
    type := aStream nextByte.
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   383
    type == $R asciiValue ifTrue:[
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   384
        "/
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   385
        "/ Ratio extension
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   386
        "/
354
b4d2ce853c24 stefans suggested info/warning/error/fatal
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   387
        'GIFREADER [info]: ratio extension ignored' infoPrintCR.
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   388
        blockSize := aStream nextByte.
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   389
        (blockSize == 2) ifTrue:[
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   390
            aspNum := aStream nextByte.
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   391
            aspDen := aStream nextByte
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   392
        ] ifFalse:[
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   393
            aStream skip:blockSize
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   394
        ].
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   395
        "/ eat subblocks
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   396
        
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   397
        [(subBlockSize := aStream nextByte) > 0] whileTrue:[
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   398
            aStream skip:subBlockSize
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   399
        ].
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   400
        ^ self
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   401
    ].
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   402
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   403
    type == 16r01 ifTrue:[
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   404
        "/
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   405
        "/ plaintext extension
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   406
        "/
625
72c766a86a0e less info printing
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   407
"/        'GIFREADER [info]: plaintext extension ignored' infoPrintCR.
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   408
        subBlockSize := aStream nextByte.
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   409
        left := aStream nextShortMSB:false.
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   410
        top := aStream nextShortMSB:false.
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   411
        width := aStream nextShortMSB:false.
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   412
        height := aStream nextShortMSB:false.
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   413
        cWidth := aStream nextByte.
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   414
        cHeight := aStream nextByte.
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   415
        fg := aStream nextByte.
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   416
        bg := aStream nextByte.
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   417
        aStream skip:12.
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   418
        [(subBlockSize := aStream nextByte) > 0] whileTrue:[
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   419
            aStream skip:subBlockSize
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   420
        ].
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   421
        ^ self
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   422
    ].
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   423
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   424
    type == 16rF9 ifTrue:[
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   425
        "/
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   426
        "/ graphic control extension
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   427
        "/
354
b4d2ce853c24 stefans suggested info/warning/error/fatal
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   428
"/        'GIFREADER [info]: graphic control extension ignored' infoPrintCR.
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   429
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   430
        [(subBlockSize := aStream nextByte) ~~ 0] whileTrue:[
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   431
            "/ type bitAnd:1 means: animationMask is transparent pixel
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   432
            "/ to be implemented in Image ...
305
0edebf4ecaa7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   433
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   434
            animationType := aStream nextByte.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   435
            animationTime := aStream nextShortMSB:false.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   436
            animationMask := aStream nextByte.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   437
            subBlockSize := subBlockSize - 4.
307
9eaeaca798a5 create a mask-image, if present
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   438
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   439
           (animationType bitTest: 1) ifTrue:[
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   440
                maskPixel := animationMask.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   441
"/                'GIFREADER [info]: mask: ' infoPrint. (maskPixel printStringRadix:16) infoPrintCR.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   442
            ].
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   443
"/            'GIFREADER [info]: animationTime: ' infoPrint. (animationTime * (1/100)) infoPrintCR.
307
9eaeaca798a5 create a mask-image, if present
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   444
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   445
            subBlockSize ~~ 0 ifTrue:[
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   446
                aStream skip:subBlockSize
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   447
            ].
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   448
        ].
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   449
        ^ self
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   450
    ].
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   451
519
1ee56341ef50 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   452
    type == 16rFE ifTrue:[
1ee56341ef50 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   453
        "/
1ee56341ef50 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   454
        "/ comment extension
1ee56341ef50 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   455
        "/
625
72c766a86a0e less info printing
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   456
"/        'GIFREADER [info]: comment extension ignored' infoPrintCR.
519
1ee56341ef50 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   457
        [(blockSize := aStream nextByte) ~~ 0] whileTrue:[
1ee56341ef50 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   458
            aStream skip:blockSize
1ee56341ef50 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   459
        ].
1ee56341ef50 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   460
        ^ self
1ee56341ef50 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   461
    ].
1ee56341ef50 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   462
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   463
    type == 16rFF ifTrue:[
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   464
        "/
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   465
        "/  application extension
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   466
        "/
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   467
        subBlockSize := aStream nextByte.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   468
        appID := (aStream nextBytes:8 ) asString.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   469
        appAUTH := aStream nextBytes:3.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   470
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   471
        subBlockSize := aStream nextByte.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   472
625
72c766a86a0e less info printing
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   473
        ok := false.
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   474
        appID = 'NETSCAPE' ifTrue:[
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   475
            appAUTH asString = '2.0' ifTrue:[
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   476
                subBlockSize == 3 ifTrue:[
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   477
                    b := aStream nextByte.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   478
                    iterationCount := aStream nextShortMSB:false.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   479
                    subBlockSize := aStream nextByte.
625
72c766a86a0e less info printing
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   480
                    ok := true.
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   481
                ]
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   482
            ]
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   483
        ].
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   484
625
72c766a86a0e less info printing
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   485
        ok ifFalse:[
72c766a86a0e less info printing
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   486
            ('GIFREADER [info]: application extension (' , appID , ') ignored') infoPrintCR.
72c766a86a0e less info printing
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   487
        ].
72c766a86a0e less info printing
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   488
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   489
        [subBlockSize > 0] whileTrue:[
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   490
            aStream skip:subBlockSize.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   491
            subBlockSize := aStream nextByte.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   492
        ].
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   493
        ^ self
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   494
    ].
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   495
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   496
    type == 16r2C ifTrue:[
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   497
        "/
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   498
        "/  image descriptor extension
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   499
        "/
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   500
        'GIFREADER [info]: image descriptor extension ignored' infoPrintCR.
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   501
        [(subBlockSize := aStream nextByte) > 0] whileTrue:[
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   502
            aStream skip:subBlockSize
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   503
        ].
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   504
        ^ self
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   505
    ].
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   506
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   507
    "/
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   508
    "/ unknown extension
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   509
    "/
354
b4d2ce853c24 stefans suggested info/warning/error/fatal
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   510
    'GIFREADER [info]: unknown extension ignored' infoPrintCR.
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   511
    [(subBlockSize := aStream nextByte) > 0] whileTrue:[
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   512
        aStream skip:subBlockSize
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   513
    ]
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   514
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   515
    "Modified: 24.7.1997 / 18:02:49 / cg"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   516
! !
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   517
339
9b4ece782f6a removed an infoPrint.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   518
!GIFReader class methodsFor:'documentation'!
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   519
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   520
version
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   521
    ^ '$Header: /cvs/stx/stx/libview2/GIFReader.st,v 1.55 1997-07-24 16:03:58 cg Exp $'
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   522
! !
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   523
GIFReader initialize!