TargaReader.st
author alkurz
Tue, 02 Jul 2019 14:10:25 +0200
changeset 4287 9e5dc8a88380
parent 4016 47c4ea8134ec
permissions -rw-r--r--
#FEATURE by alkurz class: ApplicationModel openDialogInterface:withBindings: accepts an already decoded spec as argument
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
     1
"
aeed5856f457 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1994 by Claus Gittinger
aeed5856f457 Initial revision
claus
parents:
diff changeset
     3
	      All Rights Reserved
aeed5856f457 Initial revision
claus
parents:
diff changeset
     4
aeed5856f457 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
aeed5856f457 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
aeed5856f457 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
aeed5856f457 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
aeed5856f457 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
aeed5856f457 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
aeed5856f457 Initial revision
claus
parents:
diff changeset
    11
"
1577
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
    12
"{ Package: 'stx:libview2' }"
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
    13
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
    14
"{ NameSpace: Smalltalk }"
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
    15
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
    16
ImageReader subclass:#TargaReader
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
    17
	instanceVariableNames:'orientation bytesPerRow bytesPerPixel imageType'
4016
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
    18
	classVariableNames:'Verbose'
210
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    19
	poolDictionaries:''
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 1738
diff changeset
    20
	category:'Graphics-Images-Readers'
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
    21
!
aeed5856f457 Initial revision
claus
parents:
diff changeset
    22
aeed5856f457 Initial revision
claus
parents:
diff changeset
    23
!TargaReader class methodsFor:'documentation'!
aeed5856f457 Initial revision
claus
parents:
diff changeset
    24
aeed5856f457 Initial revision
claus
parents:
diff changeset
    25
copyright
aeed5856f457 Initial revision
claus
parents:
diff changeset
    26
"
aeed5856f457 Initial revision
claus
parents:
diff changeset
    27
 COPYRIGHT (c) 1994 by Claus Gittinger
aeed5856f457 Initial revision
claus
parents:
diff changeset
    28
	      All Rights Reserved
aeed5856f457 Initial revision
claus
parents:
diff changeset
    29
aeed5856f457 Initial revision
claus
parents:
diff changeset
    30
 This software is furnished under a license and may be used
aeed5856f457 Initial revision
claus
parents:
diff changeset
    31
 only in accordance with the terms of that license and with the
aeed5856f457 Initial revision
claus
parents:
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
aeed5856f457 Initial revision
claus
parents:
diff changeset
    33
 be provided or otherwise made available to, or used by, any
aeed5856f457 Initial revision
claus
parents:
diff changeset
    34
 other person.  No title to or ownership of the software is
aeed5856f457 Initial revision
claus
parents:
diff changeset
    35
 hereby transferred.
aeed5856f457 Initial revision
claus
parents:
diff changeset
    36
"
aeed5856f457 Initial revision
claus
parents:
diff changeset
    37
!
aeed5856f457 Initial revision
claus
parents:
diff changeset
    38
aeed5856f457 Initial revision
claus
parents:
diff changeset
    39
documentation
aeed5856f457 Initial revision
claus
parents:
diff changeset
    40
"
aeed5856f457 Initial revision
claus
parents:
diff changeset
    41
    this class provides methods for loading targa-file (tga) images.
556
a2d03470af59 documentation
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
    42
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
    43
    The Targa-File format is an image file format used by a wide variety of both
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
    44
    scanners and imaging software, and exists in many incarnations. 
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
    45
    For details, please refer to the 'Truevision Technical Guide':
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
    46
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
    47
    Limitations: 
556
a2d03470af59 documentation
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
    48
        not fully tested (I only had a few targa files to check things)
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
    49
        only supports 8, 24 and 32 bits/pixel formats; 
210
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    50
        Image saving not supported
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
    51
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
    52
    I had two tga files to test this code with; 
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
    53
    therefore it may pr may not work with other targa files 
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
    54
    (it certainly does not work with 1/16 bit images).
299
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    55
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
    56
    Suggestions: adapt & use the pbmplus library here.
