TargaReader.st
author Claus Gittinger <cg@exept.de>
Fri, 27 Jun 1997 18:47:27 +0200
changeset 630 48657c687a8b
parent 556 a2d03470af59
child 647 6f26c76aa0c9
permissions -rw-r--r--
checkin from browser
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
"
aeed5856f457 Initial revision
claus
parents:
diff changeset
    12
aeed5856f457 Initial revision
claus
parents:
diff changeset
    13
ImageReader subclass:#TargaReader
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
    14
	instanceVariableNames:'orientation'
210
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    15
	classVariableNames:''
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    16
	poolDictionaries:''
259
62b1bbafd9ba category change
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
    17
	category:'Graphics-Images-Support'
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
    18
!
aeed5856f457 Initial revision
claus
parents:
diff changeset
    19
aeed5856f457 Initial revision
claus
parents:
diff changeset
    20
!TargaReader class methodsFor:'documentation'!
aeed5856f457 Initial revision
claus
parents:
diff changeset
    21
aeed5856f457 Initial revision
claus
parents:
diff changeset
    22
copyright
aeed5856f457 Initial revision
claus
parents:
diff changeset
    23
"
aeed5856f457 Initial revision
claus
parents:
diff changeset
    24
 COPYRIGHT (c) 1994 by Claus Gittinger
aeed5856f457 Initial revision
claus
parents:
diff changeset
    25
	      All Rights Reserved
aeed5856f457 Initial revision
claus
parents:
diff changeset
    26
aeed5856f457 Initial revision
claus
parents:
diff changeset
    27
 This software is furnished under a license and may be used
aeed5856f457 Initial revision
claus
parents:
diff changeset
    28
 only in accordance with the terms of that license and with the
aeed5856f457 Initial revision
claus
parents:
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
aeed5856f457 Initial revision
claus
parents:
diff changeset
    30
 be provided or otherwise made available to, or used by, any
aeed5856f457 Initial revision
claus
parents:
diff changeset
    31
 other person.  No title to or ownership of the software is
aeed5856f457 Initial revision
claus
parents:
diff changeset
    32
 hereby transferred.
aeed5856f457 Initial revision
claus
parents:
diff changeset
    33
"
aeed5856f457 Initial revision
claus
parents:
diff changeset
    34
!
aeed5856f457 Initial revision
claus
parents:
diff changeset
    35
aeed5856f457 Initial revision
claus
parents:
diff changeset
    36
documentation
aeed5856f457 Initial revision
claus
parents:
diff changeset
    37
"
aeed5856f457 Initial revision
claus
parents:
diff changeset
    38
    this class provides methods for loading targa-file (tga) images.
556
a2d03470af59 documentation
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
    39
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
    40
    Limitations: 
556
a2d03470af59 documentation
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
    41
        not fully tested (I only had a few targa files to check things)
a2d03470af59 documentation
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
    42
        only supports 8,24 and 32 bits/pixel formats; alpha channel is ignored
210
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    43
        Image saving not supported
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
    44
aeed5856f457 Initial revision
claus
parents:
diff changeset
    45
    I had two tga files to test this code with - it may not work with
556
a2d03470af59 documentation
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
    46
    other targa files (it certainly does not work with 1/16 bit images).
299
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    47
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
    48
    Suggestions: adapt & use the pbmplus library here.
210
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    49
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    50
    [See also:]
234
b6352d13e792 xrefs in documentation
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    51
        Image Form Icon
210
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    52
        BlitImageReader FaceReader GIFReader JPEGReader PBMReader PCXReader 
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    53
        ST80FormReader SunRasterReader TIFFReader WindowsIconReader 
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    54
        XBMReader XPMReader XWDReader
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
    55
"
aeed5856f457 Initial revision
claus
parents:
diff changeset
    56
! !
aeed5856f457 Initial revision
claus
parents:
diff changeset
    57
aeed5856f457 Initial revision
claus
parents:
diff changeset
    58
!TargaReader class methodsFor:'initialization'!
aeed5856f457 Initial revision
claus
parents:
diff changeset
    59
