GIFReader.st
author Claus Gittinger <cg@exept.de>
Thu, 02 Jan 2020 11:31:34 +0100
changeset 4414 224e93713033
parent 4374 9ee6defe2909
child 4450 c07db2570587
permissions -rw-r--r--
#DOCUMENTATION by exept class: RIFFReader class comment/format in: #documentation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4105
c1a6b872831b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3902
diff changeset
     1
"{ Encoding: utf8 }"
c1a6b872831b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3902
diff changeset
     2
0
3f9277473954 Initial revision
claus
parents:
diff changeset
     3
"
6
4ac87e6bf82f *** empty log message ***
claus
parents: 5
diff changeset
     4
 COPYRIGHT (c) 1991 by Claus Gittinger
26
2fe6294ca833 *** empty log message ***
claus
parents: 25
diff changeset
     5
	      All Rights Reserved
0
3f9277473954 Initial revision
claus
parents:
diff changeset
     6
3f9277473954 Initial revision
claus
parents:
diff changeset
     7
 This software is furnished under a license and may be used
3f9277473954 Initial revision
claus
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
3f9277473954 Initial revision
claus
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
3f9277473954 Initial revision
claus
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
3f9277473954 Initial revision
claus
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
3f9277473954 Initial revision
claus
parents:
diff changeset
    12
 hereby transferred.
3f9277473954 Initial revision
claus
parents:
diff changeset
    13
"
1393
abed635fb3ce convert non-depth8 images when trying to save
Claus Gittinger <cg@exept.de>
parents: 1313
diff changeset
    14
"{ Package: 'stx:libview2' }"
abed635fb3ce convert non-depth8 images when trying to save
Claus Gittinger <cg@exept.de>
parents: 1313
diff changeset
    15
3468
d0a6fa0e6b5f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3392
diff changeset
    16
"{ NameSpace: Smalltalk }"
d0a6fa0e6b5f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3392
diff changeset
    17
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    18
ImageReader subclass:#GIFReader
1739
971f1a3970a3 refactorings
Claus Gittinger <cg@exept.de>
parents: 1711
diff changeset
    19
	instanceVariableNames:'pass xpos ypos rowByteSize remainBitCount bufByte bufStream
971f1a3970a3 refactorings
Claus Gittinger <cg@exept.de>
parents: 1711
diff changeset
    20
		prefixTable suffixTable clearCode eoiCode freeCode codeSize
971f1a3970a3 refactorings
Claus Gittinger <cg@exept.de>
parents: 1711
diff changeset
    21
		maxCode interlace frameDelay iterationCount leftOffs topOffs'
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
    22
	classVariableNames:'ImageSeparator Extension Terminator'
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
    23
	poolDictionaries:''
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1739
diff changeset
    24
	category:'Graphics-Images-Readers'
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    25
!
3f9277473954 Initial revision
claus
parents:
diff changeset
    26
339
9b4ece782f6a removed an infoPrint.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
    27
!GIFReader class methodsFor:'documentation'!
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    28
21
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    29
copyright
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    30
"
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    31
 COPYRIGHT (c) 1991 by Claus Gittinger
26
2fe6294ca833 *** empty log message ***
claus
parents: 25
diff changeset
    32
	      All Rights Reserved
21
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    33
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    34
 This software is furnished under a license and may be used
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    35
 only in accordance with the terms of that license and with the
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    36
 inclusion of the above copyright notice.   This software may not
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    37
 be provided or otherwise made available to, or used by, any
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    38
 other person.  No title to or ownership of the software is
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    39
 hereby transferred.
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    40
"
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    41
!
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    42
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    43
documentation
3f9277473954 Initial revision
claus
parents:
diff changeset
    44
"
3f9277473954 Initial revision
claus
parents:
diff changeset
    45
    this class provides methods for loading and saving GIF pictures.
3775
d044932c0154 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3689
diff changeset
    46
    It has been tested with some different GIF87a pictures, I don't
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    47
    know, if it works with other GIF versions.
3f9277473954 Initial revision
claus
parents:
diff changeset
    48
    GIF extension blocks are not handled.
3f9277473954 Initial revision
claus
parents:
diff changeset
    49
21
66b31c91177f *** empty log message ***
claus
parents: 20
diff changeset
    50
    legal stuff extracted from GIF87a documentation:
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    51
3f9277473954 Initial revision
claus
parents:
diff changeset
    52
    CompuServe Incorporated hereby grants a limited, non-exclusive, royalty-free
3f9277473954 Initial revision
claus
parents:
diff changeset
    53
    license for the use of the Graphics Interchange Format(sm) in computer
3f9277473954 Initial revision
claus
parents:
diff changeset
    54
    software; computer software utilizing GIF(sm) must acknowledge ownership of the
3f9277473954 Initial revision
claus
parents:
diff changeset
    55
    Graphics Interchange Format and its Service Mark by CompuServe Incorporated, in
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
    56
    User and Technical Documentation.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    57
3f9277473954 Initial revision
claus
parents:
diff changeset
    58
      The Graphics Interchange Format(c) is the Copyright property of
3f9277473954 Initial revision
claus
parents:
diff changeset
    59
      CompuServe Incorporated. GIF(sm) is a Service Mark property of
3f9277473954 Initial revision
claus
parents:
diff changeset
    60
      CompuServe Incorporated.
194
d4ecb23d7163 commentary
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
    61
3120
ed7676f65f22 class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3119
diff changeset
    62
    Notice:
3775
d044932c0154 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3689
diff changeset
    63
        there has been some annoyance regarding a patent on the compression algorithm
3902
54d503c6e50b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3901
diff changeset
    64
        used in gif. There is no warranty from exept, regarding any legal problems, when using GIF.
54d503c6e50b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3901
diff changeset
    65
        We therefore highly recommend to use newer (and especially: royalty-free) formats, such as PNG.
54d503c6e50b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3901
diff changeset
    66
54d503c6e50b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3901
diff changeset
    67
        This patent is now obsolete: 
54d503c6e50b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3901
diff changeset
    68
            The United States LZW patent expired on 20 June 2003. 
54d503c6e50b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3901
diff changeset
    69
            The counterpart patents in the United Kingdom, France, Germany and Italy 
54d503c6e50b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3901
diff changeset
    70
            expired on 18 June 2004, the Japanese patents expired on 20 June 2004, 
54d503c6e50b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3901
diff changeset
    71
            and the Canadian patent expired on 7 July 2004.
54d503c6e50b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3901
diff changeset
    72
            Consequently, the GIF format may now be used freely.
3120
ed7676f65f22 class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3119
diff changeset
    73
194
d4ecb23d7163 commentary
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
    74
    [See also:]
3775
d044932c0154 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3689
diff changeset
    75
        Image Form Icon
4105
c1a6b872831b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3902
diff changeset
    76
        BlitImageReader FaceReader JPEGReader MacOSXIconReader
c1a6b872831b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3902
diff changeset
    77
        PBMReader PCXReader PNGReader
3775
d044932c0154 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3689
diff changeset
    78
        ST80FormReader SunRasterReader TargaReader TIFFReader WindowsIconReader
d044932c0154 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3689
diff changeset
    79
        XBMReader XPMReader XWDReader
220
4106d9ce7e02 documentation
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    80
4106d9ce7e02 documentation
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    81
    [author:]
3775
d044932c0154 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3689
diff changeset
    82
        Claus Gittinger
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    83
"
3283
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
    84
!
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
    85
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
    86
examples
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
    87
"
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
    88
    saving an animated gif sequence:
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
    89
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
    90
     a view showing rainfall:
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
    91
										[exBegin]
3284
b2302e748434 class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3283
diff changeset
    92
    |BG CLR N1 H W v WIND drops gen newDrops draw remove move buffer|