210
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    57
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    58
    [See also:]
234
b6352d13e792 xrefs in documentation
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    59
        Image Form Icon
210
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    60
        BlitImageReader FaceReader GIFReader JPEGReader PBMReader PCXReader 
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    61
        ST80FormReader SunRasterReader TIFFReader WindowsIconReader 
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    62
        XBMReader XPMReader XWDReader
4001
153c0234371a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3998
diff changeset
    63
        
153c0234371a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3998
diff changeset
    64
        http://www.dca.fee.unicamp.br/~martino/disciplinas/ea978/tgaffs.pdf
4002
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    65
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    66
    [examples:]
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    67
        Smalltalk loadPackage:'stx:goodies/communication'.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    68
        Smalltalk loadPackage:'exept:libcrypt/ssl'.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    69
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    70
        |file|
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    71
        file := (HTTPInterface getStreamFor:'https://samples.libav.org/image-samples/TGA/rgb32rle.tga') stream contents.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    72
        (TargaReader fromStream:file readStream) inspect.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    73
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    74
        |file|
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    75
        file := (HTTPInterface getStreamFor:'https://samples.libav.org/image-samples/TGA/rgb16rle.tga') stream contents.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    76
        TargaReader fromStream:file readStream.
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
    77
"
1738
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
    78
!
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
    79
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
    80
format
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
    81
"
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
    82
    Shorts etc. are lsb.
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
    83
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
    84
    offset:
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
    85
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
    86
        1       lenID           byte
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
    87
        2       hasColorMap     byte
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
    88
        3       imageType       byte
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
    89
                         1   MapRGB  
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
    90
                         2   RawRGB   
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
    91
                         3   RawMono   
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
    92
                         9   MapEnCode 
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
    93
                         10  RawEnCode 
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
    94
        4, 5    cmapOffset      short
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
    95
        6, 7    cmapLength      short
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
    96
        8       cmapEntrySize   short
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
    97
        9,10    xOrg            short
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
    98
        11,12   yOrg            short
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
    99
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   100
        13,14   width 
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   101
        15,16   height 
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   102
        17      depth 
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   103
        18      flags
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   104
                        0000 xxxx  attribute-bits-per-pixel
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   105
                        0000 0001  greysc
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   106
                        0000 0010  colour
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   107
                        0000 0011  mapped
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   108
                        0000 0100  rleEncoded
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   109
                        0000 1000  interlaced
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   110
                        00xx 0000  origin (0 -> lower-left / 1 -> l-r / 2 -> u-l / 3 -> u-r)
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   111
                        xx00 0000  interleave (0 -> none / 1 -> odd/even / 2 ->4-fould / 3 reserved)
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   112
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   113
        19..    len             lenID-bytes
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   114
        ..      colorMap        cmapLength*3 bytes iff hasColorMap ~~ 0
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   115
"
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   116
! !
aeed5856f457 Initial revision
claus
parents:
diff changeset
   117
aeed5856f457 Initial revision
claus
parents:
diff changeset
   118
!TargaReader class methodsFor:'initialization'!
aeed5856f457 Initial revision
claus
parents:
diff changeset
   119
aeed5856f457 Initial revision
claus
parents:
diff changeset
   120
initialize
210
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   121
    "tell Image-class, that a new fileReader is present
398
aef700d15416 new suffix-table
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
   122
     for the '.tga' extension."
210
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   123
647
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   124
    MIMETypes defineImageType:'image/x-targa' suffix:'tga' reader:self.
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   125
630
48657c687a8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 556
diff changeset
   126
    "Modified: 27.6.1997 / 18:39:43 / cg"
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   127
! !
aeed5856f457 Initial revision
claus
parents:
diff changeset
   128
aeed5856f457 Initial revision
claus
parents:
diff changeset
   129
!TargaReader class methodsFor:'testing'!
aeed5856f457 Initial revision
claus
parents:
diff changeset
   130