aeed5856f457 Initial revision
claus
parents:
diff changeset
    60
initialize
210
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    61
    "tell Image-class, that a new fileReader is present
398
aef700d15416 new suffix-table
Claus Gittinger <cg@exept.de>
parents: 299
diff changeset
    62
     for the '.tga' extension."
210
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    63
630
48657c687a8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 556
diff changeset
    64
    Image addReader:self suffix:'tga' mimeType:'image/x-targa'.
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
    65
630
48657c687a8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 556
diff changeset
    66
    "Modified: 27.6.1997 / 18:39:43 / cg"
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
    67
! !
aeed5856f457 Initial revision
claus
parents:
diff changeset
    68
aeed5856f457 Initial revision
claus
parents:
diff changeset
    69
!TargaReader class methodsFor:'testing'!
aeed5856f457 Initial revision
claus
parents:
diff changeset
    70
aeed5856f457 Initial revision
claus
parents:
diff changeset
    71
isValidImageFile:aFileName
aeed5856f457 Initial revision
claus
parents:
diff changeset
    72
    "return true, if aFileName contains a targa-file image"
aeed5856f457 Initial revision
claus
parents:
diff changeset
    73
43
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
    74
    |aStream w h depth flags|
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
    75
43
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
    76
    aStream := self streamReadingFile:aFileName.
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
    77
    aStream isNil ifTrue:[^ false].
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
    78
    aStream binary.
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
    79
    aStream skip:12.   "/ skip 12 bytes
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
    80
43
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
    81
    w := aStream nextShortMSB:false.
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
    82
    h := aStream nextShortMSB:false.
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
    83
43
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
    84
    depth := aStream next.
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
    85
    flags := aStream next.
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
    86
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
    87
    (#(8 "16" 24 32) includes:depth) ifFalse:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
    88
        aStream close. ^ false
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
    89
    ].
aeed5856f457 Initial revision
claus
parents:
diff changeset
    90
43
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
    91
    aStream close. 
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
    92
    ^ true
aeed5856f457 Initial revision
claus
parents:
diff changeset
    93
aeed5856f457 Initial revision
claus
parents:
diff changeset
    94
    "
aeed5856f457 Initial revision
claus
parents:
diff changeset
    95
     TargaReader isValidImageFile:'bitmaps/test.tga'    
aeed5856f457 Initial revision
claus
parents:
diff changeset
    96
     TargaReader isValidImageFile:'bitmaps/garfield.gif'  
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
    97
    "
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
    98
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
    99
    "Modified: 21.4.1997 / 20:46:52 / cg"
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   100
! !
aeed5856f457 Initial revision
claus
parents:
diff changeset
   101
aeed5856f457 Initial revision
claus
parents:
diff changeset
   102
!TargaReader methodsFor:'reading from file'!
aeed5856f457 Initial revision
claus
parents:
diff changeset
   103
43
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
   104
fromStream:aStream
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   105
    "read a targa-image from aFileName. return the receiver (with all
aeed5856f457 Initial revision
claus
parents:
diff changeset
   106
     relevant instance variables set for the image) or nil on error"
aeed5856f457 Initial revision
claus
parents:
diff changeset
   107
299
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   108
    |depth flags nBytes ok lenID hasColorMap imageType 
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   109
     cmapOffset cmapLength cmapEntrySize xOrg yOrg
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   110
     t bytesPerPixel bytesPerRow rowIdx startIdx endIdx rle
299
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   111
     dSize "{ Class: SmallInteger }" |
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   112
43
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
   113
    inStream := aStream.
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
   114
    aStream binary.
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
   115