3283
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
    93
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
    94
    BG := Color black.
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
    95
    CLR := Color blue lightened.
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
    96
    H := 100.
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
    97
    W := 100.
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
    98
    N1 := 10.
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
    99
    WIND := 0.
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   100
    drops := OrderedCollection new.
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   101
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   102
    gen := [:n | ((1 to:n) collect:[:i | Random nextIntegerBetween:1 and:W] as:Set) collect:[:x | x@0]].
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   103
    newDrops := [drops addAll:(gen value:N1)].
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   104
    draw := [buffer fill:BG; paint:CLR. drops do:[:d | buffer displayPoint:d]].
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   105
    remove := [drops := drops reject:[:d | d y > H]].
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   106
    move := [:wind | drops := drops collect:[:d| (d x + wind)\\W @ (d y + 1)]].
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   107
    v := View new openAndWait.
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   108
    buffer := Form extent:(v extent) depth:24 onDevice:v device.
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   109
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   110
    [
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   111
	[v shown] whileTrue:[
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   112
	    draw value.
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   113
	    v displayForm:buffer.
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   114
	    move value:WIND.
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   115
	    remove value.
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   116
	    newDrops value.
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   117
	    WIND := (WIND+(Random nextBetween:-1 and:1)) clampBetween:-5 and:5.
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   118
	    Delay waitForSeconds:0.1.
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   119
	]
3283
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   120
    ] fork.
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   121
										[exEnd]
3283
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   122
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   123
   saving those images:
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   124
										[exBegin]
3283
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   125
    |seq img BG CLR N1 H W v drops gen gen1 buffer|
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   126
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   127
    BG := Color black.
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   128
    CLR := Color blue lightened.
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   129
    H := 100.
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   130
    W := 100.
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   131
    N1 := 10.
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   132
    WIND := 0.
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   133
    drops := OrderedCollection new.
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   134
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   135
    gen := [:n | ((1 to:n) collect:[:i | Random nextIntegerBetween:1 and:W] as:Set) collect:[:x | x@0]].
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   136
    newDrops := [drops addAll:(gen value:N1)].
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   137
    draw := [buffer fill:BG; paint:CLR. drops do:[:d | buffer displayPoint:d]].
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   138
    remove := [drops := drops reject:[:d | d y > H]].
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   139
    move := [:wind | drops := drops collect:[:d| (d x + wind)\\W @ (d y + 1)]].
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   140
    buffer := Form extent:W@H depth:8 onDevice:Display.
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   141
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   142
    seq := OrderedCollection new.
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   143
    500 timesRepeat:[
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   144
	move value:WIND.
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   145
	remove value.
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   146
	newDrops value.
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   147
	draw value.
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   148
	seq add:(ImageFrame new delay:100; image:(Depth8Image fromForm:buffer)).
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   149
	WIND := (WIND+(Random nextBetween:-1 and:1)) clampBetween:-5 and:5.
3283
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   150
    ].
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   151
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   152
    img := seq first image.
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   153
    img imageSequence:(seq copyFrom:2).
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   154
    img imageSequence do:[:each | each image colorMap:img colorMap].
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   155
    GIFReader save:img onFile:'/tmp/img.gif'
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   156
										[exEnd]
3283
e32b39c8647f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3282
diff changeset
   157
"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   158
! !
3f9277473954 Initial revision
claus
parents:
diff changeset
   159
339
9b4ece782f6a removed an infoPrint.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   160
!GIFReader class methodsFor:'initialization'!
26
2fe6294ca833 *** empty log message ***
claus
parents: 25
diff changeset
   161
2fe6294ca833 *** empty log message ***
claus
parents: 25
diff changeset
   162
initialize
198
6d76856aaa80 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   163
    "install myself in the Image classes fileFormat table