aeed5856f457 Initial revision
claus
parents:
diff changeset
   131
isValidImageFile:aFileName
aeed5856f457 Initial revision
claus
parents:
diff changeset
   132
    "return true, if aFileName contains a targa-file image"
aeed5856f457 Initial revision
claus
parents:
diff changeset
   133
1577
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   134
    |aStream w h depth flags imageType ok|
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   135
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   136
    ok := true.
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   137
43
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
   138
    aStream := self streamReadingFile:aFileName.
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
   139
    aStream isNil ifTrue:[^ false].
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
   140
    aStream binary.
1577
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   141
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   142
    aStream next.   "lenID"
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   143
    aStream next.   "hasColorMap"
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   144
    imageType := aStream next.  
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   145
    aStream skip:2. "cmapOffset"
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   146
    aStream skip:2. "cmapLength"
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   147
    aStream next.   "cmapEntrySize"
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   148
    aStream skip:2. "xOrg"
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   149
    aStream skip:2. "yOrg"
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   150
43
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
   151
    w := aStream nextShortMSB:false.
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
   152
    h := aStream nextShortMSB:false.
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   153
43
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
   154
    depth := aStream next.
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
   155
    flags := aStream next.
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   156
1577
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   157
    "/ MapRGB == 1
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   158
    "/ RawRGB == 2
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   159
    "/ RawMono == 3
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   160
    "/ MapEnCode == 9
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   161
    "/ RawEnCode == 10
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   162
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   163
    (#(1 2 3 9 10) includes:imageType) ifFalse:[
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   164
        "/ 'TargaReader [warning]: unsupported imageType: ' errorPrint. imageType errorPrintCR.
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   165
        ok := false
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   166
    ] ifTrue:[
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   167
        (#(8 "16" 24 32) includes:depth) ifFalse:[
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   168
            ok := false
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   169
        ].
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   170
    ].
43
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
   171
    aStream close. 
1577
a8851bce16c5 isValidImageFile improved
Claus Gittinger <cg@exept.de>
parents: 1079
diff changeset
   172
    ^ ok
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   173
aeed5856f457 Initial revision
claus
parents:
diff changeset
   174
    "
aeed5856f457 Initial revision
claus
parents:
diff changeset
   175
     TargaReader isValidImageFile:'bitmaps/test.tga'    
aeed5856f457 Initial revision
claus
parents:
diff changeset
   176
     TargaReader isValidImageFile:'bitmaps/garfield.gif'  
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   177
    "
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   178
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   179
    "Modified: 21.4.1997 / 20:46:52 / cg"
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   180
! !
aeed5856f457 Initial revision
claus
parents:
diff changeset
   181
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   182
!TargaReader methodsFor:'private-reading'!
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   183
1738
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   184
handleImageOrientation
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   185
    |rowIdx startIdx endIdx t|
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   186
1738
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   187
    orientation == #topLeft ifTrue:[
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   188
        ^ self.
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   189
    ].
aeed5856f457 Initial revision
claus
parents:
diff changeset
   190
1738
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   191
    orientation == #topRight ifTrue:[
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   192
        "/ flip horizontal
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   193
        rowIdx := 1.
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   194
        1 to:height do:[:row |
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   195
            startIdx := rowIdx.
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   196
            endIdx := rowIdx + bytesPerRow - bytesPerPixel.
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   197
            1 to:width//2 do:[:x |
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   198
                0 to:bytesPerPixel-1 do:[:c |
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   199
                    t := data at:startIdx+c.
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   200
                    data at:startIdx+c put:(data at:endIdx+c).
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   201
                    data at:endIdx+c put:t.
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   202
                ].
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   203
                startIdx := startIdx + bytesPerPixel.
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   204
                endIdx := endIdx - bytesPerPixel.
1065
32a68620ddab care for EOF while reading colorMap.
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
   205
            ].
1738
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   206
            rowIdx := rowIdx + width.
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   207
        ].
1738
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   208
        ^ self.
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   209
    ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   210