299
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   116
    lenID := aStream next.
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   117
    hasColorMap := aStream next.
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   118
    imageType := aStream next.
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   119
    cmapOffset := aStream nextShortMSB:false.
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   120
    cmapLength := aStream nextShortMSB:false.
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   121
    cmapEntrySize := aStream next.
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   122
    xOrg := aStream nextShortMSB:false.
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   123
    yOrg := aStream nextShortMSB:false.
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   124
43
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
   125
    width := aStream nextShortMSB:false.
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
   126
    height := aStream nextShortMSB:false.
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
   127
    depth := aStream next.
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   128
    (#(8 "16" 24 32) includes:depth) ifFalse:[
551
7e0fb2e4f214 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   129
        'TargaReader [warning]: unsupported depth: ' errorPrint. depth errorPrintCR.
299
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   130
        ^ nil
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   131
    ].
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   132
    depth == 32 ifTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   133
        'TargaReader [info]: alpha channel ignored' infoPrintCR.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   134
    ] ifFalse:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   135
        'TargaReader [info]: depth: ' infoPrint. depth infoPrintCR.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   136
    ].
551
7e0fb2e4f214 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   137
7e0fb2e4f214 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   138
    "/ MapRGB == 1
7e0fb2e4f214 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   139
    "/ RawRGB == 2
7e0fb2e4f214 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   140
    "/ RawMono == 3
7e0fb2e4f214 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   141
    "/ MapEnCode == 9
7e0fb2e4f214 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   142
    "/ RawEnCode == 10
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   143
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   144
    (#(1 2 9 10) includes:imageType) ifFalse:[
551
7e0fb2e4f214 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   145
        'TargaReader [warning]: unsupported imageType: ' errorPrint. imageType errorPrintCR.
7e0fb2e4f214 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   146
    ].
7e0fb2e4f214 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   147
    'TargaReader [info]: imageType: ' infoPrint. imageType infoPrintCR.
299
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   148
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   149
    "/ flags:
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   150
    "/    0000 xxxx  attribute-bits-per-pixel
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   151
    "/    0000 0001  greysc
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   152
    "/    0000 0010  colour
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   153
    "/    0000 0011  mapped
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   154
    "/    0000 0100  rleEncoded
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   155
    "/    0000 1000  interlaced
299
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   156
    "/    00xx 0000  origin (0 -> lower-left / 1 -> l-r / 2 -> u-l / 3 -> u-r)
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   157
    "/    xx00 0000  interleave (0 -> none / 1 -> odd/even / 2 ->4-fould / 3 reserved)
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   158
    "/
43
e85c7d392833 *** empty log message ***
claus
parents: 37
diff changeset
   159
    flags := aStream next.
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   160
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   161
    (flags bitAnd:2r11000000) ~~ 0 ifTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   162
        'TargaReader [warning]: unsupported interlace: ' errorPrint. flags errorPrintCR.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   163
        ^ nil
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   164
    ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   165
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   166
    rle := flags bitTest:2r000001000.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   167
    flags := flags bitAnd:2r111110111.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   168
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   169
    (flags bitAnd:2r00001111) ~~ 0 ifTrue:[
551
7e0fb2e4f214 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   170
        'TargaReader [warning]: unsupported flags: ' errorPrint. flags errorPrintCR.
7e0fb2e4f214 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   171
        ^ nil
7e0fb2e4f214 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   172
    ].
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   173
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   174
    (flags bitAnd:2r00110000) == 16r20 ifTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   175
        orientation := #topLeft
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   176
    ] ifFalse:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   177
        (flags bitAnd:2r00110000) == 16r30 ifTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   178
            orientation := #topRight
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   179
        ] ifFalse:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   180
            (flags bitAnd:2r00110000) == 16r10 ifTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   181
                orientation := #bottomRight
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   182
            ] ifFalse:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   183
                (flags bitAnd:2r00110000) == 0 ifTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   184
                    orientation := #bottomLeft
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   185
                ]
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   186
            ]
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   187
        ]
299
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   188
    ].
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   189
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   190
    lenID ~~ 0 ifTrue:[
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   191
        aStream skip:lenID
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   192
    ].
