GIFReader.st
author Claus Gittinger <cg@exept.de>
Wed, 15 Oct 1997 19:58:09 +0200
changeset 712 6403dd3407eb
parent 710 c644d7932605
child 713 548898fdd1dc
permissions -rw-r--r--
checkin from browser
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
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
    14
	instanceVariableNames:'redMap greenMap blueMap pass xpos ypos rowByteSize remainBitCount
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
    15
		bufByte bufStream prefixTable suffixTable clearCode eoiCode
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
    16
		freeCode codeSize maxCode interlace'
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
    17
	classVariableNames:'ImageSeparator Extension Terminator'
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
    18
	poolDictionaries:''
259
62b1bbafd9ba category change
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
    19
	category:'Graphics-Images-Support'
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    20
!
3f9277473954 Initial revision
claus
parents:
diff changeset
    21
339
9b4ece782f6a removed an infoPrint.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
    22
!GIFReader class methodsFor:'documentation'!
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    23
21
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    24
copyright
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    25
"
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    26
 COPYRIGHT (c) 1991 by Claus Gittinger
26
2fe6294ca833 *** empty log message ***
claus
parents: 25
diff changeset
    27
	      All Rights Reserved
21
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    28
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    29
 This software is furnished under a license and may be used
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    30
 only in accordance with the terms of that license and with the
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    32
 be provided or otherwise made available to, or used by, any
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    33
 other person.  No title to or ownership of the software is
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    34
 hereby transferred.
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    35
"
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    36
!
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    37
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    38
documentation
3f9277473954 Initial revision
claus
parents:
diff changeset
    39
"
3f9277473954 Initial revision
claus
parents:
diff changeset
    40
    this class provides methods for loading and saving GIF pictures.
21
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    41
    It has been tested with some different GIF87a pictures, I dont
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    42
    know, if it works with other GIF versions.
3f9277473954 Initial revision
claus
parents:
diff changeset
    43
    GIF extension blocks are not handled.
3f9277473954 Initial revision
claus
parents:
diff changeset
    44
3f9277473954 Initial revision
claus
parents:
diff changeset
    45
    GIF file writing is not implemented (use TIFF).
3f9277473954 Initial revision
claus
parents:
diff changeset
    46
21
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    47
    legal stuff extracted from GIF87a documentation:
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    48
3f9277473954 Initial revision
claus
parents:
diff changeset
    49
    CompuServe Incorporated hereby grants a limited, non-exclusive, royalty-free
3f9277473954 Initial revision
claus
parents:
diff changeset
    50
    license for the use of the Graphics Interchange Format(sm) in computer
3f9277473954 Initial revision
claus
parents:
diff changeset
    51
    software; computer software utilizing GIF(sm) must acknowledge ownership of the
3f9277473954 Initial revision
claus
parents:
diff changeset
    52
    Graphics Interchange Format and its Service Mark by CompuServe Incorporated, in
3f9277473954 Initial revision
claus
parents:
diff changeset
    53
    User and Technical Documentation. 
3f9277473954 Initial revision
claus
parents:
diff changeset
    54
3f9277473954 Initial revision
claus
parents:
diff changeset
    55
      The Graphics Interchange Format(c) is the Copyright property of
3f9277473954 Initial revision
claus
parents:
diff changeset
    56
      CompuServe Incorporated. GIF(sm) is a Service Mark property of
3f9277473954 Initial revision
claus
parents:
diff changeset
    57
      CompuServe Incorporated.
194
d4ecb23d7163 commentary
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
    58
d4ecb23d7163 commentary
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
    59
    [See also:]
234
b6352d13e792 xrefs in documentation
Claus Gittinger <cg@exept.de>
parents: 220
diff changeset
    60
        Image Form Icon
194
d4ecb23d7163 commentary
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
    61
        BlitImageReader FaceReader JPEGReader PBMReader PCXReader 
210
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
    62
        ST80FormReader SunRasterReader TargaReader TIFFReader WindowsIconReader 
209
840ddcf12904 commentary
Claus Gittinger <cg@exept.de>
parents: 198
diff changeset
    63
        XBMReader XPMReader XWDReader 
220
4106d9ce7e02 documentation
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    64
4106d9ce7e02 documentation
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    65
    [author:]
4106d9ce7e02 documentation
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    66
        Claus Gittinger
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    67
"
3f9277473954 Initial revision
claus
parents:
diff changeset
    68
! !
3f9277473954 Initial revision
claus
parents:
diff changeset
    69
339
9b4ece782f6a removed an infoPrint.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
    70
!GIFReader class methodsFor:'initialization'!
26
2fe6294ca833 *** empty log message ***
claus
parents: 25
diff changeset
    71
2fe6294ca833 *** empty log message ***
claus
parents: 25
diff changeset
    72
initialize
198
6d76856aaa80 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
    73
    "install myself in the Image classes fileFormat table
