IrisRGBReader.st
author Claus Gittinger <cg@exept.de>
Tue, 03 Sep 2013 17:23:55 +0200
changeset 3228 187a4158a51a
parent 3097 b067905c1c89
child 3855 1db7742d33ad
permissions -rw-r--r--
class: FlyByHelp changed: #initiateHelpFor:at:now: #showHelp:for: changed the flyBy suppression slightly: if the same text is to be shown again, do not show it except if the help is for another widget. (used to check for the text only previously)
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
"
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 919
diff changeset
    12
"{ Package: 'stx:libview2' }"
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 919
diff changeset
    13
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
ImageReader subclass:#IrisRGBReader
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	instanceVariableNames:'bytesPerPixel'
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	classVariableNames:''
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
1745
4fa0fad2a463 code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 919
diff changeset
    18
	category:'Graphics-Images-Readers'
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!IrisRGBReader class methodsFor:'documentation'!
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
copyright
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
"
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
 COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
              All Rights Reserved
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 This software is furnished under a license and may be used
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 only in accordance with the terms of that license and with the
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 be provided or otherwise made available to, or used by, any
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 other person.  No title to or ownership of the software is
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 hereby transferred.
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
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
documentation
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
"
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
    this class provides methods for loading Iris RGB format images. 
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
    Only 3-byte/pixel format is supported.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    Writing is not (yet) supported.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    [author:]
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
        Claus Gittinger
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
    [See also:]
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
        Image Form Icon
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
        BlitImageReader FaceReader GIFReader JPEGReader PCXReader 
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
        ST80FormReader SunRasterReader TargaReader TIFFReader WindowsIconReader 
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
        XBMReader XPMReader XWDReader 
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
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
!IrisRGBReader class methodsFor:'initialization'!
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
initialize
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    "install myself in the Image classes fileFormat table
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
     for the `.rgb' extension."
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
647
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    60
    MIMETypes defineImageType:'image/x-rgb' suffix:'rgb' reader:self.
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    "Modified: 14.4.1997 / 15:49:19 / cg"
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
! !
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
!IrisRGBReader class methodsFor:'testing'!
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
isValidImageFile:aFileName
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
    "return true, if aFileName contains an IRIS_RGB image"
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
    |inStream magic type bpp dim w h bytesPerPixel|
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
    inStream := self streamReadingFile:aFileName.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    inStream isNil ifTrue:[^ false].
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
    inStream binary.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
    magic := inStream nextShortMSB:true.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
    type := inStream nextShortMSB:true.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    dim := inStream nextShortMSB:true.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    w := inStream nextShortMSB:true.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    h := inStream nextShortMSB:true.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
    bytesPerPixel := inStream nextShortMSB:true.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
    inStream close.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
    magic ~~ 8r0732 ifTrue:[^ false].
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    bpp := type bitAnd:16r00FF.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
    bpp ~~ 1 ifTrue:[^ false].
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    bytesPerPixel ~~ 3 ifTrue:[^ false].
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
    ^ true
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
    "
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
     IrisRGBReader isValidImageFile:'/home2/cg/capture.rgb'
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
    "
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    "Modified: 14.4.1997 / 16:51:58 / cg"
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
! !
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
    99
!IrisRGBReader methodsFor:'private-reading'!
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
readRLEData 
2726
de3b045610a0 rgba files
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   102
    "read RLE compressed data."
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
    |rleBufferLen tableLen startTable lengthTable rleData
919
d0e28bc28b25 unused locals
tz
parents: 883
diff changeset
   105
     tblIdx dstIdx|
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
    rleBufferLen := width * 2 + 10.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
    tableLen := height * bytesPerPixel.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    startTable := Array new:tableLen.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    lengthTable := Array new:tableLen.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    rleData := ByteArray uninitializedNew:rleBufferLen.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    "/ read rowStart & length table
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
1753
aa246112438a avoid position
Claus Gittinger <cg@exept.de>
parents: 1745
diff changeset
   116
    inStream position1Based:512+1.
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
    1 to:tableLen do:[:i |
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
        startTable at:i put:(inStream nextLongMSB: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
    1 to:tableLen do:[:i |
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
        lengthTable at:i put:(inStream nextLongMSB:true).
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
    ].
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
2726
de3b045610a0 rgba files
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   124
    data := ByteArray uninitializedNew:(width*height*bytesPerPixel).
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
2726
de3b045610a0 rgba files
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   126
    dstIdx := width * (height-1) * bytesPerPixel + 1.
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
    0 to:(height-1) do:[:y |
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
        0 to:(bytesPerPixel-1) do:[:z |
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
            |start length|
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
            tblIdx := y + (z*height) + 1.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
            start := startTable at:tblIdx.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
            length := lengthTable at:tblIdx.
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
1753
aa246112438a avoid position
Claus Gittinger <cg@exept.de>
parents: 1745
diff changeset
   137
            inStream position1Based:(start + 1).
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
            (inStream nextBytes:length into:rleData startingAt:1) ~~ length ifTrue:[
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
                self halt:'short read'
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
            ].
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
            (rleData at:length) ~~ 0 ifTrue:[
3097
b067905c1c89 halts changed to breakpoint
Claus Gittinger <cg@exept.de>
parents: 2726
diff changeset
   142
                self halt:'lengthTable not 0 terminated'.
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
            ].
559
06bcbb6e3f32 use common RLE helper
Claus Gittinger <cg@exept.de>
parents: 527
diff changeset
   144
06bcbb6e3f32 use common RLE helper
Claus Gittinger <cg@exept.de>
parents: 527
diff changeset
   145
            self class
06bcbb6e3f32 use common RLE helper
Claus Gittinger <cg@exept.de>
parents: 527
diff changeset
   146
                decompressRLEFrom:rleData at:1 
2726
de3b045610a0 rgba files
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   147
                into:data at:dstIdx+z increment:bytesPerPixel.
559
06bcbb6e3f32 use common RLE helper
Claus Gittinger <cg@exept.de>
parents: 527
diff changeset
   148
06bcbb6e3f32 use common RLE helper
Claus Gittinger <cg@exept.de>
parents: 527
diff changeset
   149
"/            self expandRow:rleData to:dstIdx+z. "/ (3-z).
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
        ].
2726
de3b045610a0 rgba files
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   151
        dstIdx := dstIdx - (width * bytesPerPixel).
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
    ].
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
    "
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
     IrisRGBReader fromFile:'/home2/cg/capture.rgb'
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
    "
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
559
06bcbb6e3f32 use common RLE helper
Claus Gittinger <cg@exept.de>
parents: 527
diff changeset
   158
    "Modified: 23.4.1997 / 18:59:11 / cg"
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
! !
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   161
!IrisRGBReader methodsFor:'reading'!
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   162
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   163
fromStream:aStream
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   164
    | magic type dim isRLE bpp|
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   165
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   166
    inStream := aStream.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   167
    inStream binary.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   168
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   169
    magic := inStream nextShortMSB:true.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   170
    magic ~~ 8r0732 ifTrue:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   171
        ^ self fileFormatError:'bad magic number'.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   172
    ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   173
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   174
    type := inStream nextShortMSB:true.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   175
    dim := inStream nextShortMSB:true.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   176
    width := inStream nextShortMSB:true.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   177
    height := inStream nextShortMSB:true.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   178
    bytesPerPixel := inStream nextShortMSB:true.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   179
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   180
    isRLE := (type bitAnd:16rFF00) == 16r0100.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   181
    bpp := type bitAnd:16r00FF.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   182
    bpp ~~ 1 ifTrue:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   183
        ^ self fileFormatError:'only 1byte/pixel channel supported'.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   184
    ].
2726
de3b045610a0 rgba files
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   185
    (bytesPerPixel ~~ 3 and:[ bytesPerPixel ~~ 4 ]) ifTrue:[
de3b045610a0 rgba files
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   186
        ^ self fileFormatError:'can only read 3- and 4-channel images'.
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   187
    ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   188
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   189
    self reportDimension.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   190
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   191
    isRLE ifTrue:[
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   192
        self readRLEData
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   193
    ] ifFalse:[
2726
de3b045610a0 rgba files
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   194
        "/ self readVerbatimData
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   195
        ^ self fileFormatError:'currently, only RLE encoding supported'.
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   196
    ].
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   197
2726
de3b045610a0 rgba files
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   198
    photometric := #rgba.
de3b045610a0 rgba files
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   199
    samplesPerPixel := 4.
de3b045610a0 rgba files
Claus Gittinger <cg@exept.de>
parents: 1848
diff changeset
   200
    bitsPerSample := #(8 8 8 8).
1848
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   201
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   202
    "
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   203
     IrisRGBReader fromFile:'/home2/cg/capture.rgb'
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   204
    "
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   205
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   206
    "Created: / 14.4.1997 / 15:38:51 / cg"
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   207
    "Modified: / 1.4.1998 / 14:28:51 / cg"
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   208
! !
864ca2cd4e71 category
Claus Gittinger <cg@exept.de>
parents: 1846
diff changeset
   209
527
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
3097
b067905c1c89 halts changed to breakpoint
Claus Gittinger <cg@exept.de>
parents: 2726
diff changeset
   232
    ^ '$Header: /cvs/stx/stx/libview2/IrisRGBReader.st,v 1.14 2013-03-06 09:01:16 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
3097
b067905c1c89 halts changed to breakpoint
Claus Gittinger <cg@exept.de>
parents: 2726
diff changeset
   235
527
8c9d7178db4b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
IrisRGBReader initialize!