IrisRGBReader.st
author Claus Gittinger <cg@exept.de>
Thu, 10 Apr 2003 16:26:11 +0200
changeset 1745 4fa0fad2a463
parent 919 d0e28bc28b25
child 1753 aa246112438a
permissions -rw-r--r--
code cleanup (colorMap handling) category change
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
              All Rights Reserved
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 919
diff changeset
    13
"{ Package: 'stx:libview2' }"
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 919
diff changeset
    14
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
ImageReader subclass:#IrisRGBReader
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	instanceVariableNames:'bytesPerPixel'
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	classVariableNames:''
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	poolDictionaries:''
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 919
diff changeset
    19
	category:'Graphics-Images-Readers'
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
!
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
!IrisRGBReader class methodsFor:'documentation'!
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
copyright
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
"
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
 COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
              All Rights Reserved
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 This software is furnished under a license and may be used
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 only in accordance with the terms of that license and with the
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 be provided or otherwise made available to, or used by, any
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 other person.  No title to or ownership of the software is
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 hereby transferred.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
"
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
!
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
documentation
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
"
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
    this class provides methods for loading Iris RGB format images. 
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    Only 3-byte/pixel format is supported.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    Writing is not (yet) supported.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    [author:]
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
        Claus Gittinger
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
    [See also:]
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
        Image Form Icon
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
        BlitImageReader FaceReader GIFReader JPEGReader PCXReader 
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
        ST80FormReader SunRasterReader TargaReader TIFFReader WindowsIconReader 
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
        XBMReader XPMReader XWDReader 
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
"
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
! !
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
!IrisRGBReader class methodsFor:'initialization'!
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
initialize
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    "install myself in the Image classes fileFormat table
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
     for the `.rgb' extension."
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
647
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    61
    MIMETypes defineImageType:'image/x-rgb' suffix:'rgb' reader:self.
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    "Modified: 14.4.1997 / 15:49:19 / cg"
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
! !
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
!IrisRGBReader class methodsFor:'testing'!
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
isValidImageFile:aFileName
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
    "return true, if aFileName contains an IRIS_RGB image"
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    |inStream magic type bpp dim w h bytesPerPixel|
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    inStream := self streamReadingFile:aFileName.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    inStream isNil ifTrue:[^ false].
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
    inStream binary.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
    magic := inStream nextShortMSB:true.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    type := inStream nextShortMSB:true.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    dim := inStream nextShortMSB:true.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    w := inStream nextShortMSB:true.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
    h := inStream nextShortMSB:true.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
    bytesPerPixel := inStream nextShortMSB:true.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
    inStream close.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    magic ~~ 8r0732 ifTrue:[^ false].
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
    bpp := type bitAnd:16r00FF.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    bpp ~~ 1 ifTrue:[^ false].
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    bytesPerPixel ~~ 3 ifTrue:[^ false].
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
    ^ true
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    "
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
     IrisRGBReader isValidImageFile:'/home2/cg/capture.rgb'
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
    "
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
    "Modified: 14.4.1997 / 16:51:58 / cg"
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
! !
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
!IrisRGBReader methodsFor:'reading from file'!
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
fromStream:aStream
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    "read a Portable bitmap file format as of Jeff Poskanzers Portable Bitmap Package.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
     supported are IRIS_RGB, PGB and PNM files." 
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
    | magic type dim isRLE bpp|
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
    inStream := aStream.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
    inStream binary.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    magic := inStream nextShortMSB:true.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    magic ~~ 8r0732 ifTrue:[
810
93a9f3c4d8ec use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   113
        ^ self fileFormatError:'bad magic number'.
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    ].
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
    type := inStream nextShortMSB:true.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
    dim := inStream nextShortMSB:true.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    width := inStream nextShortMSB:true.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
    height := inStream nextShortMSB:true.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    bytesPerPixel := inStream nextShortMSB:true.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
    isRLE := (type bitAnd:16rFF00) == 16r0100.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    bpp := type bitAnd:16r00FF.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
    bpp ~~ 1 ifTrue:[
810
93a9f3c4d8ec use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   125
        ^ self fileFormatError:'only 1byte/pixel channel supported'.
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
    ].
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    bytesPerPixel ~~ 3 ifTrue:[
810
93a9f3c4d8ec use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   128
        ^ self fileFormatError:'can only read 3-channel images'.
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
    ].
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
    isRLE ifTrue:[
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
        self readRLEData
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
    ] ifFalse:[
810
93a9f3c4d8ec use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   134
        ^ self fileFormatError:'currently, only RLE encoding supported'.
883
5e3c3d895f7d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 810
diff changeset
   135
        "/ self readVerbatimData
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
    ].
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
    photometric := #rgb.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    samplesPerPixel := 3.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
    bitsPerSample := #(8 8 8).
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
    "
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
     IrisRGBReader fromFile:'/home2/cg/capture.rgb'
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
    "
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
810
93a9f3c4d8ec use common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   146
    "Created: / 14.4.1997 / 15:38:51 / cg"
883
5e3c3d895f7d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 810
diff changeset
   147
    "Modified: / 1.4.1998 / 14:28:51 / cg"
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
!
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
readRLEData 
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
    "read RLE compressed data"
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
    |rleBufferLen tableLen startTable lengthTable rleData
919
d0e28bc28b25 unused locals
tz
parents: 883
diff changeset
   154
     tblIdx dstIdx|
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
    rleBufferLen := width * 2 + 10.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
    tableLen := height * bytesPerPixel.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
    startTable := Array new:tableLen.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
    lengthTable := Array new:tableLen.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
    rleData := ByteArray uninitializedNew:rleBufferLen.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
    "/ read rowStart & length table
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
    inStream position:512+1.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
    1 to:tableLen do:[:i |
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
        startTable at:i put:(inStream nextLongMSB:true).
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
    ].
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
    1 to:tableLen do:[:i |
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
        lengthTable at:i put:(inStream nextLongMSB:true).
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
    ].
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
    data := ByteArray uninitializedNew:(width*height*3).
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
    dstIdx := width * (height-1) * 3 + 1.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
    0 to:(height-1) do:[:y |
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
        0 to:(bytesPerPixel-1) do:[:z |
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
            |start length|
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
            tblIdx := y + (z*height) + 1.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
            start := startTable at:tblIdx.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
            length := lengthTable at:tblIdx.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
            inStream position:(start + 1).
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
            (inStream nextBytes:length into:rleData startingAt:1) ~~ length ifTrue:[
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
                self halt:'short read'
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
            ].
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
            (rleData at:length) ~~ 0 ifTrue:[
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
                self halt.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
            ].
559
06bcbb6e3f32 use common RLE helper
Claus Gittinger <cg@exept.de>
parents: 527
diff changeset
   193
06bcbb6e3f32 use common RLE helper
Claus Gittinger <cg@exept.de>
parents: 527
diff changeset
   194
            self class
06bcbb6e3f32 use common RLE helper
Claus Gittinger <cg@exept.de>
parents: 527
diff changeset
   195
                decompressRLEFrom:rleData at:1 
06bcbb6e3f32 use common RLE helper
Claus Gittinger <cg@exept.de>
parents: 527
diff changeset
   196
                into:data at:dstIdx+z increment:3.
06bcbb6e3f32 use common RLE helper
Claus Gittinger <cg@exept.de>
parents: 527
diff changeset
   197
06bcbb6e3f32 use common RLE helper
Claus Gittinger <cg@exept.de>
parents: 527
diff changeset
   198
"/            self expandRow:rleData to:dstIdx+z. "/ (3-z).
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
        ].
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
        dstIdx := dstIdx - (width * 3).
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
    ].
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
    "
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
     IrisRGBReader fromFile:'/home2/cg/capture.rgb'
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
    "
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
559
06bcbb6e3f32 use common RLE helper
Claus Gittinger <cg@exept.de>
parents: 527
diff changeset
   207
    "Modified: 23.4.1997 / 18:59:11 / cg"
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
! !
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
!IrisRGBReader methodsFor:'testing '!
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
canRepresent:anImage
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
    "return true, if anImage can be represented in my file format.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
     Currently only B&W and Depth8 images are supported."
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
919
d0e28bc28b25 unused locals
tz
parents: 883
diff changeset
   216
"/    |depth|
d0e28bc28b25 unused locals
tz
parents: 883
diff changeset
   217
"/
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
"/    anImage photometric == #rgb ifTrue:[
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
"/        ^ false  "/ not yet implemented
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
"/    ].
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
"/    (depth := anImage depth) == 1 ifTrue:[^ true].
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
"/    depth == 8 ifTrue:[^ true].
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
    ^ false
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
    "Created: 14.4.1997 / 15:38:51 / cg"
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
    "Modified: 14.4.1997 / 15:58:20 / cg"
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
! !
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
!IrisRGBReader class methodsFor:'documentation'!
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
version
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 919
diff changeset
   232
    ^ '$Header: /cvs/stx/stx/libview2/IrisRGBReader.st,v 1.8 2003-04-10 14:25:31 cg Exp $'
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
! !
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 919
diff changeset
   234
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
IrisRGBReader initialize!