398
aef700d15416 new suffix-table
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
    74
     for the `.gif' extensions."
198
6d76856aaa80 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
    75
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
    76
    ImageSeparator := $, asciiValue.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
    77
    Extension := $!! asciiValue.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
    78
    Terminator := $; asciiValue.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
    79
647
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
    80
    MIMETypes defineImageType:'image/gif' suffix:'gif' reader:self.
198
6d76856aaa80 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
    81
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
    82
    "Modified: 14.10.1997 / 18:47:27 / cg"
26
2fe6294ca833 *** empty log message ***
claus
parents: 25
diff changeset
    83
! !
2fe6294ca833 *** empty log message ***
claus
parents: 25
diff changeset
    84
339
9b4ece782f6a removed an infoPrint.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
    85
!GIFReader class methodsFor:'testing'!
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    86
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    87
isValidImageFile:aFileName
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    88
    "return true, if aFileName contains a GIF image"
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    89
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    90
    |id inStream|
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    91
9
415b0178ecba *** empty log message ***
claus
parents: 6
diff changeset
    92
    inStream := self streamReadingFile:aFileName.
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    93
    inStream isNil ifTrue:[^ false].
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    94
332
86b45e0f9ec0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    95
    inStream text.
86b45e0f9ec0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
    96
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    97
    id := String new:6.
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    98
    inStream nextBytes:6 into:id.
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
    99
    inStream close.
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   100
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   101
    (id = 'GIF87a') ifFalse:[
174
7fafcc56378d nicer message
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   102
        (id startsWith:'GIF') ifFalse:[^ false].
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   103
174
7fafcc56378d nicer message
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   104
        id ~= 'GIF89a' ifTrue:[ 
355
05eb4e183394 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   105
            'GIFReader [info]: not a GIF87a/GIF89a file - hope that works' infoPrintCR.
174
7fafcc56378d nicer message
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   106
        ]
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   107
    ].
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   108
    ^ true
174
7fafcc56378d nicer message
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   109
355
05eb4e183394 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   110
    "Modified: 10.1.1997 / 15:40:34 / cg"
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   111
! !
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   112
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   113
!GIFReader methodsFor:'private - writing'!
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   114
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   115
checkCodeSize
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   116
    (freeCode > maxCode and: [codeSize < 12])
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   117
            ifTrue: 
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   118
                    [codeSize := codeSize + 1.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   119
                    maxCode := (1 bitShift: codeSize) - 1]
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   120
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   121
    "Created: 14.10.1997 / 18:42:01 / cg"
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   122
!
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   123
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   124
flushBits
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   125
        remainBitCount = 0
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   126
                ifFalse: 
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   127
                        [self nextBytePut: bufByte.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   128
                        remainBitCount := 0].
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   129
        self flushBuffer
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   130
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   131
    "Modified: 14.10.1997 / 18:58:06 / cg"
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   132
!
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   133
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   134
flushBuffer
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   135
    bufStream isEmpty ifTrue: [^ self].
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   136
    outStream nextPut: bufStream size.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   137
    outStream nextPutAll: bufStream contents.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   138
    bufStream := WriteStream on: (ByteArray new: 256)
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   139
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   140
    "Modified: 14.10.1997 / 20:46:04 / cg"
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   141
!
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   142
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   143
flushCode
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   144
        self flushBits
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   145
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   146
    "Created: 14.10.1997 / 18:57:33 / cg"
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   147
!
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   148
710
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   149
nextBitsPut: anInteger
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   150
        | integer writeBitCount shiftCount |
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   151
        shiftCount _ 0.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   152
        remainBitCount = 0
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   153
                ifTrue:
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   154
                        [writeBitCount _ 8.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   155
                        integer _ anInteger]
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   156
                ifFalse:
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   157
                        [writeBitCount _ remainBitCount.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   158
                        integer _ bufByte + (anInteger bitShift: 8 - remainBitCount)].
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   159
        [writeBitCount < codeSize]
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   160
                whileTrue:
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   161
                        [self nextBytePut: ((integer bitShift: shiftCount) bitAnd: 255).
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   162
                        shiftCount _ shiftCount - 8.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   163
                        writeBitCount _ writeBitCount + 8].
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   164
        (remainBitCount _ writeBitCount - codeSize) = 0
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   165
                ifTrue: [self nextBytePut: (integer bitShift: shiftCount)]
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   166
                ifFalse: [bufByte _ integer bitShift: shiftCount].
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   167
        ^anInteger
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   168
710
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   169
    "Modified: 15.10.1997 / 16:50:30 / cg"
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   170
!
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   171
710
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   172
nextBytePut: aByte
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   173
        bufStream nextPut: aByte.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   174
        bufStream size >= 254 ifTrue: [self flushBuffer]
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   175
710
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   176
    "Modified: 15.10.1997 / 16:50:52 / cg"
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   177
!
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   178
710
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   179
readPixelFrom: bits 
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   180
    | pixel |
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   181
    ypos >= height ifTrue: [^ nil].
710
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   182
    pixel := bits at: ypos * rowByteSize + xpos + 1.
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   183
    self updatePixelPosition.
710
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   184
    ^ pixel
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   185
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   186
    "Created: 14.10.1997 / 18:43:50 / cg"
710
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   187
    "Modified: 15.10.1997 / 16:46:43 / cg"
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   188
!
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   189
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   190
setParameters:bitsPerPixel 
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   191
    clearCode := 1 bitShift:bitsPerPixel.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   192
    eoiCode := clearCode + 1.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   193
    freeCode := clearCode + 2.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   194
    codeSize := bitsPerPixel + 1.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   195
    maxCode := (1 bitShift: codeSize) - 1
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   196
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   197
    "Modified: 14.10.1997 / 20:09:48 / cg"
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   198
!
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   199
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   200
updatePixelPosition
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   201
        (xpos _ xpos + 1) >= width ifFalse: [^ self].
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   202
        xpos _ 0.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   203
        interlace == true
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   204
                ifFalse: 
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   205
                        [ypos _ ypos + 1.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   206
                        ^ self].
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   207
        pass = 0
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   208
                ifTrue: 
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   209
                        [(ypos _ ypos + 8) >= height
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   210
                                ifTrue: 
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   211
                                        [pass _ pass + 1.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   212
                                        ypos _ 4].
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   213
                        ^ self].
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   214
        pass = 1
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   215
                ifTrue: 
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   216
                        [(ypos _ ypos + 8) >= height
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   217
                                ifTrue: 
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   218
                                        [pass _ pass + 1.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   219
                                        ypos _ 2].
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   220
                        ^ self].
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   221
        pass = 2
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   222
                ifTrue: 
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   223
                        [(ypos _ ypos + 4) >= height
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   224
                                ifTrue: 
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   225
                                        [pass _ pass + 1.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   226
                                        ypos _ 1].
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   227
                        ^ self].
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   228
        pass = 3
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   229
                ifTrue: 
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   230
                        [ypos _ ypos + 2.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   231
                        ^ self].
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   232
        ^ self error: 'can''t happen'
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   233
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   234
    "Modified: 14.10.1997 / 18:44:27 / cg"
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   235
!
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   236
710
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   237
writeCode: aCode 
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   238
    self nextBitsPut: aCode
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   239
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   240
    "Created: 14.10.1997 / 18:38:35 / cg"
710
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   241
    "Modified: 15.10.1997 / 17:01:47 / cg"
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   242
!
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   243
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   244
writeCodeAndCheckCodeSize: t1 
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   245
    self writeCode: t1.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   246
    self checkCodeSize
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   247
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   248
    "Created: 14.10.1997 / 18:38:24 / cg"
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   249
    "Modified: 14.10.1997 / 18:40:56 / cg"
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   250
! !
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   251
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   252
!GIFReader methodsFor:'reading from file'!
3f9277473954 Initial revision
claus
parents:
diff changeset
   253
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   254
checkGreyscaleColormap
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   255
    "return true, if colormap is actually a greymap.
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   256
     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
   257
20
7fd1b1ec5f6d *** empty log message ***
claus
parents: 9
diff changeset
   258
    |sz "{ Class: SmallInteger }"
7fd1b1ec5f6d *** empty log message ***
claus
parents: 9
diff changeset
   259
     redVal|
7fd1b1ec5f6d *** empty log message ***
claus
parents: 9
diff changeset
   260
7fd1b1ec5f6d *** empty log message ***
claus
parents: 9
diff changeset
   261
    sz := redMap size.
7fd1b1ec5f6d *** empty log message ***
claus
parents: 9
diff changeset
   262
7fd1b1ec5f6d *** empty log message ***
claus
parents: 9
diff changeset
   263
    1 to:sz do:[:i |
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   264
        redVal := redMap at:i.
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   265
        redVal ~~ (greenMap at:i) ifTrue:[^ false].
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   266
        redVal ~~ (blueMap at:i) ifTrue:[^ false].
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   267
    ].
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   268
    ^ true
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   269
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   270
    "Modified: 2.5.1996 / 17:54:40 / cg"
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   271
!
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   272
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   273
fromStream:aStream
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   274
    "read a stream containing a GIF image.
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   275
     Leave image description in instance variables."
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   276
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   277
    |byte index flag count fileColorMap
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   278
     colorMapSize bitsPerPixel scrWidth scrHeight
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   279
     hasColorMap hasLocalColorMap interlaced id
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   280
     leftOffs topOffs codeLen
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   281
     compressedData compressedSize
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   282
     tmp srcOffset dstOffset isGif89 atEnd
64
claus
parents: 43
diff changeset
   283
     h "{ Class: SmallInteger }"|
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   284
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   285
    inStream := aStream.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   286
    aStream binary.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   287
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   288
    "GIF-files are always lsb (intel-world)"
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   289
    byteOrder := #lsb.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   290
331
304f9c439efa allow reading from ByteArray-readStreams
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   291
    id := ByteArray new:6.
304f9c439efa allow reading from ByteArray-readStreams
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   292
    aStream nextBytes:6 into:id startingAt:1.
304f9c439efa allow reading from ByteArray-readStreams
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   293
    id := id asString.
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   294
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   295
    "all I had for testing where GIF87a files;
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   296
     I hope later versions work too ..."
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   297
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   298
    isGif89 := false.
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   299
    (id ~= 'GIF87a') ifTrue:[
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   300
        (id startsWith:'GIF') ifFalse:[
355
05eb4e183394 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   301
            'GIFReader [info]: not a gif file' infoPrintCR.
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   302
            ^ nil
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   303
        ].
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   304
        id ~= 'GIF89a' ifTrue:[ 
355
05eb4e183394 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   305
            '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
   306
        ]
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   307
    ].
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   308
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   309
    "get screen dimensions (not used)"
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   310
    scrWidth := aStream nextShortMSB:false.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   311
    scrHeight := aStream nextShortMSB:false.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   312
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   313
    "get flag byte"
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   314
    flag := aStream nextByte.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   315
    hasColorMap :=      (flag bitAnd:2r10000000) ~~ 0.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   316
    "bitsPerRGB :=     ((flag bitAnd:2r01110000) bitShift:-4) + 1. "
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   317
    "colorMapSorted := ((flag bitAnd:2r00001000) ~~ 0.             "
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   318
    bitsPerPixel :=     (flag bitAnd:2r00000111) + 1.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   319
    colorMapSize := 1 bitShift:bitsPerPixel.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   320
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   321
    "get background (not used)"
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   322
    aStream nextByte.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   323
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   324
    "aspect ratio (not used)"
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   325
    aStream nextByte.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   326
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   327
    "get colorMap"
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   328
    hasColorMap ifTrue:[
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   329
        self readColorMap:colorMapSize.
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   330
        fileColorMap := Colormap 
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   331
                        redVector:redMap 
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   332
                        greenVector:greenMap 
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   333
                        blueVector:blueMap.
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   334
    ].
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   335
    colorMap := fileColorMap.
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   336
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   337
    photometric := #palette.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   338
    samplesPerPixel := 1.
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   339
    bitsPerSample := #(8).
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   340
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   341
    atEnd := false.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   342
    [atEnd] whileFalse:[
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   343
        "gif89a extensions"
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   344
        byte := aStream nextByte.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   345
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   346
        byte == Extension ifTrue:[
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   347
            self readExtension:aStream.
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   348
        ] ifFalse:[
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   349
            (byte == Terminator) ifTrue:[
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   350
                atEnd := true
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   351
            ] ifFalse:[
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   352
                "must be image separator"
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   353
                (byte ~~ ImageSeparator) ifTrue:[
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   354
                    ('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
   355
                    ^ nil
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   356
                ].
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   357
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   358
                "get image data"
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   359
                leftOffs := aStream nextShortMSB:false.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   360
                topOffs := aStream nextShortMSB:false.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   361
                width := aStream nextShortMSB:false.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   362
                height := aStream nextShortMSB:false.
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   363
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   364
                dimensionCallBack notNil ifTrue:[
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   365
                    dimensionCallBack value:self
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   366
                ].
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   367
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   368
"/
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   369
"/              'width ' print. width printNewline.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   370
"/              'height ' print. height printNewline.
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   371
"/
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   372
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   373
                "another flag byte"
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   374
                flag := aStream nextByte.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   375
                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
   376
                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
   377
                "localColorMapSorted := (flag bitAnd:2r00100000) ~~ 0.      "
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   378
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   379
                "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
   380
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   381
                hasLocalColorMap ifTrue:[
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   382
                    "local descr. overwrites"
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   383
                    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
   384
                    colorMapSize := 1 bitShift:bitsPerPixel.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   385
                    "overwrite colormap"
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   386
                    self readColorMap:colorMapSize.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   387
                    colorMap := Colormap 
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   388
                                    redVector:redMap 
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   389
                                    greenVector:greenMap 
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   390
                                    blueVector:blueMap.
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   391
                ] ifFalse:[
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   392
                    colorMap := fileColorMap
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   393
                ].
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   394
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   395
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   396
                "get codelen for decompression"
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   397
                codeLen := aStream nextByte.
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   398
691
bb5dfbec2a7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 670
diff changeset
   399
                compressedData := ByteArray uninitializedNew:(aStream fileSize).
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   400
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   401
                "get compressed data"
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   402
                index := 1.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   403
                count := aStream nextByte.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   404
                [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
   405
                    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
   406
                    index := index + count.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   407
                    count := aStream nextByte
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   408
                ].
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   409
                compressedSize := index - 1.
83
claus
parents: 79
diff changeset
   410
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   411
                h := height.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   412
                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
   413
"/                'GIFReader: decompressing ...' infoPrintCR.
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   414
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   415
                self class decompressGIFFrom:compressedData
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   416
                                       count:compressedSize
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   417
                                        into:data
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   418
                                  startingAt:1
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   419
                                     codeLen:(codeLen + 1).
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   420
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   421
                interlaced ifTrue:[
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   422
"/                    'GIFREADER: deinterlacing ...' infoPrintCR.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   423
                    tmp := ByteArray new:(data size).
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   424
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   425
                    "phase 1: 0, 8, 16, 24, ..."
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   426
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   427
                    srcOffset := 1.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   428
                    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
   429
                        dstOffset := dstRow * width + 1.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   430
                        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
   431
                                   with:data startingAt:srcOffset.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   432
                        srcOffset := srcOffset + width.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   433
                    ].
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   434
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   435
                    "phase 2: 4, 12, 20, 28, ..."
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   436
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   437
                    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
   438
                        dstOffset := dstRow * width + 1.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   439
                        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
   440
                                   with:data startingAt:srcOffset.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   441
                        srcOffset := srcOffset + width.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   442
                    ].
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   443
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   444
                    "phase 3: 2, 6, 10, 14, ..."
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   445
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   446
                    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
   447
                        dstOffset := dstRow * width + 1.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   448
                        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
   449
                                   with:data startingAt:srcOffset.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   450
                        srcOffset := srcOffset + width.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   451
                    ].
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   452
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   453
                    "phase 4: 1, 3, 5, 7, ..."
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   454
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   455
                    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
   456
                        dstOffset := dstRow * width + 1.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   457
                        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
   458
                                   with:data startingAt:srcOffset.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   459
                        srcOffset := srcOffset + width.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   460
                    ].
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   461
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   462
                    data := tmp.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   463
                    tmp := nil.
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   464
                ].
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   465
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   466
                imageSequence isNil ifTrue:[
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   467
                    imageSequence := OrderedCollection new.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   468
                ].
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   469
                maskPixel notNil ifTrue:[
618
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
                    "/ ok, there is a maskValue
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   472
                    "/ build a Depth1Image for it.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   473
                    "/
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   474
                    self buildMaskFromColor:maskPixel
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   475
                ].
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   476
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   477
                imageSequence add:(self image).
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   478
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   479
                aStream atEnd ifTrue:[
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   480
                    atEnd := true.
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
        ].
307
9eaeaca798a5 create a mask-image, if present
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   484
    ].
9eaeaca798a5 create a mask-image, if present
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   485
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   486
    "
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   487
     GIFReader fromFile:'../fileIn/bitmaps/claus.gif
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   488
     GIFReader fromFile:'../fileIn/bitmaps/garfield.gif'
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   489
     GIFReader new fromStream:('/home2/cg/.misc/circum.gif' asFilename readStream)
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   490
    "
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   491
315
506e0ce38534 Moved #buildMask from GIFReader to ImageReader>>#buildMaskFromColor:
Stefan Vogel <sv@exept.de>
parents: 312
diff changeset
   492
    "Modified: 5.7.1996 / 17:32:01 / stefan"
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   493
    "Modified: 14.10.1997 / 20:45:57 / cg"
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   494
!
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   495
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   496
makeGreyscale
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   497
    "not yet implemented/needed"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   498
!
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   499
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   500
readColorMap:colorMapSize
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   501
    "get gif colormap consisting of colorMapSize entries"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   502
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   503
    |sz "{ Class: SmallInteger }"|
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   504
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   505
    redMap := ByteArray uninitializedNew:colorMapSize.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   506
    greenMap := ByteArray uninitializedNew:colorMapSize.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   507
    blueMap := ByteArray uninitializedNew:colorMapSize.
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   508
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   509
    sz := colorMapSize.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   510
    1 to:sz do:[:i |
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   511
        redMap at:i put:(inStream nextByte).
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   512
        greenMap at:i put:(inStream nextByte).
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   513
        blueMap at:i put:(inStream nextByte)
307
9eaeaca798a5 create a mask-image, if present
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   514
    ].
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   515
307
9eaeaca798a5 create a mask-image, if present
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   516
    "Modified: 21.6.1996 / 12:32:43 / cg"
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   517
!
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   518
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   519
readExtension:aStream
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   520
    "get gif89 extension - this is currently ignored"
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   521
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   522
    |type blockSize subBlockSize
304
c8078fb77706 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
   523
     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
   524
     animationType animationTime animationMask
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   525
     appID appAUTH
625
72c766a86a0e less info printing
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   526
     iterationCount b ok|
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   527
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   528
    type := aStream nextByte.
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   529
    type == $R asciiValue ifTrue:[
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   530
        "/
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   531
        "/ Ratio extension
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   532
        "/
354
b4d2ce853c24 stefans suggested info/warning/error/fatal
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   533
        'GIFREADER [info]: ratio extension ignored' infoPrintCR.
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   534
        blockSize := aStream nextByte.
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   535
        (blockSize == 2) ifTrue:[
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   536
            aspNum := aStream nextByte.
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   537
            aspDen := aStream nextByte
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   538
        ] ifFalse:[
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   539
            aStream skip:blockSize
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   540
        ].
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   541
        "/ eat subblocks
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   542
        
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   543
        [(subBlockSize := aStream nextByte) > 0] whileTrue:[
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   544
            aStream skip:subBlockSize
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   545
        ].
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   546
        ^ self
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   547
    ].
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   548
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   549
    type == 16r01 ifTrue:[
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   550
        "/
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   551
        "/ plaintext extension
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   552
        "/
625
72c766a86a0e less info printing
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   553
"/        'GIFREADER [info]: plaintext extension ignored' infoPrintCR.
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   554
        subBlockSize := aStream nextByte.
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   555
        left := aStream nextShortMSB:false.
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   556
        top := aStream nextShortMSB:false.
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   557
        width := aStream nextShortMSB:false.
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   558
        height := aStream nextShortMSB:false.
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   559
        cWidth := aStream nextByte.
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   560
        cHeight := aStream nextByte.
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   561
        fg := aStream nextByte.
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   562
        bg := aStream nextByte.
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   563
        aStream skip:12.
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   564
        [(subBlockSize := aStream nextByte) > 0] whileTrue:[
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   565
            aStream skip:subBlockSize
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   566
        ].
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   567
        ^ self
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   568
    ].
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   569
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   570
    type == 16rF9 ifTrue:[
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   571
        "/
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   572
        "/ graphic control extension
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   573
        "/
354
b4d2ce853c24 stefans suggested info/warning/error/fatal
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   574
"/        '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
   575
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   576
        [(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
   577
            "/ 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
   578
            "/ to be implemented in Image ...
305
0edebf4ecaa7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   579
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   580
            animationType := aStream nextByte.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   581
            animationTime := aStream nextShortMSB:false.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   582
            animationMask := aStream nextByte.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   583
            subBlockSize := subBlockSize - 4.
307
9eaeaca798a5 create a mask-image, if present
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   584
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   585
           (animationType bitTest: 1) ifTrue:[
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   586
                maskPixel := animationMask.
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   587
"/                '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
   588
            ].
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   589
"/            '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
   590
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   591
            subBlockSize ~~ 0 ifTrue:[
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   592
                aStream skip:subBlockSize
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   593
            ].
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   594
        ].
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   595
        ^ self
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   596
    ].
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   597
519
1ee56341ef50 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   598
    type == 16rFE ifTrue:[
1ee56341ef50 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   599
        "/
1ee56341ef50 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   600
        "/ comment extension
1ee56341ef50 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   601
        "/
625
72c766a86a0e less info printing
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   602
"/        'GIFREADER [info]: comment extension ignored' infoPrintCR.
519
1ee56341ef50 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   603
        [(blockSize := aStream nextByte) ~~ 0] whileTrue:[
1ee56341ef50 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   604
            aStream skip:blockSize
1ee56341ef50 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   605
        ].
1ee56341ef50 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   606
        ^ self
1ee56341ef50 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   607
    ].
1ee56341ef50 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   608
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   609
    type == 16rFF ifTrue:[
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   610
        "/
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   611
        "/  application extension
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   612
        "/
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   613
        subBlockSize := aStream nextByte.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   614
        appID := (aStream nextBytes:8 ) asString.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   615
        appAUTH := aStream nextBytes:3.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   616
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   617
        subBlockSize := aStream nextByte.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   618
625
72c766a86a0e less info printing
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   619
        ok := false.
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   620
        appID = 'NETSCAPE' ifTrue:[
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   621
            appAUTH asString = '2.0' ifTrue:[
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   622
                subBlockSize == 3 ifTrue:[
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   623
                    b := aStream nextByte.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   624
                    iterationCount := aStream nextShortMSB:false.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   625
                    subBlockSize := aStream nextByte.
625
72c766a86a0e less info printing
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   626
                    ok := true.
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   627
                ]
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   628
            ]
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   629
        ].
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   630
625
72c766a86a0e less info printing
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   631
        ok ifFalse:[
72c766a86a0e less info printing
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   632
            ('GIFREADER [info]: application extension (' , appID , ') ignored') infoPrintCR.
72c766a86a0e less info printing
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   633
        ].
72c766a86a0e less info printing
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   634
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   635
        [subBlockSize > 0] whileTrue:[
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   636
            aStream skip:subBlockSize.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   637
            subBlockSize := aStream nextByte.
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   638
        ].
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   639
        ^ self
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   640
    ].
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   641
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   642
    type == 16r2C ifTrue:[
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   643
        "/
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   644
        "/  image descriptor extension
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   645
        "/
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   646
        'GIFREADER [info]: image descriptor extension ignored' infoPrintCR.
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   647
        [(subBlockSize := aStream nextByte) > 0] whileTrue:[
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   648
            aStream skip:subBlockSize
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   649
        ].
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   650
        ^ self
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   651
    ].
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   652
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   653
    "/
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   654
    "/ unknown extension
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   655
    "/
354
b4d2ce853c24 stefans suggested info/warning/error/fatal
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   656
    'GIFREADER [info]: unknown extension ignored' infoPrintCR.
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   657
    [(subBlockSize := aStream nextByte) > 0] whileTrue:[
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   658
        aStream skip:subBlockSize
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   659
    ]
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   660
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   661
    "Modified: 24.7.1997 / 18:02:49 / cg"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   662
! !
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   663
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   664
!GIFReader methodsFor:'writing to file'!
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   665
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   666
save:image onFile:aFileName
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   667
    "save image as GIF file on aFileName"
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   668
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   669
    outStream := FileStream newFileNamed:aFileName.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   670
    outStream isNil ifTrue:[
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   671
        ^ Image fileCreationErrorSignal 
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   672
            raiseWith:image
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   673
            errorString:('file creation error: ' , aFileName asString).
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   674
    ].
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   675
    outStream binary.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   676
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   677
    image mask notNil ifTrue:[
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   678
        Image informationLostQuerySignal
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   679
            raiseWith:image
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   680
            errorString:('GFF writer does not (yet) support an imageMask').
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   681
    ].
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   682
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   683
    byteOrder := #lsb.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   684
    width := image width.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   685
    height := image height.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   686
    photometric := image photometric.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   687
    samplesPerPixel := image samplesPerPixel.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   688
    bitsPerSample := image bitsPerSample.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   689
    colorMap := image colorMap.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   690
    data := image bits.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   691
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   692
    self writeHeaderFor:image.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   693
    self writeBitDataFor:image.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   694
    outStream close.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   695
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   696
    "
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   697
     |i|
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   698
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   699
     i := Image fromFile:'bitmaps/gifImages/garfield.gif'.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   700
     GIFReader save:i onFile:'foo.gif'.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   701
     (Image fromFile:'./foo.gif') inspect
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   702
    "
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   703
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   704
    "Created: 14.10.1997 / 17:40:12 / cg"
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   705
    "Modified: 14.10.1997 / 18:59:22 / cg"
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   706
!
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   707
710
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   708
writeBitDataFor: image
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   709
        "using modified Lempel-Ziv Welch algorithm."
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   710
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   711
        | bits bitsPerPixel
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   712
          maxBits maxMaxCode tSize initCodeSize ent tShift fCode pixel index disp nomatch |
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   713
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   714
        bitsPerPixel := image bitsPerPixel.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   715
        bits := image bits.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   716
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   717
        pass := 0.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   718
        xpos := 0.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   719
        ypos := 0.
712
6403dd3407eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   720
        rowByteSize := image bytesPerRow. "/ width * 8 + 31 // 32 * 4.
710
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   721
        remainBitCount := 0.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   722
        bufByte := 0.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   723
        bufStream := WriteStream on: (ByteArray new: 256).
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   724
710
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   725
        maxBits := 12.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   726
        maxMaxCode := 1 bitShift: maxBits.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   727
        tSize := 5003.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   728
        prefixTable := Array new: tSize.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   729
        suffixTable := Array new: tSize.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   730
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   731
        initCodeSize := bitsPerPixel <= 1 ifTrue: [2] ifFalse: [bitsPerPixel].
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   732
        outStream nextPut: initCodeSize.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   733
        self setParameters: initCodeSize.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   734
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   735
        tShift := 0.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   736
        fCode := tSize.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   737
        [fCode < 65536] whileTrue:
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   738
                [tShift := tShift + 1.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   739
                fCode := fCode * 2].
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   740
        tShift := 8 - tShift.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   741
        1 to: tSize do: [:i | suffixTable at: i put: -1].
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   742
710
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   743
        self writeCodeAndCheckCodeSize: clearCode.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   744
        ent := self readPixelFrom: bits.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   745
        [(pixel := self readPixelFrom: bits) == nil] whileFalse:
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   746
                [
710
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   747
                fCode := (pixel bitShift: maxBits) + ent.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   748
                index := ((pixel bitShift: tShift) bitXor: ent) + 1.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   749
                (suffixTable at: index) = fCode
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   750
                        ifTrue: [ent := prefixTable at: index]
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   751
                        ifFalse:
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   752
                                [nomatch := true.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   753
                                (suffixTable at: index) >= 0
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   754
                                        ifTrue:
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   755
                                                [disp := tSize - index + 1.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   756
                                                index = 1 ifTrue: [disp := 1].
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   757
                                                "probe"
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   758
                                                [(index := index - disp) < 1 ifTrue: [index := index + tSize].
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   759
                                                (suffixTable at: index) = fCode
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   760
                                                        ifTrue:
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   761
                                                                [ent := prefixTable at: index.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   762
                                                                nomatch := false.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   763
                                                                "continue whileFalse:"].
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   764
                                                nomatch and: [(suffixTable at: index) > 0]]
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   765
                                                        whileTrue: ["probe"]].
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   766
                                "nomatch"
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   767
                                nomatch ifTrue:
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   768
                                        [self writeCodeAndCheckCodeSize: ent.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   769
                                        ent := pixel.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   770
                                        freeCode < maxMaxCode
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   771
                                                ifTrue:
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   772
                                                        [prefixTable at: index put: freeCode.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   773
                                                        suffixTable at: index put: fCode.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   774
                                                        freeCode := freeCode + 1]
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   775
                                                ifFalse:
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   776
                                                        [self writeCodeAndCheckCodeSize: clearCode.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   777
                                                        1 to: tSize do: [:i | suffixTable at: i put: -1].
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   778
                                                        self setParameters: initCodeSize]]]].
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   779
        prefixTable := suffixTable := nil.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   780
        self writeCodeAndCheckCodeSize: ent.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   781
        self writeCodeAndCheckCodeSize: eoiCode.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   782
        self flushCode.
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   783
710
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   784
        outStream nextPut: 0.        "zero-length packet"
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   785
        outStream nextPut: Terminator.
c644d7932605 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   786
712
6403dd3407eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   787
    "Modified: 15.10.1997 / 19:56:28 / cg"
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   788
!
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   789
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   790
writeHeaderFor:image
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   791
    "save image as GIF file on aFileName"
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   792
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   793
    |bitsPerPixel t1 n|
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   794
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   795
    bitsPerPixel := image bitsPerPixel.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   796
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   797
    outStream nextPutAll: 'GIF87a' asByteArray.
712
6403dd3407eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   798
    self writeShort:width. "/ screen size
6403dd3407eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   799
    self writeShort:height.    
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   800
    t1 := 128.
712
6403dd3407eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   801
    t1 := t1 bitOr:(bitsPerPixel - 1 bitShift:5).
6403dd3407eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   802
    t1 := t1 bitOr:(bitsPerPixel - 1).
6403dd3407eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   803
    outStream nextPut:t1.  "/ flag
6403dd3407eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   804
    outStream nextPut:0.   "/ background (not used)
6403dd3407eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   805
    outStream nextPut:0.   "/ aspect ratio
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   806
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   807
    n := 0.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   808
    image colorMap notNil ifTrue:[
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   809
        image colorMap do:[:clr |
712
6403dd3407eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   810
            |red green blue|
6403dd3407eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   811
6403dd3407eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   812
            clr isNil ifTrue:[
6403dd3407eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   813
                "/ unused colorMap slot
6403dd3407eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   814
                red := green := blue := 0.
6403dd3407eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   815
            ] ifFalse:[
6403dd3407eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   816
                red := (clr redByte).
6403dd3407eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   817
                green := (clr greenByte).
6403dd3407eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   818
                blue := (clr blueByte).
6403dd3407eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   819
            ].
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   820
            outStream
712
6403dd3407eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   821
                nextPut:red; nextPut:green; nextPut:blue.
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   822
            n := n + 1.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   823
        ]
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   824
    ].
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   825
    n+1 to:(1 bitShift:bitsPerPixel) do:[:i |
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   826
        outStream nextPut:0; nextPut:0; nextPut:0
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   827
    ].
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   828
    outStream nextPut:ImageSeparator.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   829
    self writeShort:0.       "/
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   830
    self writeShort:0.       "/
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   831
    self writeShort:width.   "/ image size
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   832
    self writeShort:height.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   833
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   834
    interlace == true ifTrue:[
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   835
        t1 := 64
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   836
    ] ifFalse:[
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   837
        t1 := 0
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   838
    ].
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   839
    outStream nextPut:t1       "/ another flag
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   840
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   841
    "Created: 14.10.1997 / 17:41:28 / cg"
712
6403dd3407eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   842
    "Modified: 15.10.1997 / 19:54:30 / cg"
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   843
! !
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   844
339
9b4ece782f6a removed an infoPrint.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   845
!GIFReader class methodsFor:'documentation'!
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   846
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   847
version
712
6403dd3407eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   848
    ^ '$Header: /cvs/stx/stx/libview2/GIFReader.st,v 1.59 1997-10-15 17:58:09 cg Exp $'
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   849
! !
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   850
GIFReader initialize!