1738
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   211
    orientation == #bottomLeft ifTrue:[
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   212
        "/ flip vertical
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   213
        startIdx := 1.
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   214
        endIdx := 1 + ((height - 1) * bytesPerRow).
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   215
        t := ByteArray new:bytesPerRow.
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   216
        1 to:height//2 do:[:row |
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   217
            t replaceFrom:1 to:bytesPerRow with:data startingAt:startIdx.
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   218
            data replaceFrom:startIdx to:startIdx+bytesPerRow-1 with:data startingAt:endIdx.
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   219
            data replaceFrom:endIdx to:endIdx+bytesPerRow-1 with:t startingAt:1.
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   220
            startIdx := startIdx + bytesPerRow.
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   221
            endIdx := endIdx - bytesPerRow
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   222
        ].
1738
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   223
        ^ self.
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   224
    ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   225
1738
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   226
    'TargaReader [warning]: unsupported orientation: ' errorPrint. orientation errorPrintCR.
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   227
!
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   228
4002
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   229
read16
4016
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   230
    "read a 16 bit/pixel targa-image.
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   231
     Notice, that the channels are in bgr order; not rgb"
4002
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   232
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   233
    |totalBytes remainingBytes dstIndex b1 b2|
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   234
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   235
    totalBytes := width * height * 2.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   236
    data := ByteArray new:totalBytes.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   237
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   238
    dstIndex := 1.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   239
    remainingBytes := totalBytes.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   240
    [remainingBytes > 0] whileTrue:[
4016
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   241
        b2 := inStream nextByte.
4002
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   242
        b1 := inStream nextByte.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   243
        data at:dstIndex   put:b1.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   244
        data at:dstIndex+1 put:b2.
4016
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   245
        
4002
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   246
        dstIndex := dstIndex + 2.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   247
        remainingBytes := remainingBytes - 2.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   248
    ].
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   249
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   250
    "Created: / 29-08-2017 / 23:38:30 / cg"
4016
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   251
    "Modified: / 17-09-2017 / 13:35:21 / cg"
4002
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   252
!
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   253
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   254
read16RLE
4016
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   255
    "read a 16 bit/pixel rle encoded targa-image.
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   256
     Notice, that the channels are in bgr order; not rgb"
4002
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   257
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   258
    |total count dstIndex code n b1 b2|
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   259
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   260
    data := ByteArray new:((total := width * height * 2)).
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   261
    count := 0.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   262
    dstIndex := 1.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   263
    [count < total] whileTrue:[
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   264
        code := inStream nextByte.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   265
        n := (code bitAnd:16r7F) + 1.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   266
        (code bitAnd:16r80) ~~ 0 ifTrue:[
4016
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   267
            b2 := inStream nextByte.
4002
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   268
            b1 := inStream nextByte.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   269
            n timesRepeat:[
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   270
                data at:dstIndex put:b1.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   271
                data at:dstIndex+1 put:b2.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   272
                dstIndex := dstIndex + 2
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   273
            ].
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   274
        ] ifFalse:[
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   275
            n timesRepeat:[
4016
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   276
                b2 := inStream nextByte.
4002
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   277
                b1 := inStream nextByte.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   278
                data at:dstIndex put:b1.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   279
                data at:dstIndex+1 put:b2.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   280
                dstIndex := dstIndex + 2
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   281
            ]
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   282
        ].
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   283
        count := count + (n * 2).
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   284
    ].
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   285
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   286
    "Created: / 29-08-2017 / 23:39:19 / cg"
4016
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   287
    "Modified (comment): / 17-09-2017 / 13:35:59 / cg"
4002
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   288
!
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   289
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   290
read24
4016
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   291
    "read a 24 bit/pixel targa-image.
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   292
     Notice, that the channels are in bgr order; not rgb"
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   293
1738
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   294
    |totalBytes|
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   295
1738
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   296
    totalBytes := width * height * 3.
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   297
    data := ByteArray new:totalBytes.
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   298
    inStream nextBytes:totalBytes into:data.