aeed5856f457 Initial revision
claus
parents:
diff changeset
   193
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   194
    hasColorMap ~~ 0 ifTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   195
        "/ read the colorMap
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   196
        colorMap := Array new:cmapLength.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   197
        1 to:cmapLength do:[:index |
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   198
            |r g b|
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   199
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   200
            b := aStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   201
            g := aStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   202
            r := aStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   203
            colorMap at:index put:(Color redByte:r greenByte:g blueByte:b).
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   204
        ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   205
        'TargaReader [info]: has colorMap' infoPrintCR.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   206
    ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   207
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   208
    depth == 32 ifTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   209
        imageType == 2 ifTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   210
"/            rle ifTrue:[self halt].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   211
            self read32.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   212
        ] ifFalse:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   213
"/            rle ifFalse:[self halt].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   214
            self read32RLE.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   215
        ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   216
        bytesPerRow := width*3.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   217
        bytesPerPixel := 3.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   218
    ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   219
    depth == 24 ifTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   220
        imageType == 2 ifTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   221
"/            rle ifTrue:[self halt].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   222
            self read24.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   223
        ] ifFalse:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   224
"/            rle ifFalse:[self halt].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   225
            self read24RLE.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   226
        ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   227
        bytesPerRow := width*3.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   228
        bytesPerPixel := 3.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   229
    ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   230
    depth == 8 ifTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   231
        imageType == 1 ifTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   232
"/            rle ifTrue:[self halt].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   233
            self read8.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   234
        ] ifFalse:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   235
"/            rle ifFalse:[self halt].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   236
            self read8RLE
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   237
        ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   238
        bytesPerRow := width.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   239
        bytesPerPixel := 1.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   240
    ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   241
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   242
    orientation == #topLeft ifTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   243
    ] ifFalse:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   244
        orientation == #topRight ifTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   245
            "/ flip horizontal
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   246
            rowIdx := 1.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   247
            1 to:height do:[:row |
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   248
                startIdx := rowIdx.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   249
                endIdx := rowIdx + bytesPerRow - bytesPerPixel.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   250
                1 to:width//2 do:[:x |
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   251
                    0 to:bytesPerPixel-1 do:[:c |
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   252
                        t := data at:startIdx+c.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   253
                        data at:startIdx+c put:(data at:endIdx+c).
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   254
                        data at:endIdx+c put:t.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   255
                    ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   256
                    startIdx := startIdx + bytesPerPixel.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   257
                    endIdx := endIdx - bytesPerPixel.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   258
                ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   259
                rowIdx := rowIdx + width.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   260
            ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   261
        ] ifFalse:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   262
            orientation == #bottomLeft ifTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   263
                "/ flip vertical
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   264
                startIdx := 1.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   265
                endIdx := 1 + ((height - 1) * bytesPerRow).
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   266
                t := ByteArray new:bytesPerRow.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   267
                1 to:height//2 do:[:row |
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   268
                    t replaceFrom:1 to:bytesPerRow with:data startingAt:startIdx.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   269
                    data replaceFrom:startIdx to:startIdx+bytesPerRow-1 with:data startingAt:endIdx.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   270
                    data replaceFrom:endIdx to:endIdx+bytesPerRow-1 with:t startingAt:1.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   271
                    startIdx := startIdx + bytesPerRow.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   272
                    endIdx := endIdx - bytesPerRow
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   273
                ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   274
            ] ifFalse:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   275
                'TargaReader [warning]: unsupported orientation: ' errorPrint. orientation errorPrintCR.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   276
            ]
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   277
        ]
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   278
    ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   279
    ^ self
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   280
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   281
    "
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   282
     TargaReader fromFile:'bitmaps/test.tga' 
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   283
    "
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   284
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   285
    "Modified: 21.4.1997 / 21:03:36 / cg"
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   286
!
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   287
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   288
read24
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   289
    "read a 24 bit/pixel targa-image"
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   290
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   291
    |nBytes ok dSize t|
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   292
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   293
    data := ByteArray new:(width * height * 3).
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   294
    inStream nextBytes:(dSize := data size) into:data.
299
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   295
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   296
    "
299
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   297
     mhmh - pixel-byte order is blue-green-red
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   298
     swap blue & red bytes
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   299
    "
107
Claus Gittinger <cg@exept.de>
parents: 96
diff changeset
   300
    nBytes := data size.
