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