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