299
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   299
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   300
    "
4016
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   301
     mhmh - pixel-byte order is blue-green-red; swap blue & red bytes
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   302
    "
1738
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   303
    self class swap:totalBytes bytesFromRGB_to_BGR_in:data.
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   304
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   305
    "Modified: / 29-08-2017 / 23:06:02 / cg"
4016
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   306
    "Modified (comment): / 17-09-2017 / 13:37:53 / cg"
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   307
!
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   308
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   309
read24RLE
4016
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   310
    "read an 8 bit/pixel rle encoded targa-image.
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   311
     Notice, that the channels are in bgr order; not rgb"
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   312
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   313
    |total count dstIndex code n r g b|
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   314
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   315
    data := ByteArray new:((total := width * height * 3)).
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   316
    count := 0.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   317
    dstIndex := 1.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   318
    [count < total] whileTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   319
        code := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   320
        n := (code bitAnd:16r7F) + 1.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   321
        (code bitAnd:16r80) ~~ 0 ifTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   322
            b := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   323
            g := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   324
            r := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   325
            n timesRepeat:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   326
                data at:dstIndex put:r.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   327
                data at:dstIndex+1 put:g.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   328
                data at:dstIndex+2 put:b.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   329
                dstIndex := dstIndex + 3
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   330
            ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   331
        ] ifFalse:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   332
            n timesRepeat:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   333
                b := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   334
                g := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   335
                r := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   336
                data at:dstIndex put:r.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   337
                data at:dstIndex+1 put:g.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   338
                data at:dstIndex+2 put:b.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   339
                dstIndex := dstIndex + 3
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   340
            ]
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   341
        ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   342
        count := count + (n * 3).
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   343
    ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   344
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   345
    "Created: / 21-04-1997 / 20:43:23 / cg"
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   346
    "Modified: / 29-08-2017 / 23:06:35 / cg"
4016
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   347
    "Modified (comment): / 17-09-2017 / 13:37:58 / cg"
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   348
!
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   349
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   350
read32
4016
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   351
    "read a 32 bit/pixel targa-image.
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   352
     Notice, that the channels are in bgra order; not rgba"
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   353
1738
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   354
    |totalBytes remainingBytes dstIndex a r g b|
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   355
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   356
    totalBytes := width * height * 4.
1738
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   357
    data := ByteArray new:totalBytes.
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   358
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   359
    dstIndex := 1.
1738
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   360
    remainingBytes := totalBytes.
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   361
    [remainingBytes > 0] whileTrue:[
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   362
        b := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   363
        g := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   364
        r := inStream nextByte.
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   365
        a := inStream nextByte.  
1738
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   366
        data at:dstIndex   put:r.
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   367
        data at:dstIndex+1 put:g.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   368
        data at:dstIndex+2 put:b.
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   369
        data at:dstIndex+3 put:a.
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   370
        dstIndex := dstIndex + 4.
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   371
        remainingBytes := remainingBytes - 4.
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   372
    ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   373
1738
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   374
    "
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   375
     TargaReader fromFile:'/phys/exept//unsaved1/pd_stuff/graphic/3d_engines/crystal_space/CS/plugins/video/canvas/sdl/img/move.tga'
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   376
     TargaReader fromFile:'/phys/exept/unsaved2/smalltalk/Squeak/croquet/Croquet/Content/Cisco/2520/Textures/2520caseback.tga'
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   377
     TargaReader fromFile:'/phys/exept/unsaved2/smalltalk/Squeak/croquet/Croquet/Content/Cisco/2520/Textures/2520dimm1front.tga'
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   378
    "
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   379
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   380
    "Modified: / 29-08-2017 / 23:09:42 / cg"
4016
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   381
    "Modified (comment): / 17-09-2017 / 13:37:26 / cg"
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   382
!
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   383
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   384
read32RLE
4016
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   385
    "read a 32 bit/pixel rle encoded targa-image; skip alpha channel (for now).
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   386
     Notice, that the channels are in bgra order; not rgba"
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   387
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   388
    |total count dstIndex code n a r g b|
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   389
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   390
    data := ByteArray new:((total := width * height * 4)).
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   391
    count := 0.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   392
    dstIndex := 1.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   393
    [count < total] whileTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   394
        code := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   395
        n := (code bitAnd:16r7F) + 1.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   396
        (code bitAnd:16r80) ~~ 0 ifTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   397
            b := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   398
            g := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   399
            r := inStream nextByte.
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   400
            a := inStream nextByte.  
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   401
            n timesRepeat:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   402
                data at:dstIndex put:r.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   403
                data at:dstIndex+1 put:g.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   404
                data at:dstIndex+2 put:b.
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   405
                data at:dstIndex+3 put:a.
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   406
                dstIndex := dstIndex + 4
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   407
            ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   408
        ] ifFalse:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   409
            n timesRepeat:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   410
                b := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   411
                g := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   412
                r := inStream nextByte.
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   413
                a := inStream nextByte.        
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   414
                data at:dstIndex put:r.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   415
                data at:dstIndex+1 put:g.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   416
                data at:dstIndex+2 put:b.
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   417
                data at:dstIndex+3 put:a.
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   418
                dstIndex := dstIndex + 4
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   419
            ]
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   420
        ].