Claus Gittinger <cg@exept.de>
parents: 96
diff changeset
   301
    ok := false.
Claus Gittinger <cg@exept.de>
parents: 96
diff changeset
   302
Claus Gittinger <cg@exept.de>
parents: 96
diff changeset
   303
%{  /* OPTIONAL */
Claus Gittinger <cg@exept.de>
parents: 96
diff changeset
   304
    if (__isByteArray(_INST(data))) {
299
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   305
        int __lastIndex = __intVal(nBytes) - 2;
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   306
        unsigned char *__cp = __ByteArrayInstPtr(_INST(data))->ba_element;
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   307
        int __i;
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   308
        unsigned char __t;
107
Claus Gittinger <cg@exept.de>
parents: 96
diff changeset
   309
299
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   310
        for (__i=0; __i<__lastIndex; __i+=3, __cp+=3) {
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   311
            __t = __cp[0];
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   312
            __cp[0] = __cp[2];
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   313
            __cp[2] = __t;
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   314
        }
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   315
        ok = true;
107
Claus Gittinger <cg@exept.de>
parents: 96
diff changeset
   316
    }
Claus Gittinger <cg@exept.de>
parents: 96
diff changeset
   317
%}.
Claus Gittinger <cg@exept.de>
parents: 96
diff changeset
   318
    ok ifFalse:[
299
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   319
        1 to:(dSize - 2) by:3 do:[:i |
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   320
            t := data at:i.
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   321
            data at:i put:(data at:i+2).
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   322
            data at:i+2 put:t
23d89531904f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
   323
        ]
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   324
    ].
aeed5856f457 Initial revision
claus
parents:
diff changeset
   325
aeed5856f457 Initial revision
claus
parents:
diff changeset
   326
    photometric := #rgb.
aeed5856f457 Initial revision
claus
parents:
diff changeset
   327
    samplesPerPixel := 3.