398
aef700d15416 new suffix-table
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   164
     for the `.gif' extensions."
3468
d0a6fa0e6b5f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3392
diff changeset
   165
    
d0a6fa0e6b5f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3392
diff changeset
   166
    ImageSeparator isNil ifTrue:[
d0a6fa0e6b5f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3392
diff changeset
   167
        ImageSeparator := $, codePoint.
d0a6fa0e6b5f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3392
diff changeset
   168
        Extension := $!! codePoint.
d0a6fa0e6b5f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3392
diff changeset
   169
        Terminator := $; codePoint.
198
6d76856aaa80 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   170
3468
d0a6fa0e6b5f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3392
diff changeset
   171
        MIMETypes defineImageType:'image/gif' suffix:'gif' reader:self.
d0a6fa0e6b5f class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3392
diff changeset
   172
    ].
198
6d76856aaa80 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   173
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
   174
    "Modified: 14.10.1997 / 18:47:27 / cg"
26
2fe6294ca833 *** empty log message ***
claus
parents: 25
diff changeset
   175
! !
2fe6294ca833 *** empty log message ***
claus
parents: 25
diff changeset
   176
339
9b4ece782f6a removed an infoPrint.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   177
!GIFReader class methodsFor:'testing'!
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   178
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   179
canRepresent:anImage
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   180
    "return true, if anImage can be represented in my file format.
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   181
     GIF supports depth 8 images only."
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   182
1521
3c54279a418c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1429
diff changeset
   183
    anImage depth == 8 ifTrue:[^ true].
3573
7df429deaf89 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 3553
diff changeset
   184
    ('GIFReader [info]: image depth is not 8.') infoPrintCR.
2030
cfe668c44a8c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1952
diff changeset
   185
    ^ false.
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   186
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   187
    "Created: 17.10.1997 / 20:19:20 / cg"
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   188
!
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
   189
4348
6113e0a7959c #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4341
diff changeset
   190
hasValidImageHeader:someHeaderBytes
6113e0a7959c #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4341
diff changeset
   191
    "return true, if someHeaderBytes 
6113e0a7959c #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4341
diff changeset
   192
     (which does not need to be the whole data, but large enough
6113e0a7959c #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4341
diff changeset
   193
      to detect the header) contains a valid GIF image header"
6113e0a7959c #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4341
diff changeset
   194
6113e0a7959c #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4341
diff changeset
   195
    |id|
6113e0a7959c #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4341
diff changeset
   196
6113e0a7959c #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4341
diff changeset
   197
    id := (someHeaderBytes copyFrom:1 to:6) asString.
6113e0a7959c #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4341
diff changeset
   198
    (id = 'GIF87a') ifFalse:[
6113e0a7959c #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4341
diff changeset
   199
        id = 'GIF89a' ifFalse:[
6113e0a7959c #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4341
diff changeset
   200
            (id startsWith:'GIF') ifFalse:[^ false].
6113e0a7959c #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4341
diff changeset
   201
            'GIFReader [info]: not a GIF87a/GIF89a file - hope that works' infoPrintCR.
6113e0a7959c #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4341
diff changeset
   202
        ]
6113e0a7959c #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4341
diff changeset
   203
    ].
6113e0a7959c #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4341
diff changeset
   204
    ^ true
6113e0a7959c #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4341
diff changeset
   205
6113e0a7959c #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4341
diff changeset
   206
    "Modified: 10.1.1997 / 15:40:34 / cg"
6113e0a7959c #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4341
diff changeset
   207
!
6113e0a7959c #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4341
diff changeset
   208
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   209
isValidImageFile:aFileName
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   210
    "return true, if aFileName contains a GIF image"
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   211
4348
6113e0a7959c #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4341
diff changeset
   212
    |someBytes inStream|
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   213
9
415b0178ecba *** empty log message ***
claus
parents: 6
diff changeset
   214
    inStream := self streamReadingFile:aFileName.
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   215
    inStream isNil ifTrue:[^ false].
4348
6113e0a7959c #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 4341
diff changeset
   216
    someBytes := inStream nextBytes:6.
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   217
    inStream close.
4374
9ee6defe2909 #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 4348
diff changeset
   218
    ^ (someBytes size == 6) and:[self hasValidImageHeader:someBytes]
9ee6defe2909 #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 4348
diff changeset
   219
9ee6defe2909 #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 4348
diff changeset
   220
    "
9ee6defe2909 #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 4348
diff changeset
   221
     GIFReader isValidImageFile:'../../goodies/bitmaps/gifImages/a.gif'
9ee6defe2909 #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 4348
diff changeset
   222
     GIFReader isValidImageFile:'../../goodies/bitmaps/gifImages/garfield.gif' 
9ee6defe2909 #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 4348
diff changeset
   223
     GIFReader isValidImageFile:'fooBar'    
9ee6defe2909 #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 4348
diff changeset
   224
     GIFReader isValidImageFile:'../../goodies/bitmaps/xpmBitmaps/device_images/ljet.xpm'      
9ee6defe2909 #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 4348
diff changeset
   225
    "
174
7fafcc56378d nicer message
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   226
355
05eb4e183394 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   227
    "Modified: 10.1.1997 / 15:40:34 / cg"
1
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   228
! !
6fe019b6ea79 *** empty log message ***
claus
parents: 0
diff changeset
   229
2694
54871b04e18f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   230
!GIFReader methodsFor:'image reading'!
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   231
2596
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   232
fromStream:aStream
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   233
    "read a stream containing a GIF image (or an image sequence).
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   234
     Leave image description in instance variables."
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   235
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   236
    |byte flag fileColorMap
2596
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   237
     colorMapSize bitsPerPixel scrWidth scrHeight
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   238
     hasColorMap interlaced id
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   239
     isGif89 atEnd
2596
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   240
     img firstImage firstOffset firstFrameDelay frame imageCount|
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   241
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   242
    inStream := aStream.
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   243
    aStream binary.
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   244
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   245
    "GIF-files are always lsb (intel-world)"
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   246
    byteOrder := #lsb.
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   247
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   248
    id := ByteArray new:6.
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   249
    (aStream nextBytes:6 into:id startingAt:1) ~~ 6 ifTrue:[
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   250
        ^ self fileFormatError:'not a gif file (short read)'.
2596
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   251
    ].
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   252
    id := id asString.
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   253
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   254
    "all I had for testing where GIF87a files;
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   255
     I hope later versions work too ..."
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   256
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   257
    isGif89 := false.
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   258
    (id ~= 'GIF87a') ifTrue:[
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   259
        (id startsWith:'GIF') ifFalse:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   260
            ^ self fileFormatError:('not a gif file (id=''' , id , ''')').
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   261
        ].
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   262
        id ~= 'GIF89a' ifTrue:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   263
            'GIFReader [info]: not a GIF87a/GIF89a file - hope that works' infoPrintCR.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   264
        ]
2596
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   265
    ].
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   266
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   267
    "get screen dimensions (not used)"
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   268
    scrWidth := aStream nextInt16MSB:false.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   269
    scrHeight := aStream nextInt16MSB:false.
2596
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   270
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   271
    "get flag byte"
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   272
    flag := aStream nextByte.
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   273
    hasColorMap :=      (flag bitAnd:2r10000000) ~~ 0.
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   274
    "bitsPerRGB :=     ((flag bitAnd:2r01110000) bitShift:-4) + 1. "
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   275
    "colorMapSorted := ((flag bitAnd:2r00001000) ~~ 0.             "
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   276
    bitsPerPixel :=     (flag bitAnd:2r00000111) + 1.
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   277
    colorMapSize := 1 bitShift:bitsPerPixel.
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   278
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   279
    "get background (not used)"
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   280
    aStream nextByte.
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   281
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   282
    "aspect ratio (not used)"
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   283
    aStream nextByte.
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   284
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   285
    "get colorMap"
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   286
    hasColorMap ifTrue:[
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   287
        fileColorMap := self readColorMap:colorMapSize.
2596
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   288
    ].
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   289
    colorMap := fileColorMap.
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   290
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   291
    photometric := #palette.
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   292
    samplesPerPixel := 1.
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   293
    bitsPerSample := #(8).
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   294
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   295
    imageCount := 0.
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   296
    atEnd := false.
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   297
    [atEnd] whileFalse:[
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   298
        "gif89a extensions"
2596
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   299
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   300
        byte := aStream nextByte.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   301
        byte isNil ifTrue:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   302
            "/ atEnd-Terminator missing
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   303
            atEnd := true
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   304
        ] ifFalse:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   305
            byte == Extension ifTrue:[
3901
f2c56662a45e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3849
diff changeset
   306
                "/ 'Ext' infoPrintCR.
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   307
                self readExtension:aStream.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   308
            ] ifFalse:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   309
                (byte == Terminator) ifTrue:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   310
                    atEnd := true
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   311
                ] ifFalse:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   312
                    "must be image separator"
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   313
                    (byte ~~ ImageSeparator) ifTrue:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   314
                        ^ self fileFormatError:('corrupted gif file (no IMAGESEP): ' , (byte printStringRadix:16)).
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   315
                    ].
3901
f2c56662a45e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3849
diff changeset
   316
                    "/ 'Img' infoPrintCR.
2596
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   317
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   318
                    fileColorMap notNil ifTrue:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   319
                        colorMap := fileColorMap.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   320
                    ].
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   321
                    Object primitiveFailureSignal handle:[:ex |
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   322
                        ^ self fileFormatError:('corrupted gif file').
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   323
                    ] do:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   324
                        self readImage:aStream.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   325
                    ].
2596
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   326
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   327
                    maskPixel notNil ifTrue:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   328
                        "/
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   329
                        "/ ok, there is a maskValue
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   330
                        "/ build a Depth1Image for it.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   331
                        "/
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   332
                        self buildMaskFromColor:maskPixel
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   333
                    ].
2596
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   334
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   335
                    imageCount == 0 ifTrue:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   336
                        img := self makeImage.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   337
                        "/ remember first image in case more come later.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   338
                        firstImage := img.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   339
                        firstFrameDelay := frameDelay.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   340
                        firstOffset := (leftOffs @ topOffs).
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   341
                    ] ifFalse:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   342
                        imageCount == 1 ifTrue:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   343
                            imageSequence := ImageSequence new.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   344
                            img imageSequence:imageSequence.
2596
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   345
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   346
                            "/ add frame for first image.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   347
                            frame := ImageFrame new image:firstImage.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   348
                            frame delay:firstFrameDelay.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   349
                            frame offset:firstOffset.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   350
                            imageSequence add:frame.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   351
                        ].
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   352
                        img := self makeImage.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   353
                        img imageSequence:imageSequence.
2596
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   354
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   355
                        "/ add frame for this image.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   356
                        frame := ImageFrame new image:img.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   357
                        frame delay:frameDelay.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   358
                        frame offset:(leftOffs @ topOffs).
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   359
                        imageSequence add:frame.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   360
                    ].
2596
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   361
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   362
                    imageCount := imageCount + 1.
2596
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   363
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   364
                    frameDelay := nil.
2596
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   365
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   366
                    aStream atEnd ifTrue:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   367
                        atEnd := true.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   368
                    ]
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   369
                ]
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   370
            ].
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   371
        ].
2596
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   372
    ].
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   373
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   374
    imageSequence notNil ifTrue:[
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   375
        iterationCount notNil ifTrue:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   376
            iterationCount == 0 ifTrue:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   377
                imageSequence loop:true.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   378
            ] ifFalse:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   379
                imageSequence loop:false.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   380
                imageSequence iterationCount:iterationCount.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   381
            ]
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   382
        ]
2596
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   383
    ].
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   384
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   385
    "
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   386
     Image fromFile:'/home/cg/work/stx/goodies/bitmaps/gifImages/animated/vrml.gif'
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   387
     Image fromFile:'/home/cg/work/stx/goodies/bitmaps/gifImages/animated/arrow.gif'
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   388
    "
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   389
3901
f2c56662a45e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3849
diff changeset
   390
    "Modified: / 05-07-1996 / 17:32:01 / stefan"
f2c56662a45e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3849
diff changeset
   391
    "Modified: / 21-08-1998 / 22:20:00 / cg"
f2c56662a45e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3849
diff changeset
   392
    "Modified (format): / 17-02-2017 / 12:29:10 / cg"
2694
54871b04e18f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   393
! !
54871b04e18f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   394
54871b04e18f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   395
!GIFReader methodsFor:'private-reading'!
54871b04e18f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   396
54871b04e18f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   397
makeGreyscale
54871b04e18f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   398
    "not yet implemented/needed"
54871b04e18f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   399
!
54871b04e18f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   400
54871b04e18f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   401
readColorMap:colorMapSize
54871b04e18f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   402
    "get a gif colormap consisting of colorMapSize entries"
54871b04e18f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   403
54871b04e18f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   404
    |rgbVector|
54871b04e18f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   405
54871b04e18f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   406
    rgbVector := inStream nextBytes:colorMapSize*3.
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   407
    ^ MappedPalette rgbBytesVector:rgbVector
2596
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   408
!
da5ad69ff368 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   409
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   410
readExtension:aStream
882
2913420cab5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 809
diff changeset
   411
    "get gif89 extension"
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   412
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   413
    |type blockSize subBlockSize
304
c8078fb77706 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
   414
     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
   415
     animationType animationTime animationMask
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   416
     appID appAUTH
888
69628f75a4b8 fixed imageSequence reading
Claus Gittinger <cg@exept.de>
parents: 882
diff changeset
   417
     b ok|
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   418
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   419
    type := aStream nextByte.
1952
5009754ae556 Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents: 1846
diff changeset
   420
    type == $R codePoint ifTrue:[
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   421
        "/
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   422
        "/ Ratio extension
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   423
        "/
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   424
        "/ 'GIFREADER [info]: ratio extension ignored' infoPrintCR.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   425
        blockSize := aStream nextByte.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   426
        (blockSize == 2) ifTrue:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   427
            aspNum := aStream nextByte.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   428
            aspDen := aStream nextByte
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   429
        ] ifFalse:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   430
            aStream skip:blockSize
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   431
        ].
2844
ce205334bcdc changed: #readExtension:
Claus Gittinger <cg@exept.de>
parents: 2694
diff changeset
   432
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   433
        "/ eat subblocks
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   434
        [(subBlockSize := aStream nextByte) > 0] whileTrue:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   435
            aStream skip:subBlockSize
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   436
        ].
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   437
        ^ self
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   438
    ].
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   439
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   440
    type == 16r01 ifTrue:[
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   441
        "/
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   442
        "/ plaintext extension
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   443
        "/
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   444
        "/ 'GIFREADER [info]: plaintext extension ignored' infoPrintCR.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   445
        subBlockSize := aStream nextByte.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   446
        left := aStream nextInt16MSB:false.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   447
        top := aStream nextInt16MSB:false.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   448
        width := aStream nextInt16MSB:false.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   449
        height := aStream nextInt16MSB:false.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   450
        cWidth := aStream nextByte.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   451
        cHeight := aStream nextByte.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   452
        fg := aStream nextByte.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   453
        bg := aStream nextByte.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   454
        aStream skip:12.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   455
        "/ eat subblocks
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   456
        [(subBlockSize := aStream nextByte) > 0] whileTrue:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   457
            aStream skip:subBlockSize
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   458
        ].
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   459
        ^ self
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   460
    ].
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   461
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   462
    type == 16rF9 ifTrue:[
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   463
        "/
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   464
        "/ graphic control extension
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   465
        "/
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   466
        "/ 'GIFREADER [info]: graphic control extension' infoPrintCR.
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   467
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   468
        [(subBlockSize := aStream nextByte) ~~ 0 and:[subBlockSize notNil]] whileTrue:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   469
            "/ type bitAnd:1 means: animationMask is transparent pixel
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   470
            "/ to be implemented in Image ...
305
0edebf4ecaa7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   471
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   472
            animationType := aStream nextByte.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   473
            animationTime := aStream nextInt16MSB:false.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   474
            animationMask := aStream nextByte.
2595
37dc71e1e59b be tolerant to corrupted gif files (subblock size in extension)
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
   475
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   476
            subBlockSize := subBlockSize - 4.
307
9eaeaca798a5 create a mask-image, if present
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   477
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   478
           (animationType bitTest: 1) ifTrue:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   479
                maskPixel := animationMask.
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   480
"/                'GIFREADER [info]: mask: ' infoPrint. (maskPixel printStringRadix:16) infoPrintCR.
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   481
            ].
670
6a7f628ee66c oops - mask was only set for interlaced images (stupid typo)
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   482
"/            'GIFREADER [info]: animationTime: ' infoPrint. (animationTime * (1/100)) infoPrintCR.
1429
28c9e0f9d239 remember offsets in imageSequences
martin
parents: 1393
diff changeset
   483
"/            'GIFREADER [info]: animationType: ' infoPrint. (animationType) infoPrintCR.
28c9e0f9d239 remember offsets in imageSequences
martin
parents: 1393
diff changeset
   484
"/            'GIFREADER [info]: animationMask: ' infoPrint. (animationMask) infoPrintCR.
307
9eaeaca798a5 create a mask-image, if present
Claus Gittinger <cg@exept.de>
parents: 305
diff changeset
   485
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   486
            frameDelay := (animationTime * (1/100)) * 1000.
888
69628f75a4b8 fixed imageSequence reading
Claus Gittinger <cg@exept.de>
parents: 882
diff changeset
   487
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   488
            subBlockSize ~~ 0 ifTrue:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   489
                aStream skip:subBlockSize
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   490
            ].
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   491
        ].
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   492
        ^ self
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   493
    ].
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   494
519
1ee56341ef50 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   495
    type == 16rFE ifTrue:[
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   496
        "/
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   497
        "/ comment extension
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   498
        "/
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   499
        "/ 'GIFREADER [info]: comment extension' infoPrintCR.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   500
        [(blockSize := aStream nextByte) ~~ 0] whileTrue:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   501
            aStream skip:blockSize
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   502
        ].
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   503
        ^ self
519
1ee56341ef50 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   504
    ].
1ee56341ef50 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   505
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   506
    type == 16rFF ifTrue:[
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   507
        "/
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   508
        "/  application extension
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   509
        "/
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   510
        "/ 'GIFREADER [info]: application extension' infoPrintCR.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   511
        subBlockSize := aStream nextByte.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   512
        appID := (aStream nextBytes:8 ) asString.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   513
        appAUTH := aStream nextBytes:3.
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   514
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   515
        subBlockSize := aStream nextByte.
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   516
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   517
        ok := false.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   518
        appID = 'NETSCAPE' ifTrue:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   519
            appAUTH asString = '2.0' ifTrue:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   520
                subBlockSize == 3 ifTrue:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   521
                    b := aStream nextByte.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   522
                    iterationCount := aStream nextInt16MSB:false.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   523
                    subBlockSize := aStream nextByte.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   524
                    ok := true.
888
69628f75a4b8 fixed imageSequence reading
Claus Gittinger <cg@exept.de>
parents: 882
diff changeset
   525
"/                    ('GIFREADER [info]: NETSCAPE application extension - iterationCount = ') infoPrint.
69628f75a4b8 fixed imageSequence reading
Claus Gittinger <cg@exept.de>
parents: 882
diff changeset
   526
"/                    iterationCount infoPrintCR.
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   527
                ]
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   528
            ]
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   529
        ].
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   530
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   531
        ok ifFalse:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   532
            ('GIFREADER [info]: application extension (' , appID , ') ignored') infoPrintCR.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   533
        ].
625
72c766a86a0e less info printing
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   534
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   535
        [subBlockSize > 0] whileTrue:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   536
            aStream skip:subBlockSize.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   537
            subBlockSize := aStream nextByte.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   538
        ].
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   539
        ^ self
618
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   540
    ].
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   541
ab83e72fd105 support multiple images (animated gif)
Claus Gittinger <cg@exept.de>
parents: 563
diff changeset
   542
    type == 16r2C ifTrue:[
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   543
        "/
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   544
        "/  image descriptor extension
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   545
        "/
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   546
        "/ 'GIFREADER [info]: image descriptor extension ignored' infoPrintCR.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   547
        [(subBlockSize := aStream nextByte) > 0] whileTrue:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   548
            aStream skip:subBlockSize
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   549
        ].
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   550
        ^ self
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   551
    ].
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   552
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   553
    "/
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   554
    "/ unknown extension
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   555
    "/
354
b4d2ce853c24 stefans suggested info/warning/error/fatal
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   556
    'GIFREADER [info]: unknown extension ignored' infoPrintCR.
239
208108f3c707 comments
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
   557
    [(subBlockSize := aStream nextByte) > 0] whileTrue:[
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   558
        aStream skip:subBlockSize
154
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   559
    ]
40bbc62e8d78 added GIF89a support
Claus Gittinger <cg@exept.de>
parents: 136
diff changeset
   560
2844
ce205334bcdc changed: #readExtension:
Claus Gittinger <cg@exept.de>
parents: 2694
diff changeset
   561
    "Modified: / 02-06-2010 / 12:21:53 / cg"
757
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   562
!
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   563
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   564
readImage:aStream
882
2913420cab5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 809
diff changeset
   565
    "read a single image from aStream."
2913420cab5a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 809
diff changeset
   566
1429
28c9e0f9d239 remember offsets in imageSequences
martin
parents: 1393
diff changeset
   567
    | flag interlaced hasLocalColorMap bitsPerPixel colorMapSize
757
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   568
     codeLen compressedData compressedSize index count h tmp srcOffset dstOffset
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   569
     initialBuffSize|
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   570
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   571
    "get image data"
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   572
    leftOffs := aStream nextInt16MSB:false.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   573
    topOffs := aStream nextInt16MSB:false.
3901
f2c56662a45e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3849
diff changeset
   574
    "/    'GIFReader: leftOffs ' infoPrint. leftOffs infoPrintCR.
f2c56662a45e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3849
diff changeset
   575
    "/    'GIFReader: topOffs ' infoPrint. topOffs infoPrintCR.
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   576
    width := aStream nextInt16MSB:false.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   577
    height := aStream nextInt16MSB:false.
757
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   578
1846
d29322944b05 dimensionReport
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
   579
    self reportDimension.
757
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   580
3901
f2c56662a45e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3849
diff changeset
   581
    "/
f2c56662a45e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3849
diff changeset
   582
    "/    'width ' print. width printNewline.
f2c56662a45e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3849
diff changeset
   583
    "/    'height ' print. height printNewline.
f2c56662a45e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3849
diff changeset
   584
    "/
757
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   585
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   586
    "another flag byte"
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   587
    flag := aStream nextByte.
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   588
    interlaced :=           (flag bitAnd:2r01000000) ~~ 0.
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   589
    hasLocalColorMap :=     (flag bitAnd:2r10000000) ~~ 0.
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   590
    "localColorMapSorted := (flag bitAnd:2r00100000) ~~ 0.      "
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   591
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   592
    "if image has a local colormap, this one is used"
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   593
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   594
    hasLocalColorMap ifTrue:[
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   595
        "local descr. overwrites"
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   596
        bitsPerPixel := (flag bitAnd:2r00000111) + 1.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   597
        colorMapSize := 1 bitShift:bitsPerPixel.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   598
        "overwrite colormap"
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   599
        colorMap := self readColorMap:colorMapSize.
757
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   600
    ].
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   601
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   602
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   603
    "get codelen for decompression"
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   604
    codeLen := aStream nextByte.
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   605
    (aStream respondsTo:#fileSize) ifTrue:[
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   606
        initialBuffSize := aStream fileSize.
757
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   607
    ] ifFalse:[
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   608
        initialBuffSize := 512.
757
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   609
    ].
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   610
    compressedData := ByteArray uninitializedNew:initialBuffSize.
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   611
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   612
    "get compressed data"
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   613
    index := 1.
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   614
    count := aStream nextByte.
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   615
    [count notNil and:[count ~~ 0]] whileTrue:[
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   616
        (compressedData size < (index+count)) ifTrue:[
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   617
            |t|
757
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   618
3784
3f67fdf386bd #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3775
diff changeset
   619
            t := ByteArray uninitializedNew:((index+count)*3//2).
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   620
            t replaceBytesFrom:1 to:index-1 with:compressedData startingAt:1.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   621
            compressedData := t.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   622
        ].
757
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   623
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   624
        aStream nextBytes:count into:compressedData startingAt:index blockSize:4096.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   625
        index := index + count.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   626
        count := aStream nextByte
757
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   627
    ].
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   628
    compressedSize := index - 1.
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   629
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   630
    h := height.
1037
90d38c8e3f5f use initialized byteArrays, in case rows are padded
Claus Gittinger <cg@exept.de>
parents: 891
diff changeset
   631
    data := ByteArray new:((width + 1) * (h + 1)).
3901
f2c56662a45e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3849
diff changeset
   632
    "/    'GIFReader: decompressing ...' infoPrintCR.
757
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   633
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   634
    self class decompressGIFFrom:compressedData
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   635
                           count:compressedSize
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   636
                            into:data
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   637
                      startingAt:1
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   638
                         codeLen:(codeLen + 1).
757
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   639
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   640
    interlaced ifTrue:[
3901
f2c56662a45e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3849
diff changeset
   641
    "/    'GIFREADER: deinterlacing ...' infoPrintCR.
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   642
        tmp := ByteArray new:(data size).
757
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   643
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   644
        "phase 1: 0, 8, 16, 24, ..."
757
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   645
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   646
        srcOffset := 1.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   647
        0 to:(h - 1) by:8 do:[:dstRow |
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   648
            dstOffset := dstRow * width + 1.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   649
            tmp replaceFrom:dstOffset to:(dstOffset + width - 1)
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   650
                       with:data startingAt:srcOffset.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   651
            srcOffset := srcOffset + width.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   652
        ].
757
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   653
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   654
        "phase 2: 4, 12, 20, 28, ..."
757
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   655
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   656
        4 to:(h - 1) by:8 do:[:dstRow |
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   657
            dstOffset := dstRow * width + 1.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   658
            tmp replaceFrom:dstOffset to:(dstOffset + width - 1)
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   659
                       with:data startingAt:srcOffset.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   660
            srcOffset := srcOffset + width.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   661
        ].
757
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   662
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   663
        "phase 3: 2, 6, 10, 14, ..."
757
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   664
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   665
        2 to:(h - 1) by:4 do:[:dstRow |
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   666
            dstOffset := dstRow * width + 1.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   667
            tmp replaceFrom:dstOffset to:(dstOffset + width - 1)
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   668
                       with:data startingAt:srcOffset.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   669
            srcOffset := srcOffset + width.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   670
        ].
757
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   671
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   672
        "phase 4: 1, 3, 5, 7, ..."
757
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   673
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   674
        1 to:(h - 1) by:2 do:[:dstRow |
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   675
            dstOffset := dstRow * width + 1.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   676
            tmp replaceFrom:dstOffset to:(dstOffset + width - 1)
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   677
                       with:data startingAt:srcOffset.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   678
            srcOffset := srcOffset + width.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   679
        ].
757
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   680
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   681
        data := tmp.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   682
        tmp := nil.
757
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   683
    ].
094c6c7c4ce6 extracted raw image reading (i.e. after header & extensions have been read)
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   684
3784
3f67fdf386bd #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3775
diff changeset
   685
    "Created: / 13-01-1998 / 10:44:05 / cg"
3f67fdf386bd #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3775
diff changeset
   686
    "Modified: / 12-08-1998 / 13:55:32 / cg"
3901
f2c56662a45e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3849
diff changeset
   687
    "Modified (format): / 17-02-2017 / 12:29:44 / cg"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   688
! !
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
   689
1805
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   690
!GIFReader methodsFor:'private-writing'!
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   691
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   692
assignTransparentPixelIn:image
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   693
    "find an usused pixelValue in the colorMap (or image)."
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   694
3689
c12d825e0249 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3658
diff changeset
   695
    |cmap cmapSize imgDepth usedPixelValues unusedValues|
1805
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   696
3689
c12d825e0249 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3658
diff changeset
   697
    cmap := image colorMap.
c12d825e0249 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3658
diff changeset
   698
    cmapSize := cmap size.
c12d825e0249 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3658
diff changeset
   699
    ((cmapSize > 0) and:[cmapSize < 256]) ifTrue:[
c12d825e0249 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3658
diff changeset
   700
        maskPixel := cmapSize.
c12d825e0249 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3658
diff changeset
   701
        ^ self
1805
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   702
    ].
3689
c12d825e0249 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3658
diff changeset
   703
    
3009
6015068e91a3 changed: #assignTransparentPixelIn:
anwild
parents: 2845
diff changeset
   704
    image compressColorMap.
3689
c12d825e0249 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3658
diff changeset
   705
    imgDepth := image depth.
1805
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   706
    usedPixelValues := image usedValues.
3689
c12d825e0249 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3658
diff changeset
   707
    usedPixelValues size < (1 bitShift:imgDepth) ifFalse:[
c12d825e0249 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3658
diff changeset
   708
        Image informationLostQuerySignal
c12d825e0249 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3658
diff changeset
   709
            raiseRequestWith:image
c12d825e0249 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3658
diff changeset
   710
            errorString:('GIF writer cannot assign a transparent pixel - all pixelValues used by image').
2056
b7eea50081f2 fixed transparency-pixel bug (with full colormap)
Claus Gittinger <cg@exept.de>
parents: 2032
diff changeset
   711
    ].
b7eea50081f2 fixed transparency-pixel bug (with full colormap)
Claus Gittinger <cg@exept.de>
parents: 2032
diff changeset
   712
b7eea50081f2 fixed transparency-pixel bug (with full colormap)
Claus Gittinger <cg@exept.de>
parents: 2032
diff changeset
   713
    "/ there must be an unused pixelValue
3689
c12d825e0249 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3658
diff changeset
   714
    unusedValues := (0 to:(1 bitShift:imgDepth)-1) asSet.
2056
b7eea50081f2 fixed transparency-pixel bug (with full colormap)
Claus Gittinger <cg@exept.de>
parents: 2032
diff changeset
   715
    unusedValues removeAll:usedPixelValues.
b7eea50081f2 fixed transparency-pixel bug (with full colormap)
Claus Gittinger <cg@exept.de>
parents: 2032
diff changeset
   716
b7eea50081f2 fixed transparency-pixel bug (with full colormap)
Claus Gittinger <cg@exept.de>
parents: 2032
diff changeset
   717
    maskPixel := unusedValues first.
3009
6015068e91a3 changed: #assignTransparentPixelIn:
anwild
parents: 2845
diff changeset
   718
6015068e91a3 changed: #assignTransparentPixelIn:
anwild
parents: 2845
diff changeset
   719
    "Modified: / 17-07-2012 / 12:25:24 / anwild"
1805
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   720
!
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   721
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   722
checkCodeSize
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   723
    (freeCode > maxCode and: [codeSize < 12])
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   724
	    ifTrue:
1805
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   725
		    [codeSize := codeSize + 1.
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   726
		    maxCode := (1 bitShift: codeSize) - 1]
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   727
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   728
    "Created: 14.10.1997 / 18:42:01 / cg"
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   729
!
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   730
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   731
flushBits
4341
f1e9c4428cd3 #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   732
        remainBitCount == 0
f1e9c4428cd3 #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   733
                ifFalse:
f1e9c4428cd3 #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   734
                        [self nextBytePut: bufByte.
f1e9c4428cd3 #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   735
                        remainBitCount := 0].
f1e9c4428cd3 #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   736
        self flushBuffer
1805
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   737
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   738
    "Modified: 14.10.1997 / 18:58:06 / cg"
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   739
!
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   740
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   741
flushBuffer
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   742
    bufStream isEmpty ifTrue: [^ self].
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   743
    outStream nextPut: bufStream size.
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   744
    outStream nextPutAll: bufStream contents.
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   745
    bufStream := WriteStream on: (ByteArray new: 256)
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   746
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   747
    "Modified: 14.10.1997 / 20:46:04 / cg"
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   748
!
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   749
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   750
flushCode
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   751
	self flushBits
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   752
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   753
    "Created: 14.10.1997 / 18:57:33 / cg"
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   754
!
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   755
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   756
nextBitsPut: anInteger
4341
f1e9c4428cd3 #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   757
        | integer writeBitCount shiftCount |
f1e9c4428cd3 #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   758
        shiftCount := 0.
f1e9c4428cd3 #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   759
        remainBitCount == 0
f1e9c4428cd3 #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   760
                ifTrue:
f1e9c4428cd3 #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   761
                        [writeBitCount := 8.
f1e9c4428cd3 #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   762
                        integer := anInteger]
f1e9c4428cd3 #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   763
                ifFalse:
f1e9c4428cd3 #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   764
                        [writeBitCount := remainBitCount.
f1e9c4428cd3 #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   765
                        integer := bufByte + (anInteger bitShift: 8 - remainBitCount)].
f1e9c4428cd3 #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   766
        [writeBitCount < codeSize]
f1e9c4428cd3 #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   767
                whileTrue:
f1e9c4428cd3 #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   768
                        [self nextBytePut: ((integer bitShift: shiftCount) bitAnd: 255).
f1e9c4428cd3 #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   769
                        shiftCount := shiftCount - 8.
f1e9c4428cd3 #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   770
                        writeBitCount := writeBitCount + 8].
f1e9c4428cd3 #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   771
        (remainBitCount := writeBitCount - codeSize) = 0
f1e9c4428cd3 #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   772
                ifTrue: [self nextBytePut: (integer bitShift: shiftCount)]
f1e9c4428cd3 #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   773
                ifFalse: [bufByte := integer bitShift: shiftCount].
f1e9c4428cd3 #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   774
        ^anInteger
1805
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   775
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   776
    "Modified: 15.10.1997 / 16:50:30 / cg"
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   777
!
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   778
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   779
nextBytePut: aByte
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   780
	bufStream nextPut: aByte.
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   781
	bufStream size >= 254 ifTrue: [self flushBuffer]
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   782
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   783
    "Modified: 15.10.1997 / 16:50:52 / cg"
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   784
!
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   785
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   786
readPixelFrom: bits
1805
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   787
    | pixel |
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   788
    ypos >= height ifTrue: [^ nil].
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   789
    (maskPixel notNil
1805
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   790
    and:[(mask pixelAtX:xpos y:ypos) == 0]) ifTrue:[
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   791
	pixel := maskPixel
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   792
    ] ifFalse:[
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   793
	pixel := bits at: ypos * rowByteSize + xpos + 1.
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   794
    ].
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   795
    self updatePixelPosition.
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   796
    ^ pixel
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   797
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   798
    "Created: 14.10.1997 / 18:43:50 / cg"
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   799
    "Modified: 15.10.1997 / 16:46:43 / cg"
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   800
!
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   801
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   802
setParameters:bitsPerPixel
1805
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   803
    clearCode := 1 bitShift:bitsPerPixel.
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   804
    eoiCode := clearCode + 1.
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   805
    freeCode := clearCode + 2.
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   806
    codeSize := bitsPerPixel + 1.
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   807
    maxCode := (1 bitShift: codeSize) - 1
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   808
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   809
    "Modified: 14.10.1997 / 20:09:48 / cg"
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   810
!
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   811
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   812
updatePixelPosition
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   813
    (xpos := xpos + 1) >= width ifFalse: [^ self].
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   814
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   815
    xpos := 0.
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   816
    interlace == true ifFalse:[
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   817
	ypos := ypos + 1.
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   818
	^ self
1805
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   819
    ].
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   820
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   821
    pass == 0 ifTrue:[
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   822
	(ypos := ypos + 8) >= height ifTrue:[
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   823
	    pass := pass + 1.
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   824
	    ypos := 4
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   825
	].
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   826
	^ self
1805
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   827
    ].
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   828
    pass == 1 ifTrue:[
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   829
	(ypos := ypos + 8) >= height ifTrue:[
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   830
	    pass := pass + 1.
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   831
	    ypos := 2
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   832
	].
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   833
	^ self
1805
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   834
    ].
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   835
    pass == 2 ifTrue:[
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   836
	(ypos := ypos + 4) >= height ifTrue:[
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   837
	    pass := pass + 1.
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   838
	    ypos := 1
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   839
	].
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   840
	^ self
1805
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   841
    ].
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   842
    pass == 3 ifTrue:[
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   843
	ypos := ypos + 2.
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   844
	^ self
1805
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   845
    ].
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   846
    ^ self error: 'can''t happen'
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   847
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   848
    "Modified: 14.10.1997 / 18:44:27 / cg"
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   849
!
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   850
2032
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   851
writeBitDataFor: image
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   852
    "using modified Lempel-Ziv Welch algorithm."
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   853
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   854
    | bits bitsPerPixel t1
3849
2588329e3f4a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3848
diff changeset
   855
      maxBits maxMaxCode tSize initCodeSize ent tShift fCode 
2588329e3f4a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3848
diff changeset
   856
      pixel
2588329e3f4a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3848
diff changeset
   857
      index disp nomatch |
2032
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   858
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   859
    outStream nextPut:ImageSeparator.
3282
57d0f3cef4ef class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3120
diff changeset
   860
    self writeShort:0.       "/ leftOffs
57d0f3cef4ef class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3120
diff changeset
   861
    self writeShort:0.       "/ topOffs
2032
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   862
    self writeShort:width.   "/ image size
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   863
    self writeShort:height.
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   864
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   865
    interlace == true ifTrue:[
3848
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   866
        t1 := 64
2032
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   867
    ] ifFalse:[
3848
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   868
        t1 := 0  "/ no local colormap
2032
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   869
    ].
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   870
    outStream nextPut:t1.       "/ another flag
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   871
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   872
    bitsPerPixel := image bitsPerPixel.
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   873
    bits := image bits.
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   874
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   875
    pass := 0.
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   876
    xpos := 0.
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   877
    ypos := 0.
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   878
    rowByteSize := image bytesPerRow. "/ width * 8 + 31 // 32 * 4.
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   879
    remainBitCount := 0.
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   880
    bufByte := 0.
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   881
    bufStream := WriteStream on: (ByteArray new: 256).
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   882
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   883
    maxBits := 12.
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   884
    maxMaxCode := 1 bitShift: maxBits.
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   885
    tSize := 5003.
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   886
    prefixTable := Array new: tSize.
3364
c20af44ab483 class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3284
diff changeset
   887
    suffixTable := Array new: tSize withAll:-1.
2032
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   888
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   889
    initCodeSize := bitsPerPixel <= 1 ifTrue: [2] ifFalse: [bitsPerPixel].
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   890
    outStream nextPut: initCodeSize.
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   891
    self setParameters: initCodeSize.
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   892
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   893
    tShift := 0.
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   894
    fCode := tSize.
2845
62d4128bb923 comment/format in: #writeBitDataFor:
Claus Gittinger <cg@exept.de>
parents: 2844
diff changeset
   895
    [fCode < 65536] whileTrue:[
3848
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   896
        tShift := tShift + 1.
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   897
        fCode := fCode * 2
2845
62d4128bb923 comment/format in: #writeBitDataFor:
Claus Gittinger <cg@exept.de>
parents: 2844
diff changeset
   898
    ].
2032
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   899
    tShift := 8 - tShift.
3364
c20af44ab483 class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3284
diff changeset
   900
    "/ 1 to: tSize do: [:i | suffixTable at: i put: -1]. - cg changed initialization above
2032
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   901
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   902
    self writeCodeAndCheckCodeSize: clearCode.
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   903
    ent := self readPixelFrom: bits.
3848
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   904
    [(pixel := self readPixelFrom: bits) notNil] whileTrue:[
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   905
        fCode := (pixel bitShift: maxBits) + ent.
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   906
        index := ((pixel bitShift: tShift) bitXor: ent) + 1.
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   907
        (suffixTable at: index) = fCode
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   908
            ifTrue: [ent := prefixTable at: index]
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   909
            ifFalse:[
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   910
                nomatch := true.
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   911
                (suffixTable at: index) >= 0
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   912
                    ifTrue:[
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   913
                        disp := tSize - index + 1.
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   914
                        index = 1 ifTrue: [disp := 1].
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   915
                        "probe"
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   916
                        [(index := index - disp) < 1 ifTrue: [index := index + tSize].
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   917
                        (suffixTable at: index) = fCode
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   918
                            ifTrue:[
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   919
                                    ent := prefixTable at: index.
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   920
                                    nomatch := false.
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   921
                                    "continue whileFalse:"].
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   922
                        nomatch and: [(suffixTable at: index) > 0]]
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   923
                            whileTrue: ["probe"]].
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   924
                "nomatch"
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   925
                nomatch ifTrue:[
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   926
                    self writeCodeAndCheckCodeSize: ent.
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   927
                    ent := pixel.
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   928
                    freeCode < maxMaxCode
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   929
                        ifTrue:[
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   930
                            prefixTable at: index put: freeCode.
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   931
                            suffixTable at: index put: fCode.
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   932
                            freeCode := freeCode + 1]
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   933
                        ifFalse:[
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   934
                            self writeCodeAndCheckCodeSize: clearCode.
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   935
                            suffixTable from:1 to:tSize put:-1.
fdaa0179292f #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3784
diff changeset
   936
                            self setParameters: initCodeSize]]]].
2032
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   937
    prefixTable := suffixTable := nil.
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   938
    self writeCodeAndCheckCodeSize: ent.
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   939
    self writeCodeAndCheckCodeSize: eoiCode.
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   940
    self flushCode.
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   941
    outStream nextPut: 0.        "zero-length packet"
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   942
2845
62d4128bb923 comment/format in: #writeBitDataFor:
Claus Gittinger <cg@exept.de>
parents: 2844
diff changeset
   943
    "Modified: / 02-06-2010 / 12:24:20 / cg"
2032
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   944
!
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   945
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   946
writeCode: aCode
1805
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   947
    self nextBitsPut: aCode
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   948
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   949
    "Created: 14.10.1997 / 18:38:35 / cg"
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   950
    "Modified: 15.10.1997 / 17:01:47 / cg"
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   951
!
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   952
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   953
writeCodeAndCheckCodeSize: t1
1805
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   954
    self writeCode: t1.
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   955
    self checkCodeSize
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   956
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   957
    "Created: 14.10.1997 / 18:38:24 / cg"
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   958
    "Modified: 14.10.1997 / 18:40:56 / cg"
2032
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   959
!
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   960
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   961
writeHeaderFor:image
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   962
    "write the gif header"
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   963
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   964
    |bitsPerPixel t1|
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   965
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   966
    bitsPerPixel := image bitsPerPixel.
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   967
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   968
    outStream nextPutAll: 'GIF89a' asByteArray.
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   969
    self writeShort:width. "/ screen size
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   970
    self writeShort:height.
2032
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   971
    t1 := 128.
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   972
    t1 := t1 bitOr:(bitsPerPixel - 1 bitShift:5).
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   973
    t1 := t1 bitOr:(bitsPerPixel - 1).
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   974
    outStream nextPut:t1.  "/ flag
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   975
    outStream nextPut:0.   "/ background (not used)
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   976
    outStream nextPut:0.   "/ aspect ratio
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   977
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   978
    0 to:(1 bitShift:bitsPerPixel)-1 do:[:pixel |
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   979
	|clr red green blue|
2032
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   980
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   981
	clr := image colorFromValue:pixel.
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   982
	clr isNil ifTrue:[
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   983
	    "/ unused colorMap slot
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   984
	    red := green := blue := 0.
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   985
	] ifFalse:[
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   986
	    red := (clr redByte).
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   987
	    green := (clr greenByte).
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   988
	    blue := (clr blueByte).
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   989
	].
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   990
	outStream
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   991
	    nextPut:red; nextPut:green; nextPut:blue.
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
   992
    ].
2032
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   993
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   994
    "Created: / 14.10.1997 / 17:41:28 / cg"
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   995
    "Modified: / 31.10.1997 / 16:12:13 / cg"
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   996
!
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   997
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   998
writeMaskExtensionHeaderFor:image
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
   999
    "write an extension header for the transparent pixel"
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
  1000
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
  1001
    outStream nextPut:Extension.
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
  1002
    outStream nextPut:16rF9.       "/ graphic control extension
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
  1003
    outStream nextPut:4.           "/ subBlockSize
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
  1004
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
  1005
    outStream nextPut:1.                "/ animationType
3658
ed7a9aa41ba4 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3573
diff changeset
  1006
    outStream nextPutInt16LSB:1.        "/ animationTime
2032
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
  1007
    outStream nextPut:maskPixel.        "/ animationMask
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
  1008
cf3b4dcc4ad3 category
Stefan Vogel <sv@exept.de>
parents: 2030
diff changeset
  1009
    outStream nextPut:0.
1805
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
  1010
! !
93f557cbe600 category changes
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
  1011
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1012
!GIFReader methodsFor:'writing to file'!
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1013
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1014
save:image onFile:aFileName
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1015
    "save image as GIF file on aFileName"
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1016
1813
aa74c7bd22ad image saving - use save:onStream:
Claus Gittinger <cg@exept.de>
parents: 1811
diff changeset
  1017
    |convertedImage|
1206
fe2354feee01 separated image writer for stream writing
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1018
718
41ade132da98 raise an error, if depth is not supported.
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
  1019
    image depth ~~ 8 ifTrue:[
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
  1020
	Error handle:[:ex |
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
  1021
	    ^ Image cannotRepresentImageSignal
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
  1022
		raiseWith:image
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
  1023
		errorString:('GIF failed to convert image to depth8: ', ex description).
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
  1024
	    "/ ex return.
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
  1025
	] do:[
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
  1026
	    convertedImage := Image newForDepth:8.
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
  1027
	    convertedImage fromImage:image photometric:#palette.
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
  1028
	].
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
  1029
	convertedImage notNil ifTrue:[
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
  1030
	    ^ self save:convertedImage onFile:aFileName
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
  1031
	].
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
  1032
	^ Image cannotRepresentImageSignal
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
  1033
	    raiseWith:image
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
  1034
	    errorString:('GIF (currently) only supports depth8 images (cannot convert)').
718
41ade132da98 raise an error, if depth is not supported.
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
  1035
    ].
41ade132da98 raise an error, if depth is not supported.
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
  1036
1813
aa74c7bd22ad image saving - use save:onStream:
Claus Gittinger <cg@exept.de>
parents: 1811
diff changeset
  1037
    super save:image onFile:aFileName.
1206
fe2354feee01 separated image writer for stream writing
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1038
fe2354feee01 separated image writer for stream writing
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1039
    "
fe2354feee01 separated image writer for stream writing
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1040
     |i|
fe2354feee01 separated image writer for stream writing
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1041
fe2354feee01 separated image writer for stream writing
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1042
     i := Image fromFile:'bitmaps/gifImages/garfield.gif'.
fe2354feee01 separated image writer for stream writing
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1043
     GIFReader save:i onFile:'foo.gif'.
fe2354feee01 separated image writer for stream writing
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1044
     (Image fromFile:'./foo.gif') inspect
fe2354feee01 separated image writer for stream writing
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1045
    "
fe2354feee01 separated image writer for stream writing
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1046
fe2354feee01 separated image writer for stream writing
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1047
    "Created: / 14.10.1997 / 17:40:12 / cg"
fe2354feee01 separated image writer for stream writing
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1048
    "Modified: / 27.10.1997 / 22:42:31 / cg"
fe2354feee01 separated image writer for stream writing
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1049
!
fe2354feee01 separated image writer for stream writing
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1050
fe2354feee01 separated image writer for stream writing
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1051
save:image onStream:aStream
fe2354feee01 separated image writer for stream writing
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1052
    "save image in GIF-file-format onto aStream"
fe2354feee01 separated image writer for stream writing
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1053
fe2354feee01 separated image writer for stream writing
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1054
    image depth ~~ 8 ifTrue:[
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
  1055
        ^ Image cannotRepresentImageSignal
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
  1056
            raiseWith:image
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
  1057
            errorString:('GIF (currently) only supports depth8 images').
1206
fe2354feee01 separated image writer for stream writing
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1058
    ].
fe2354feee01 separated image writer for stream writing
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1059
fe2354feee01 separated image writer for stream writing
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1060
    outStream := aStream.
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1061
    outStream binary.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1062
714
c89f5c12538c added transparentPixel support.
ca
parents: 713
diff changeset
  1063
    mask := image mask.
c89f5c12538c added transparentPixel support.
ca
parents: 713
diff changeset
  1064
    mask notNil ifTrue:[
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
  1065
        self assignTransparentPixelIn:image
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1066
    ].
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1067
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1068
    byteOrder := #lsb.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1069
    width := image width.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1070
    height := image height.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1071
    photometric := image photometric.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1072
    samplesPerPixel := image samplesPerPixel.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1073
    bitsPerSample := image bitsPerSample.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1074
    colorMap := image colorMap.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1075
    data := image bits.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1076
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1077
    self writeHeaderFor:image.
714
c89f5c12538c added transparentPixel support.
ca
parents: 713
diff changeset
  1078
    maskPixel notNil ifTrue:[
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
  1079
        self writeMaskExtensionHeaderFor:image.
714
c89f5c12538c added transparentPixel support.
ca
parents: 713
diff changeset
  1080
    ].
c89f5c12538c added transparentPixel support.
ca
parents: 713
diff changeset
  1081
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1082
    self writeBitDataFor:image.
714
c89f5c12538c added transparentPixel support.
ca
parents: 713
diff changeset
  1083
3282
57d0f3cef4ef class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3120
diff changeset
  1084
    image imageSequence notEmptyOrNil ifTrue:[
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
  1085
        image imageSequence do:[:eachFrame |
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
  1086
            outStream nextPut:Extension.
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
  1087
            outStream nextPut:16rF9.    "/ graphic control extension
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
  1088
            outStream nextPut:4.        "/ sub block size
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
  1089
            outStream nextPut:0.        "/ animation type 0
3658
ed7a9aa41ba4 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3573
diff changeset
  1090
            outStream nextPutInt16LSB:(eachFrame delay / 10) rounded asInteger.
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
  1091
            outStream nextPut:0.        "/ animation mask
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
  1092
            outStream nextPut:0.        "/ subblock size
3282
57d0f3cef4ef class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3120
diff changeset
  1093
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
  1094
            self writeBitDataFor:eachFrame image.
3392
8bb003c31c63 unused locals
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
  1095
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
  1096
        ].
3282
57d0f3cef4ef class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3120
diff changeset
  1097
    ].
57d0f3cef4ef class: GIFReader
Claus Gittinger <cg@exept.de>
parents: 3120
diff changeset
  1098
714
c89f5c12538c added transparentPixel support.
ca
parents: 713
diff changeset
  1099
    outStream nextPut: Terminator.
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1100
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1101
    "
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1102
     |i|
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1103
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1104
     i := Image fromFile:'bitmaps/gifImages/garfield.gif'.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1105
     GIFReader save:i onFile:'foo.gif'.
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1106
     (Image fromFile:'./foo.gif') inspect
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1107
    "
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1108
718
41ade132da98 raise an error, if depth is not supported.
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
  1109
    "Created: / 14.10.1997 / 17:40:12 / cg"
41ade132da98 raise an error, if depth is not supported.
Claus Gittinger <cg@exept.de>
parents: 714
diff changeset
  1110
    "Modified: / 27.10.1997 / 22:42:31 / cg"
708
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1111
! !
47d402971287 added GIF writing capability
Claus Gittinger <cg@exept.de>
parents: 691
diff changeset
  1112
339
9b4ece782f6a removed an infoPrint.
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1113
!GIFReader class methodsFor:'documentation'!
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
  1114
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
  1115
version
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
  1116
    ^ '$Header$'
2844
ce205334bcdc changed: #readExtension:
Claus Gittinger <cg@exept.de>
parents: 2694
diff changeset
  1117
!
ce205334bcdc changed: #readExtension:
Claus Gittinger <cg@exept.de>
parents: 2694
diff changeset
  1118
ce205334bcdc changed: #readExtension:
Claus Gittinger <cg@exept.de>
parents: 2694
diff changeset
  1119
version_CVS
3553
2e3f003c3848 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
  1120
    ^ '$Header$'
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
  1121
! !
1711
b3ba13167ee7 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 1521
diff changeset
  1122
3119
af4a0d795d01 exception access
Claus Gittinger <cg@exept.de>
parents: 3009
diff changeset
  1123
43
e85c7d392833 *** empty log message ***
claus
parents: 34
diff changeset
  1124
GIFReader initialize!