4002
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   421
        count := count + (n * 4).
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   422
    ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   423
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   424
    "Created: / 21-04-1997 / 20:43:54 / cg"
4002
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   425
    "Modified: / 29-08-2017 / 23:35:48 / cg"
4016
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   426
    "Modified (comment): / 17-09-2017 / 13:37:37 / cg"
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   427
!
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   428
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   429
read8
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   430
    "read an 8 bit/pixel targa-image"
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   431
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   432
    data := ByteArray new:(width * height).
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   433
    inStream nextBytes:(data size) into:data.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   434
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   435
    "Created: / 21-04-1997 / 20:12:35 / cg"
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   436
    "Modified: / 29-08-2017 / 23:10:32 / cg"
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   437
!
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   438
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   439
read8RLE
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   440
    "read an 8 bit/pixel rle encoded targa-image"
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   441
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   442
    |total count dstIndex code n byte|
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   443
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   444
    data := ByteArray new:((total := width * height)).
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   445
    count := 0.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   446
    dstIndex := 1.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   447
    [count < total] whileTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   448
        code := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   449
        n := (code bitAnd:16r7F) + 1.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   450
        (code bitAnd:16r80) ~~ 0 ifTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   451
            byte := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   452
            data from:dstIndex to:dstIndex+n-1 put:byte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   453
        ] ifFalse:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   454
            inStream nextBytes:n into:data startingAt:dstIndex.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   455
        ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   456
        count := count + n.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   457
        dstIndex := dstIndex + n.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   458
    ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   459
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   460
    "Created: / 21-04-1997 / 20:19:46 / cg"
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   461
    "Modified: / 29-08-2017 / 23:10:46 / cg"
1738
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   462
!
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   463
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   464
readColorMap:cmapLength
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   465
    colorMap := Array new:cmapLength.
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   466
    1 to:cmapLength do:[:index |
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   467
        |r g b|
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   468
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   469
        b := inStream nextByte.
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   470
        g := inStream nextByte.
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   471
        r := inStream nextByte.
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   472
        (r isNil or:[g isNil or:[b isNil]]) ifTrue:[
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   473
            ^ self fileFormatError:('short file - probably not targa format').
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   474
        ].
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   475
        colorMap at:index put:(Color redByte:r greenByte:g blueByte:b).
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   476
    ].
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   477
    ^ colorMap
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   478
! !
aeed5856f457 Initial revision
claus
parents:
diff changeset
   479
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   480
!TargaReader methodsFor:'reading'!
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   481
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   482
readImage
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   483
    "read a targa-image from aFileName. return the receiver (with all
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   484
     relevant instance variables set for the image) or nil on error"
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   485
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   486
    |depth flags lenID hasColorMap 
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   487
     cmapOffset cmapLength cmapEntrySize xOrg yOrg rle|
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   488
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   489
    inStream binary.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   490
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   491
    lenID := inStream next.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   492
    hasColorMap := inStream next.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   493
    imageType := inStream next.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   494
    cmapOffset := inStream nextShortMSB:false.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   495
    cmapLength := inStream nextShortMSB:false.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   496
    cmapEntrySize := inStream next.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   497
    xOrg := inStream nextShortMSB:false.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   498
    yOrg := inStream nextShortMSB:false.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   499
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   500
    width := inStream nextShortMSB:false.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   501
    height := inStream nextShortMSB:false.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   502
    depth := inStream next.