aeed5856f457 Initial revision
claus
parents:
diff changeset
   328
    bitsPerSample := #(8 8 8).
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   329
!
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   330
555
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   331
read24RLE
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   332
    "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
   333
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   334
    |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
   335
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   336
    data := ByteArray new:((total := width * height * 3)).
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   337
    count := 0.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   338
    dstIndex := 1.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   339
    [count < total] whileTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   340
        code := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   341
        n := (code bitAnd:16r7F) + 1.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   342
        (code bitAnd:16r80) ~~ 0 ifTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   343
            b := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   344
            g := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   345
            r := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   346
            n timesRepeat:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   347
                data at:dstIndex put:r.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   348
                data at:dstIndex+1 put:g.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   349
                data at:dstIndex+2 put:b.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   350
                dstIndex := dstIndex + 3
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   351
            ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   352
        ] ifFalse:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   353
            n timesRepeat:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   354
                b := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   355
                g := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   356
                r := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   357
                data at:dstIndex put:r.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   358
                data at:dstIndex+1 put:g.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   359
                data at:dstIndex+2 put:b.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   360
                dstIndex := dstIndex + 3
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   361
            ]
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   362
        ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   363
        count := count + (n * 3).
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   364
    ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   365
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   366
    photometric := #rgb.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   367
    samplesPerPixel := 3.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   368
    bitsPerSample := #(8 8 8).
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   369
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   370
    "Modified: 21.4.1997 / 20:21:12 / cg"
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   371
    "Created: 21.4.1997 / 20:43:23 / cg"
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
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   374
read32
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   375
    "read a 32 bit/pixel targa-image; skip alpha channel (for now)"
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   376
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   377
    |total dstIndex a r g b|
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   378
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   379
    data := ByteArray new:((total := width * height * 3)).
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   380
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   381
    dstIndex := 1.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   382
    [total > 0] whileTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   383
        inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   384
        a := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   385
        b := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   386
        g := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   387
        r := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   388
        data at:dstIndex put:r.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   389
        data at:dstIndex+1 put:g.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   390
        data at:dstIndex+2 put:b.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   391
        dstIndex := dstIndex + 3.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   392
        total := total - 3.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   393
    ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   394
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   395
    photometric := #rgb.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   396
    samplesPerPixel := 3.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   397
    bitsPerSample := #(8 8 8).
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   398
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   399
    "Modified: 21.4.1997 / 20:21:12 / cg"
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   400
    "Created: 21.4.1997 / 20:45:35 / cg"
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   401
!
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   402
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   403
read32RLE
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   404
    "read a 32 bit/pixel rle encoded targa-image; skip alpha channel (for now)"
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   405
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   406
    |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
   407
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   408
    data := ByteArray new:((total := width * height * 3)).
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   409
    count := 0.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   410
    dstIndex := 1.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   411
    [count < total] whileTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   412
        code := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   413
        n := (code bitAnd:16r7F) + 1.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   414
        (code bitAnd:16r80) ~~ 0 ifTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   415
            a := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   416
            b := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   417
            g := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   418
            r := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   419
            n timesRepeat:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   420
                data at:dstIndex put:r.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   421
                data at:dstIndex+1 put:g.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   422
                data at:dstIndex+2 put:b.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   423
                dstIndex := dstIndex + 3
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   424
            ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   425
        ] ifFalse:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   426
            n timesRepeat:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   427
                a := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   428
                b := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   429
                g := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   430
                r := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   431
                data at:dstIndex put:r.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   432
                data at:dstIndex+1 put:g.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   433
                data at:dstIndex+2 put:b.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   434
                dstIndex := dstIndex + 3
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   435
            ]
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   436
        ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   437
        count := count + (n * 3).
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
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   440
    photometric := #rgb.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   441
    samplesPerPixel := 3.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   442
    bitsPerSample := #(8 8 8).
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
    "Created: 21.4.1997 / 20:43:54 / cg"
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   445
    "Modified: 21.4.1997 / 20:45:49 / cg"
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   446
!
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   447
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   448
read8
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   449
    "read an 8 bit/pixel targa-image"
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   450
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   451
    data := ByteArray new:(width * height).
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   452
    inStream nextBytes:(data size) into:data.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   453
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   454
    colorMap isNil ifTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   455
        photometric := #blackIs0.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   456
    ] ifFalse:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   457
        photometric := #palette.
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
    samplesPerPixel := 1.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   460
    bitsPerSample := #(8).
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   461
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   462
    "Created: 21.4.1997 / 20:12:35 / cg"
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   463
    "Modified: 21.4.1997 / 20:39:02 / cg"
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   464
!
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   465
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   466
read8RLE
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   467
    "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
   468
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   469
    |total count dstIndex code n byte|
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   470
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   471
    data := ByteArray new:((total := width * height)).
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   472
    count := 0.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   473
    dstIndex := 1.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   474
    [count < total] whileTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   475
        code := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   476
        n := (code bitAnd:16r7F) + 1.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   477
        (code bitAnd:16r80) ~~ 0 ifTrue:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   478
            byte := inStream nextByte.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   479
            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
   480
        ] ifFalse:[
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   481
            inStream nextBytes:n into:data startingAt:dstIndex.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   482
        ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   483
        count := count + n.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   484
        dstIndex := dstIndex + n.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   485
    ].
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   486
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   487
    photometric := #palette.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   488
    samplesPerPixel := 1.
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   489
    bitsPerSample := #(8).
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   490
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   491
    "Created: 21.4.1997 / 20:19:46 / cg"
f51ec2cc4482 support RLE, 8 and 32 bit images
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   492
    "Modified: 21.4.1997 / 20:21:12 / cg"
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   493
! !
aeed5856f457 Initial revision
claus
parents:
diff changeset
   494
210
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   495
!TargaReader class methodsFor:'documentation'!
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   496
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   497
version
630
48657c687a8b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 556
diff changeset
   498
    ^ '$Header: /cvs/stx/stx/libview2/TargaReader.st,v 1.14 1997-06-27 16:47:23 cg Exp $'
210
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   499
! !
37
aeed5856f457 Initial revision
claus
parents:
diff changeset
   500
TargaReader initialize!