4002
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   503
    (#(8 15 16 24 32) includes:depth) ifFalse:[
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   504
        ^ self fileFormatError:'unsupported depth: %1' with:depth printString.
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   505
    ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   506
    depth == 32 ifTrue:[
4016
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   507
        Logger warning: 'TargaReader [info]: alpha channel ignored'.
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   508
    ] ifFalse:[
4016
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   509
        Verbose == true ifTrue:[ Logger info:'TargaReader [info]: depth: %1' with:depth ].
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   510
    ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   511
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   512
    "/ MapRGB == 1
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   513
    "/ RawRGB == 2
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   514
    "/ RawMono == 3
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   515
    "/ MapEnCode == 9
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   516
    "/ RawEnCode == 10
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   517
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   518
    (#(1 2 3 9 10) includes:imageType) ifFalse:[
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   519
        "/ 'TargaReader [warning]: unsupported imageType: ' errorPrint. imageType errorPrintCR.
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   520
        ^ self fileFormatError:'unsupported imageType: %1' with:imageType printString.
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   521
    ].
4016
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   522
    Verbose == true ifTrue:[ Logger info:'TargaReader [info]: imageType: %1' with:imageType].
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   523
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   524
    self reportDimension.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   525
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   526
    "/ flags:
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   527
    "/    0000 xxxx  attribute-bits-per-pixel
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   528
    "/    0000 0001  greysc
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   529
    "/    0000 0010  colour
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   530
    "/    0000 0011  mapped
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   531
    "/    0000 0100  rleEncoded
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   532
    "/    0000 1000  interlaced
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   533
    "/    00xx 0000  origin (0 -> lower-left / 1 -> l-r / 2 -> u-l / 3 -> u-r)
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   534
    "/    xx00 0000  interleave (0 -> none / 1 -> odd/even / 2 ->4-fould / 3 reserved)
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   535
    "/
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   536
    flags := inStream next.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   537
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   538
    (flags bitAnd:2r11000000) ~~ 0 ifTrue:[
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   539
        ^ self fileFormatError:'unsupported interlace: %1' with:flags printString.
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   540
    ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   541
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   542
    rle := flags bitTest:2r000001000.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   543
    flags := flags bitAnd:2r111110111.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   544
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   545
    (flags bitAnd:2r00001111) ~~ 0 ifTrue:[
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   546
        ^ self fileFormatError:'unsupported flags: %1' with:flags printString.
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   547
    ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   548
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   549
    (flags bitAnd:2r00110000) == 16r20 ifTrue:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   550
        orientation := #topLeft
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   551
    ] ifFalse:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   552
        (flags bitAnd:2r00110000) == 16r30 ifTrue:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   553
            orientation := #topRight
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   554
        ] ifFalse:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   555
            (flags bitAnd:2r00110000) == 16r10 ifTrue:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   556
                orientation := #bottomRight
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   557
            ] ifFalse:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   558
                (flags bitAnd:2r00110000) == 0 ifTrue:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   559
                    orientation := #bottomLeft
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   560
                ]
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   561
            ]
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   562
        ]
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   563
    ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   564
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   565
    lenID ~~ 0 ifTrue:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   566
        inStream skip:lenID
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   567
    ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   568
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   569
    hasColorMap ~~ 0 ifTrue:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   570
        "/ read the colorMap
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   571
        colorMap := self readColorMap:cmapLength.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   572
        'TargaReader [info]: has colorMap' infoPrintCR.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   573
    ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   574
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   575
    depth == 32 ifTrue:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   576
        imageType == 2 ifTrue:[
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   577
            "/ rle ifTrue:[self halt:'oops - should not happen'].
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   578
            self read32.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   579
        ] ifFalse:[
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   580
            "/ rle ifFalse:[self halt:'oops - should not happen'].
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   581
            self read32RLE.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   582
        ].
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   583
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   584
        photometric := #rgba.
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   585
        samplesPerPixel := 4.
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   586
        bitsPerSample := #(8 8 8 8).
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   587
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   588
        bytesPerRow := width*4.
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   589
        bytesPerPixel := 4.
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   590
    ].
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   591
    
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   592
    depth == 24 ifTrue:[
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   593
        imageType == 2 ifTrue:[
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   594
            "/ rle ifTrue:[self halt:'oops - should not happen'].
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   595
            self read24.
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   596
        ] ifFalse:[
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   597
            "/ rle ifFalse:[self halt:'oops - should not happen'].
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   598
            self read24RLE.
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   599
        ].
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   600
        
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   601
        photometric := #rgb.
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   602
        samplesPerPixel := 3.
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   603
        bitsPerSample := #(8 8 8).
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   604
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   605
        bytesPerRow := width*3.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   606
        bytesPerPixel := 3.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   607
    ].
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   608
    
4002
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   609
    ((depth == 15) or:[depth == 16]) ifTrue:[
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   610
        imageType == 2 ifTrue:[
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   611
            "/ rle ifTrue:[self halt:'oops - should not happen'].
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   612
            self read16.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   613
        ] ifFalse:[
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   614
            "/ rle ifFalse:[self halt:'oops - should not happen'].
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   615
            self read16RLE.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   616
        ].
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   617
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   618
        photometric := #rgb.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   619
        samplesPerPixel := 3.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   620
        bitsPerSample := #(5 5 5).
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   621
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   622
        bytesPerRow := width*2.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   623
        bytesPerPixel := 2.
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   624
    ].
91e154c3580d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
   625
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   626
    depth == 8 ifTrue:[
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   627
        (imageType == 1 or:[imageType == 3]) ifTrue:[
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   628
            "/ rle ifTrue:[self halt:'oops - should not happen'].
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   629
            self read8.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   630
        ] ifFalse:[
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   631
            "/ rle ifFalse:[self halt:'oops - should not happen'].
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   632
            self read8RLE
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   633
        ].
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   634
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   635
        (imageType == 3 or:[colorMap isNil]) ifTrue:[
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   636
            photometric := #blackIs0.
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   637
        ] ifFalse:[
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   638
            photometric := #palette.
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   639
        ].
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   640
        samplesPerPixel := 1.
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   641
        bitsPerSample := #(8).
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   642
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   643
        bytesPerRow := width.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   644
        bytesPerPixel := 1.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   645
    ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   646
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   647
    self handleImageOrientation.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   648
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   649
    "
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   650
     TargaReader fromFile:'bitmaps/test.tga' 
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   651
    "
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   652
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   653
    "Modified: / 13-10-1998 / 19:50:48 / ps"
4016
47c4ea8134ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4002
diff changeset
   654
    "Modified: / 18-09-2017 / 08:56:24 / cg"
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   655
! !
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   656
210
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   657
!TargaReader class methodsFor:'documentation'!
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   658
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   659
version
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   660
    ^ '$Header$'
4001
153c0234371a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3998
diff changeset
   661
!
153c0234371a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3998
diff changeset
   662
153c0234371a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3998
diff changeset
   663
version_CVS
153c0234371a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3998
diff changeset
   664
    ^ '$Header$'
210
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   665
! !
1738
9c85e9d8326b refactorings
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   666
3998
f38061cec746 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   667
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   668
TargaReader initialize!