TIFFReader.st
author Claus Gittinger <cg@exept.de>
Fri, 28 Feb 1997 22:51:30 +0100
changeset 465 5df2fbe7275a
parent 461 bacef118f54a
child 516 76ffe180cff8
permissions -rw-r--r--
comments
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
3f9277473954 Initial revision
claus
parents:
diff changeset
     1
"
6
4ac87e6bf82f *** empty log message ***
claus
parents: 5
diff changeset
     2
 COPYRIGHT (c) 1991 by Claus Gittinger
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
     3
	      All Rights Reserved
0
3f9277473954 Initial revision
claus
parents:
diff changeset
     4
3f9277473954 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
3f9277473954 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
3f9277473954 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
3f9277473954 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
3f9277473954 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
3f9277473954 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
3f9277473954 Initial revision
claus
parents:
diff changeset
    11
"
3f9277473954 Initial revision
claus
parents:
diff changeset
    12
3f9277473954 Initial revision
claus
parents:
diff changeset
    13
ImageReader subclass:#TIFFReader
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
    14
	instanceVariableNames:'planarConfiguration subFileType stripOffsets rowsPerStrip
159
327da5085900 fixed saving of 24bit RGB images (forgot samplesPerPixel-TAG)
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    15
		fillOrder compression group3options predictor stripByteCounts
327da5085900 fixed saving of 24bit RGB images (forgot samplesPerPixel-TAG)
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    16
		currentOffset stripOffsetsPos stripByteCountsPos bitsPerSamplePos
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
    17
		colorMapPos orientation'
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
    18
	classVariableNames:''
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
    19
	poolDictionaries:''
259
62b1bbafd9ba category change
Claus Gittinger <cg@exept.de>
parents: 234
diff changeset
    20
	category:'Graphics-Images-Support'
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    21
!
3f9277473954 Initial revision
claus
parents:
diff changeset
    22
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
    23
!TIFFReader class methodsFor:'documentation'!
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    24
21
66b31c91177f *** empty log message ***
claus
parents: 19
diff changeset
    25
copyright
66b31c91177f *** empty log message ***
claus
parents: 19
diff changeset
    26
"
66b31c91177f *** empty log message ***
claus
parents: 19
diff changeset
    27
 COPYRIGHT (c) 1991 by Claus Gittinger
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
    28
	      All Rights Reserved
21
66b31c91177f *** empty log message ***
claus
parents: 19
diff changeset
    29
66b31c91177f *** empty log message ***
claus
parents: 19
diff changeset
    30
 This software is furnished under a license and may be used
66b31c91177f *** empty log message ***
claus
parents: 19
diff changeset
    31
 only in accordance with the terms of that license and with the
66b31c91177f *** empty log message ***
claus
parents: 19
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
66b31c91177f *** empty log message ***
claus
parents: 19
diff changeset
    33
 be provided or otherwise made available to, or used by, any
66b31c91177f *** empty log message ***
claus
parents: 19
diff changeset
    34
 other person.  No title to or ownership of the software is
66b31c91177f *** empty log message ***
claus
parents: 19
diff changeset
    35
 hereby transferred.
66b31c91177f *** empty log message ***
claus
parents: 19
diff changeset
    36
"
66b31c91177f *** empty log message ***
claus
parents: 19
diff changeset
    37
!
66b31c91177f *** empty log message ***
claus
parents: 19
diff changeset
    38
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    39
documentation
3f9277473954 Initial revision
claus
parents:
diff changeset
    40
"
21
66b31c91177f *** empty log message ***
claus
parents: 19
diff changeset
    41
    This class knows how to read TIFF files and how to
66b31c91177f *** empty log message ***
claus
parents: 19
diff changeset
    42
    write uncompressed TIFF files.
14
20638e830834 *** empty log message ***
claus
parents: 11
diff changeset
    43
21
66b31c91177f *** empty log message ***
claus
parents: 19
diff changeset
    44
    Only single image files are supported.
38
201df32d2377 *** empty log message ***
claus
parents: 35
diff changeset
    45
    Not all formats are implemented, and of those that are, not all are tested.
159
327da5085900 fixed saving of 24bit RGB images (forgot samplesPerPixel-TAG)
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    46
    It should read with most rgb, mono and 2-plane greyscale
38
201df32d2377 *** empty log message ***
claus
parents: 35
diff changeset
    47
    images, since this is what I have as test material on the NeXT.
21
66b31c91177f *** empty log message ***
claus
parents: 19
diff changeset
    48
    It supports reading of uncompressed, LZW and G3 compressed 
66b31c91177f *** empty log message ***
claus
parents: 19
diff changeset
    49
    images; JPEG and packbits are currently not implemented.
14
20638e830834 *** empty log message ***
claus
parents: 11
diff changeset
    50
21
66b31c91177f *** empty log message ***
claus
parents: 19
diff changeset
    51
    Only writing of uncompressed images is currently implemented.
159
327da5085900 fixed saving of 24bit RGB images (forgot samplesPerPixel-TAG)
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    52
    It should write (at least) mono, 8-bit palette and 24 bit rgb formats.
21
66b31c91177f *** empty log message ***
claus
parents: 19
diff changeset
    53
    More formats will come ...
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
    54
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
    55
    TODO: since I dont want to spend all of my life adding more formats here and
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
    56
    reinventing the wheel, this code should be changed to use the tiff library.
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
    57
    That would give us most formats and also writing capabilities for free.
195
7975a2c4a890 commentary
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
    58
220
4106d9ce7e02 documentation
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    59
    [author:]
4106d9ce7e02 documentation
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    60
        Claus Gittinger
4106d9ce7e02 documentation
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    61
195
7975a2c4a890 commentary
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
    62
    [See also:]
234
b6352d13e792 xrefs in documentation
Claus Gittinger <cg@exept.de>
parents: 220
diff changeset
    63
        Image Form Icon
197
50812e81d86f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 195
diff changeset
    64
        BlitImageReader FaceReader GIFReader JPEGReader PBMReader PCXReader 
210
5405de794686 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
    65
        ST80FormReader SunRasterReader TargaReader WindowsIconReader 
209
840ddcf12904 commentary
Claus Gittinger <cg@exept.de>
parents: 198
diff changeset
    66
        XBMReader XPMReader XWDReader 
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    67
"
3f9277473954 Initial revision
claus
parents:
diff changeset
    68
! !
3f9277473954 Initial revision
claus
parents:
diff changeset
    69
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
    70
!TIFFReader class methodsFor:'initialization'!
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
    71
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
    72
initialize
198
6d76856aaa80 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
    73
    "install myself in the Image classes fileFormat table
398
aef700d15416 new suffix-table
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
    74
     for the `.tiff' and `.tif' extensions."
198
6d76856aaa80 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
    75
398
aef700d15416 new suffix-table
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
    76
    Image addReader:self suffix:'tiff'.
aef700d15416 new suffix-table
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
    77
    Image addReader:self suffix:'tif'.
198
6d76856aaa80 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
    78
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
    79
    "
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
    80
     self initialize
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
    81
    "
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
    82
398
aef700d15416 new suffix-table
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
    83
    "Modified: 1.2.1997 / 15:00:01 / cg"
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
    84
! !
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
    85
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
    86
!TIFFReader class methodsFor:'testing'!
3
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
    87
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
    88
canRepresent:anImage
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
    89
    "return true, if anImage can be represented in my file format.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
    90
     Any image is supported."
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
    91
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
    92
    ^ true
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
    93
!
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
    94
3
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
    95
isValidImageFile:aFileName
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
    96
    "return true, if aFileName contains a GIF image"
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
    97
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
    98
    |inStream char1 char2 version|
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
    99
11
1d0df18a7049 *** empty log message ***
claus
parents: 6
diff changeset
   100
    inStream := self streamReadingFile:aFileName.
3
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
   101
    inStream isNil ifTrue:[^ false].
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
   102
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
   103
    char1 := inStream next.
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
   104
    char2 := inStream next.
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
   105
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
   106
    ((char1 ~~ char2) or:[(char1 ~~ $I) and:[char1 ~~ $M]]) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
   107
	inStream close.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
   108
	^ false
3
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
   109
    ].
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
   110
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
   111
    inStream binary.
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
   112
    version := inStream nextShortMSB:(char1 == $M).
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
   113
    inStream close.
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
   114
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
   115
    (version ~~ 42) ifTrue:[^ false].
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
   116
    ^ true
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   117
! !
3f9277473954 Initial revision
claus
parents:
diff changeset
   118
3f9277473954 Initial revision
claus
parents:
diff changeset
   119
!TIFFReader methodsFor:'private'!
3f9277473954 Initial revision
claus
parents:
diff changeset
   120
3f9277473954 Initial revision
claus
parents:
diff changeset
   121
decodeTiffTag:tagType numberType:numberType length:length
3f9277473954 Initial revision
claus
parents:
diff changeset
   122
    |offset value valueArray 
40
c2e206361c7b *** empty log message ***
claus
parents: 38
diff changeset
   123
     val scaleFactor rV gV bV
c2e206361c7b *** empty log message ***
claus
parents: 38
diff changeset
   124
     n  "{ Class: SmallInteger }"
35
f13cdd0b44c7 *** empty log message ***
claus
parents: 32
diff changeset
   125
     i2 "{ Class: SmallInteger }"
f13cdd0b44c7 *** empty log message ***
claus
parents: 32
diff changeset
   126
     i3 "{ Class: SmallInteger }" |
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   127
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   128
"/ 'tiffTag: ' print. tagType printCR.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   129
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   130
    (numberType == 3) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   131
        "short"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   132
        valueArray := self readShorts:length.
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   133
        value := valueArray at:1
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   134
    ] ifFalse:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   135
        (numberType == 4) ifTrue:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   136
            "integer"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   137
            valueArray := self readLongs:length.
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   138
            value := valueArray at:1
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   139
        ] ifFalse:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   140
            (numberType == 2) ifTrue:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   141
                "character"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   142
                value := self readChars:length
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   143
            ] ifFalse:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   144
                (numberType == 5) ifTrue:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   145
                    "fraction"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   146
                    valueArray := self readFracts:length.
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   147
                    value := valueArray at:1
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   148
                ] ifFalse:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   149
                    offset := (inStream nextLongMSB:(byteOrder ~~ #lsb))
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   150
                ]
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   151
            ]
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   152
        ]
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   153
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   154
3f9277473954 Initial revision
claus
parents:
diff changeset
   155
    (tagType == 254) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   156
        "NewSubfileType"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   157
        "newSubFileType := value."
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   158
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   159
"/        'newSubfiletype ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   160
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   161
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   162
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   163
    (tagType == 255) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   164
        "SubfileType"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   165
        subFileType := value.
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   166
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   167
"/        'subfiletype ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   168
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   169
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   170
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   171
    (tagType == 256) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   172
        "ImageWidth"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   173
        width := value.
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   174
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   175
"/        'width ' print. width printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   176
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   177
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   178
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   179
    (tagType == 257) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   180
        "ImageHeight"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   181
        height := value.
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   182
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   183
"/        'height ' print. height  printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   184
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   185
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   186
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   187
    (tagType == 258) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   188
        "bitspersample"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   189
         bitsPerSample := valueArray.
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   190
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   191
"/        'bitspersample ' print. bitsPerSample printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   192
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   193
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   194
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   195
    (tagType == 259) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   196
        "compression"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   197
        compression := value.
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   198
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   199
"/        'compression ' print. compression printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   200
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   201
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   202
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   203
    (tagType == 262) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   204
        "photometric"
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   205
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   206
        (value == 0) ifTrue:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   207
          photometric := #whiteIs0
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   208
        ] ifFalse:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   209
          (value == 1) ifTrue:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   210
            photometric := #blackIs0
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   211
          ] ifFalse:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   212
            (value == 2) ifTrue:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   213
              photometric := #rgb
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   214
            ] ifFalse:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   215
              (value == 3) ifTrue:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   216
                photometric := #palette
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   217
              ] ifFalse:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   218
                (value == 4) ifTrue:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   219
                  photometric := #transparency
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   220
                ] ifFalse:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   221
                  (value == 5) ifTrue:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   222
                    photometric := #separated  "/ color separations
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   223
                  ] ifFalse:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   224
                    (value == 6) ifTrue:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   225
                      photometric := #ycbr    "/ CCIR 601
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   226
                    ] ifFalse:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   227
                      (value == 8) ifTrue:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   228
                        photometric := #cielab  "/ 1976 CIE L*a*b*
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   229
                      ] ifFalse:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   230
                        photometric := nil
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   231
                      ]
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   232
                    ]
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   233
                  ]
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   234
                ]
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   235
              ]
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   236
            ]
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   237
          ]
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   238
        ].
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   239
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   240
"/        'photometric ' print. photometric printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   241
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   242
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   243
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   244
    (tagType == 263) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   245
        "Treshholding"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   246
        "threshholding := value."
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   247
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   248
"/        'treshholding ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   249
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   250
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   251
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   252
    (tagType == 264) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   253
        "CellWidth"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   254
        "cellWidth:= value."
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   255
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   256
"/        'cellWidth ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   257
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   258
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   259
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   260
    (tagType == 265) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   261
        "CellLength"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   262
        "cellLength:= value."
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   263
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   264
"/        'cellLength ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   265
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   266
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   267
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   268
    (tagType == 266) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   269
        "fillOrder"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   270
        (value == 1) ifTrue:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   271
          fillOrder := #msb
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   272
        ] ifFalse:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   273
          (value == 2) ifTrue:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   274
            fillOrder := #lsb
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   275
          ] ifFalse:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   276
            fillOrder := nil
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   277
          ]
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   278
        ].
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   279
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   280
"/        'fillorder ' print. fillOrder printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   281
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   282
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   283
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   284
    (tagType == 269) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   285
        "documentName - info only"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   286
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   287
"/        'documentName ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   288
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   289
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   290
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   291
    (tagType == 270) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   292
        "imageDescription - info only"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   293
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   294
"/        'imageDescription ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   295
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   296
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   297
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   298
    (tagType == 271) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   299
        "make - info only"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   300
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   301
"/        'make ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   302
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   303
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   304
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   305
    (tagType == 272) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   306
        "model - info only"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   307
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   308
"/        'model ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   309
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   310
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   311
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   312
    (tagType == 273) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   313
        "stripoffsets"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   314
        stripOffsets := valueArray.
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   315
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   316
"/        'stripOffsets Array(' print. stripOffsets size print. ')' printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   317
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   318
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   319
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   320
    (tagType == 274) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   321
        "Orientation"
393
9e9f2272b524 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
   322
9e9f2272b524 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
   323
        orientation :=
9e9f2272b524 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
   324
                        #( nil          "/ 1 normal
9e9f2272b524 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
   325
                           unsupported  "/ 2 horizontal flip
9e9f2272b524 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
   326
                           unsupported  "/ 3 horizontal & vertical flip
9e9f2272b524 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
   327
                           vFlip        "/ 4 vertical flip
9e9f2272b524 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
   328
                           unsupported  "/ 5 rot 90' counter clock-wise
9e9f2272b524 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
   329
                           unsupported  "/ 6 rot 90' clock-wise
9e9f2272b524 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
   330
                           unsupported  "/ 7 rot 90' & flip
9e9f2272b524 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
   331
                           unsupported  "/ 8 rot 90' ccw & flip
9e9f2272b524 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
   332
                         ) at:value ifAbsent:#unsupported.
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   333
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   334
"/        'orientation ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   335
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   336
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   337
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   338
    (tagType == 277) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   339
        "samplesPerPixel"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   340
        samplesPerPixel := value.
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   341
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   342
"/        'samplesperpixel ' print. samplesPerPixel printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   343
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   344
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   345
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   346
    (tagType == 278) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   347
        "rowsperstrip"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   348
        rowsPerStrip := value.
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   349
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   350
"/        'rowsperstrip ' print. rowsPerStrip printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   351
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   352
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   353
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   354
    (tagType == 279) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   355
        "stripbytecount"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   356
        stripByteCounts := valueArray.
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   357
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   358
"/        'stripByteCounts Array(' print. 
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   359
"/        stripByteCounts size print.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   360
"/        ')' printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   361
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   362
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   363
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   364
    (tagType == 280) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   365
        "MinSampleValue"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   366
        "minSampleValue:= value."
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   367
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   368
"/        'minSampleValue ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   369
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   370
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   371
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   372
    (tagType == 281) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   373
        "MaxSampleValue"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   374
        "maxSampleValue:= value."
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   375
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   376
"/        'maxSampleValue ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   377
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   378
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   379
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   380
    (tagType == 282) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   381
        "xResolution"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   382
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   383
"/        'xres ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   384
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   385
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   386
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   387
    (tagType == 283) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   388
        "yResolution"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   389
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   390
"/        'yres ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   391
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   392
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   393
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   394
    (tagType == 284) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   395
        "planarconfig"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   396
        (value == 1) ifTrue:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   397
          planarConfiguration := 1
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   398
        ] ifFalse:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   399
          (value == 2) ifTrue:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   400
            planarConfiguration := 2
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   401
          ] ifFalse:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   402
            planarConfiguration := nil
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   403
          ]
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   404
        ].
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   405
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   406
"/        'planarconfig ' print. planarConfiguration printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   407
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   408
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   409
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   410
    (tagType == 285) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   411
        "pageName"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   412
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   413
"/        'pageName ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   414
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   415
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   416
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   417
    (tagType == 286) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   418
        "xPosition"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   419
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   420
"/        'xPos ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   421
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   422
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   423
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   424
    (tagType == 287) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   425
        "yPosition"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   426
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   427
"/        'yPos ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   428
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   429
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   430
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   431
    (tagType == 288) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   432
        "freeOffsets"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   433
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   434
"/        'freeOffsets ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   435
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   436
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   437
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   438
    (tagType == 289) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   439
        "freeByteCounts"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   440
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   441
"/        'freeByteCounts ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   442
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   443
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   444
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   445
    (tagType == 290) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   446
        "grayResponceUnit"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   447
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   448
"/        'grayResponceUnit' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   449
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   450
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   451
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   452
    (tagType == 291) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   453
        "grayResponceCurve"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   454
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   455
"/        'grayResponceCurve' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   456
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   457
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   458
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   459
    (tagType == 292) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   460
        "group3options"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   461
        group3options := value.
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   462
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   463
"/        'group3options ' print. group3options printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   464
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   465
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   466
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   467
    (tagType == 293) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   468
        "group4options"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   469
        "group4options := value."
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   470
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   471
"/        'group4options ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   472
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   473
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   474
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   475
    (tagType == 296) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   476
        "resolutionunit"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   477
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   478
"/        (value == 1) ifTrue:[
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   479
"/            'res-unit pixel' printNewline
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   480
"/        ] ifFalse:[
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   481
"/            (value == 2) ifTrue:[
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   482
"/                'res-unit inch' printNewline
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   483
"/            ] ifFalse:[
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   484
"/                (value == 3) ifTrue:[
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   485
"/                    'res-unit mm' printNewline
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   486
"/                ] ifFalse:[
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   487
"/                    'res-unit invalid' printNewline
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   488
"/                ]
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   489
"/            ]
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   490
"/        ].
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   491
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   492
        "resolutionUnit := value."
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   493
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   494
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   495
    (tagType == 297) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   496
        "pageNumber"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   497
        "pageNumber := value."
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   498
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   499
"/        'pageNumber ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   500
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   501
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   502
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   503
    (tagType == 300) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   504
        "colorResponceUnit"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   505
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   506
"/        'colorResponceUnit' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   507
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   508
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   509
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   510
    (tagType == 301) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   511
        "colorResponceCurve"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   512
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   513
"/        'colorResponceCurve' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   514
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   515
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   516
    ].
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   517
    (tagType == 305) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   518
        "software - info only"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   519
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   520
"/        'software' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   521
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   522
        ^ self
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   523
    ].
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   524
    (tagType == 306) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   525
        "dateTime - info only"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   526
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   527
"/        'dateTime ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   528
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   529
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   530
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
   531
    (tagType == 315) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   532
        "artist - info only"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   533
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   534
"/        'artist ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   535
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   536
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   537
    ].
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   538
    (tagType == 316) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   539
        "host computer - info only"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   540
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   541
"/        'host ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   542
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   543
        ^ self
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   544
    ].
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   545
    (tagType == 317) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   546
        "predictor"
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   547
        predictor := value.
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   548
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   549
"/        'predictor ' print. predictor printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   550
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   551
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   552
    ].
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   553
    (tagType == 318) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   554
        "whitePoint"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   555
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   556
"/        'whitePoint ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   557
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   558
        ^ self
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   559
    ].
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   560
    (tagType == 319) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   561
        "primaryChromatics"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   562
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   563
"/        'primaryChromatics ' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   564
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   565
        ^ self
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   566
    ].
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   567
    (tagType == 320) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   568
        "colorMap"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   569
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   570
"/        'colorMap (size=' print. valueArray size print. ')' printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   571
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   572
        "
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   573
         the tiff colormap contains 16bit values;
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   574
         our colormap expects 8bit values
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   575
        "
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   576
        n := valueArray size // 3.
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
   577
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   578
        rV := ByteArray uninitializedNew:n.
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   579
        gV := ByteArray uninitializedNew:n.
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   580
        bV := ByteArray uninitializedNew:n.
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   581
        scaleFactor := 255.0 / 16rFFFF.
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   582
        i2 := n+1.
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   583
        i3 := 2*n+1.
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   584
        1 to:n do:[:vi |
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   585
            val := ((valueArray at:vi) * scaleFactor) rounded.
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   586
            rV at:vi put:val.
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   587
            val := ((valueArray at:i2) * scaleFactor) rounded.
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   588
            gV at:vi put:val.
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   589
            val := ((valueArray at:i3) * scaleFactor) rounded.
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   590
            bV at:vi put:val.
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   591
            i2 := i2 + 1.
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   592
            i3 := i3 + 1.
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   593
        ].
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   594
        colorMap := Colormap redVector:rV greenVector:gV blueVector:bV.
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   595
        ^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   596
    ].
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   597
    (tagType == 332) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   598
        "ink set"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   599
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   600
"/        'ink set' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   601
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   602
        ^ self
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   603
    ].
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   604
    (tagType == 333) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   605
        "ink names"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   606
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   607
"/        'ink names' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   608
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   609
        ^ self
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   610
    ].
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   611
    (tagType == 336) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   612
        "dot range"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   613
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   614
"/        'dot range' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   615
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   616
        ^ self
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   617
    ].
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   618
    (tagType == 337) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   619
        "target printer"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   620
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   621
"/        'target printer' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   622
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   623
        ^ self
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   624
    ].
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   625
    (tagType == 339) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   626
        "sample format"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   627
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   628
"/        'sample format' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   629
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   630
        ^ self
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   631
    ].
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   632
    (tagType == 340) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   633
        "min sample value"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   634
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   635
"/        'min sample value' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   636
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   637
        ^ self
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   638
    ].
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   639
    (tagType == 341) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   640
        "max sample value"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   641
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   642
"/        'max sample value' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   643
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   644
        ^ self
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   645
    ].
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   646
    (tagType == 512) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   647
        "jpeg proc"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   648
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   649
"/        'jpeg proc' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   650
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   651
        ^ self
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   652
    ].
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   653
    (tagType == 513) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   654
        "jpeg proc"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   655
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   656
"/        'jpeg proc' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   657
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   658
        ^ self
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   659
    ].
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   660
    (tagType == 32995) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   661
        "matteing"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   662
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   663
"/        'matteing' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   664
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   665
        ^ self
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   666
    ].
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   667
    (tagType == 32996) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   668
        "datatype"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   669
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   670
"/        'datatype' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   671
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   672
        ^ self
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   673
    ].
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   674
    (tagType == 32997) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   675
        "imagedepth"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   676
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   677
"/        'imagedepth' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   678
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   679
        ^ self
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   680
    ].
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   681
    (tagType == 32998) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   682
        "tiledepth"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   683
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   684
"/        'tiledepth' print. value printNewline.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   685
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   686
        ^ self
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
   687
    ].
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   688
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   689
"/
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   690
"/ 'TIFFReader: tag:' print. tagType print. ' typ:' print. numberType print.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   691
"/ ' len:' print. length print. ' offs:' print. offset print. 
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   692
"/ ' val:' print. value print. ' valArr:' print. valueArray printNewline.  
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
   693
"/
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   694
    'TIFFReader [warning]: unknown tag type ' errorPrint. tagType errorPrintCR
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   695
393
9e9f2272b524 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
   696
    "Modified: 31.1.1997 / 10:50:38 / cg"
440
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   697
! !
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   698
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
   699
!TIFFReader methodsFor:'private - reading'!
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   700
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   701
readCCITT3RLETiffImageData
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   702
     'TIFFReader [warning]: ccitt mod Huffman (rle) compression not implemented' errorPrintCR.
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   703
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   704
    "Modified: 10.1.1997 / 18:09:02 / cg"
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   705
!
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   706
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   707
readCCITT3RLEWTiffImageData
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   708
     'TIFFReader [warning]: ccitt mod Huffman (rlew) compression not implemented' errorPrintCR.
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   709
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   710
    "Modified: 10.1.1997 / 18:09:11 / cg"
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   711
!
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   712
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   713
readCCITTGroup3TiffImageData
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   714
    "not really tested - all I got is a single
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   715
     fax from NeXT step"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   716
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   717
    |bytesPerRow bitsPerRow compressedStrip nPlanes 
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   718
     stripNr       "{ Class: SmallInteger }"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   719
     offset        "{ Class: SmallInteger }"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   720
     row           "{ Class: SmallInteger }"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   721
     bytesPerStrip "{ Class: SmallInteger }" |
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   722
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   723
    nPlanes := samplesPerPixel.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   724
    (nPlanes == 2) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   725
        'TIFFReader [info]: ignoring alpha plane' infoPrintCR.
335
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   726
        nPlanes := 1
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   727
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   728
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   729
    (nPlanes ~~ 1) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   730
        'TIFFReader [warning]: only monochrome/greyscale supported' errorPrintCR.
335
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   731
        ^ nil
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   732
    ].
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   733
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   734
    stripByteCounts isNil ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   735
        'TIFFReader [warning]: currently require stripByteCounts' errorPrintCR.
335
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   736
        ^ nil
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   737
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   738
    (rowsPerStrip ~~ 1) isNil ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   739
        'TIFFReader [warning]: currently require rowsPerStrip to be 1' errorPrintCR.
335
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   740
        ^ nil
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   741
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   742
335
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   743
"/    'TIFFReader: decompressing CCITT-3 ...' infoPrintNL.
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   744
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   745
    bitsPerRow := width * (bitsPerSample at:1).
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   746
    bytesPerRow := bitsPerRow // 8.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   747
    ((bitsPerRow \\ 8) ~~ 0) ifTrue:[
335
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   748
        bytesPerRow := bytesPerRow + 1
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   749
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   750
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   751
    data := ByteArray new:(bytesPerRow * height).
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   752
    compressedStrip := ByteArray uninitializedNew:bytesPerRow.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   753
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   754
    offset := 1.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   755
    stripNr := 0.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   756
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   757
    row := 1.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   758
    bytesPerStrip := bytesPerRow * rowsPerStrip.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   759
    [row <= height] whileTrue:[
335
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   760
        stripNr := stripNr + 1.
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   761
        inStream position:((stripOffsets at:stripNr) + 1).
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   762
        inStream nextBytes:(stripByteCounts at:stripNr) into:compressedStrip.
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   763
        self class decompressCCITT3From:compressedStrip
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   764
                                   into:data
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   765
                             startingAt:offset
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   766
                                  count:width.
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   767
        offset := offset + bytesPerStrip.
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   768
        row := row + rowsPerStrip
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   769
    ]
335
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   770
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   771
    "Modified: 10.1.1997 / 18:14:56 / cg"
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   772
!
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   773
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   774
readCCITTGroup4TiffImageData
359
6fdd7d3119a8 *PrintNL eliminated
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   775
    'TIFFReader [warning]: ccitt group4 fax compression not implemented' errorPrintCR.
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   776
359
6fdd7d3119a8 *PrintNL eliminated
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   777
    "Modified: 10.1.1997 / 19:10:59 / cg"
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   778
!
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   779
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   780
readChars:n
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   781
    "read n characters and return them in a string"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   782
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   783
    |oldPos offset string|
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   784
329
5fb99e0734e4 handle empty character-strings
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
   785
    n == 0 ifTrue:[^ ''].
5fb99e0734e4 handle empty character-strings
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
   786
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   787
    string := String new:(n - 1).
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   788
    (n <= 4) ifTrue:[
329
5fb99e0734e4 handle empty character-strings
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
   789
        inStream nextBytes:(n - 1) into:string
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   790
    ] ifFalse:[
329
5fb99e0734e4 handle empty character-strings
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
   791
        offset := inStream nextLongMSB:(byteOrder ~~ #lsb).
5fb99e0734e4 handle empty character-strings
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
   792
        oldPos := inStream position.
5fb99e0734e4 handle empty character-strings
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
   793
        inStream position:(offset + 1).
5fb99e0734e4 handle empty character-strings
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
   794
        inStream nextBytes:(n - 1) into:string.
5fb99e0734e4 handle empty character-strings
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
   795
        inStream position:oldPos
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   796
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   797
    ^ string
329
5fb99e0734e4 handle empty character-strings
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
   798
5fb99e0734e4 handle empty character-strings
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
   799
    "Modified: 5.9.1996 / 12:21:08 / cg"
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   800
!
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   801
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   802
readFracts:nFracts
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   803
    "read nFracts fractions (2 32bit words) and return them in an array"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   804
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   805
    |oldPos offset values numerator denominator msb
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   806
     n "{ Class: SmallInteger }" |
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   807
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   808
    n := nFracts.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   809
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   810
    msb := byteOrder ~~ #lsb.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   811
    values := Array basicNew:n.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   812
    offset := inStream nextLongMSB:msb.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   813
    oldPos := inStream position.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   814
    inStream position:(offset + 1).
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   815
    1 to:n do:[:index |
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   816
	numerator := inStream nextLongMSB:msb.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   817
	denominator := inStream nextLongMSB:msb.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   818
	values at:index put:(Fraction numerator:numerator denominator:denominator)
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   819
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   820
    inStream position:oldPos.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   821
    ^ values
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   822
!
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   823
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   824
readJPEGTiffImageData
359
6fdd7d3119a8 *PrintNL eliminated
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   825
    'TIFFReader [warning]: jpeg compression not implemented' errorPrintCR
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   826
359
6fdd7d3119a8 *PrintNL eliminated
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   827
    "Modified: 10.1.1997 / 19:11:02 / cg"
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   828
!
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   829
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   830
readLZWTiffImageData
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   831
    "read LZW compressed tiff data; this method only
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   832
     handles 3x8 rgb and 1x2 or 2x2 greyscale images.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   833
     For 2x2 greyscale images, the alpha plane is ignored.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   834
     (maybe other formats work also - its simply not
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   835
      tested)"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   836
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   837
    |bytesPerRow compressedStrip nPlanes 
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   838
     bytesPerStrip "{ Class: SmallInteger }"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   839
     nBytes        "{ Class: SmallInteger }"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   840
     prevSize      "{ Class: SmallInteger }"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   841
     stripNr       "{ Class: SmallInteger }"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   842
     offset        "{ Class: SmallInteger }"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   843
     row           "{ Class: SmallInteger }" |
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   844
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   845
    nPlanes := samplesPerPixel.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   846
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   847
    (nPlanes == 3) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   848
        (((bitsPerSample at:1) ~~ 8) 
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   849
        or:[((bitsPerSample at:2) ~~ 8) 
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   850
        or:[((bitsPerSample at:3) ~~ 8)]]) ifTrue:[
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   851
            'TIFFReader [warning]: only 8/8/8 bit/sample are supported' errorPrintCR.
335
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   852
            ^ nil
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   853
        ].
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   854
        bytesPerRow := width * samplesPerPixel.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   855
    ] ifFalse:[
335
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   856
        (nPlanes == 2) ifTrue:[
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   857
            (planarConfiguration ~~ 2) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   858
                'TIFFReader [warning]: only separate planes are supported' errorPrintCR.
335
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   859
                ^ nil
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   860
            ].
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   861
            'TIFFReader [info]: ignoring alpha plane' infoPrintCR.
335
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   862
            nPlanes := 1
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   863
        ].
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   864
        (nPlanes == 1) ifFalse:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   865
            'TIFFReader [warning]: only 3-sample rgb / monochrome supported' errorPrintCR.
335
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   866
            ^ nil
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   867
        ].
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   868
        bytesPerRow := (width * (bitsPerSample at:1) + 7) // 8.
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   869
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   870
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   871
    stripByteCounts isNil ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   872
        'TIFFReader [warning]: currently require stripByteCounts' errorPrintCR.
335
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   873
        ^ nil
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   874
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   875
335
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   876
"/    'TIFFReader: decompressing LZW ...' infoPrintNL.
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   877
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   878
    data := ByteArray uninitializedNew:(bytesPerRow * height).
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   879
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   880
    offset := 1.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   881
    stripNr := 0.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   882
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   883
    row := 1.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   884
    bytesPerStrip := bytesPerRow * rowsPerStrip.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   885
    prevSize := 0.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   886
    [row <= height] whileTrue:[
335
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   887
        stripNr := stripNr + 1.
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   888
        inStream position:((stripOffsets at:stripNr) + 1).
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   889
        nBytes := stripByteCounts at:stripNr.
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   890
        (nBytes > prevSize) ifTrue:[
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   891
            compressedStrip := ByteArray uninitializedNew:nBytes.
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   892
            prevSize := nBytes
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   893
        ].
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   894
        inStream nextBytes:nBytes
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   895
                      into:compressedStrip.
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   896
        self class decompressLZWFrom:compressedStrip
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   897
                               count:nBytes
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   898
                                into:data
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   899
                          startingAt:offset.
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   900
        offset := offset + bytesPerStrip.
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   901
        row := row + rowsPerStrip
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   902
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   903
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   904
    (predictor == 2) ifTrue:[
335
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   905
        self class decodeDelta:3 in:data width:width height:height
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   906
    ]
335
a32831edacc5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   907
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   908
    "Modified: 10.1.1997 / 18:13:21 / cg"
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   909
!
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   910
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   911
readLongs:nLongs
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   912
    "read nLongs long numbers (32bit) and return them in an array"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   913
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   914
    |oldPos offset values msb 
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   915
     n "{ Class: SmallInteger }" |
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   916
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   917
    n := nLongs.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   918
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   919
    msb := byteOrder ~~ #lsb.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   920
    values := Array basicNew:n.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   921
    (n == 1) ifTrue:[
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   922
	values at:1 put:(inStream nextLongMSB:msb).
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   923
    ] ifFalse:[
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   924
	offset := inStream nextLongMSB:msb.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   925
	oldPos := inStream position.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   926
	inStream position:(offset + 1).
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   927
	1 to:n do:[:index |
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   928
	    values at:index put:(inStream nextLongMSB:msb)
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   929
	].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   930
	inStream position:oldPos
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   931
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   932
    ^ values
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   933
!
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   934
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   935
readNeXTJPEGTiffImageData
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   936
    'TIFFReader [warning]: jpeg compression not implemented' errorPrintCR
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   937
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   938
    "Modified: 10.1.1997 / 18:11:04 / cg"
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   939
!
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   940
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   941
readNeXTRLE2TiffImageData
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   942
    'TIFFReader [warning]: next 2bit rle compression not implemented' errorPrintCR.
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   943
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   944
    "Modified: 10.1.1997 / 18:11:01 / cg"
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   945
!
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   946
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   947
readPackbitsTiffImageData
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   948
    "had no samples yet - however, packbits decompression
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   949
     is rather trivial to add ..."
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   950
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   951
    'TIFFReader [warning]: packbits compression not implemented' errorPrintCR
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   952
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   953
    "Modified: 10.1.1997 / 18:10:57 / cg"
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   954
!
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   955
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   956
readShorts:nShorts
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   957
    "read nShorts short numbers (16bit) and return them in an array"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   958
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   959
    |oldPos offset values msb val2
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   960
     n "{ Class: SmallInteger }" |
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   961
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   962
    n := nShorts.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   963
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   964
    msb := (byteOrder ~~ #lsb).
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   965
    values := Array basicNew:n.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   966
    (n <= 2) ifTrue:[
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   967
	values at:1 put:(inStream nextUnsignedShortMSB:msb).
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   968
	val2 := inStream nextUnsignedShortMSB:msb.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   969
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   970
	(n == 2) ifTrue:[
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   971
	    values at:2 put:val2
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   972
	]
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   973
    ] ifFalse:[
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   974
	offset := inStream nextLongMSB:msb.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   975
	oldPos := inStream position.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   976
	inStream position:(offset + 1).
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   977
	1 to:n do:[:index |
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   978
	    values at:index put:(inStream nextUnsignedShortMSB:msb)
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   979
	].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   980
	inStream position:oldPos
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   981
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   982
    ^ values
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   983
!
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   984
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   985
readUncompressedTiffImageData
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   986
    |bytesPerRow bitsPerRow nPlanes 
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   987
     stripNr       "{ Class: SmallInteger }"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   988
     offset        "{ Class: SmallInteger }"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   989
     row           "{ Class: SmallInteger }" 
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   990
     nBytes        "{ Class: SmallInteger }"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   991
     bitsPerPixel overAllBytes|
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   992
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   993
    nPlanes := samplesPerPixel.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   994
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   995
    "only support 1-sample/pixel,
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   996
     with alpha - if separate planes,
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   997
     or rgb - if non separate planes and no alpha"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   998
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
   999
    (nPlanes == 2) ifTrue:[
317
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1000
        (planarConfiguration ~~ 2) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1001
            'TIFFReader [warning]: with alpha, only separate planes supported' errorPrintCR.
317
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1002
            ^ nil
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1003
        ].
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1004
        'TIFFReader [info]: ignoring alpha plane' infoPrintCR.
317
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1005
        nPlanes := 1.
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1006
        bitsPerPixel := bitsPerSample at:1.
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1007
        bitsPerSample := Array with:bitsPerPixel.
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1008
        samplesPerPixel := 1.
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1009
    ] ifFalse:[
317
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1010
        (nPlanes == 3) ifTrue:[
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1011
            (planarConfiguration ~~ 1) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1012
                'TIFFReader [warning]: only non separate planes supported' errorPrintCR.
317
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1013
                ^ nil
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1014
            ].
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1015
            bitsPerSample ~= #(8 8 8) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1016
                'TIFFReader [warning]: only 8/8/8 rgb images supported' errorPrintCR.
317
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1017
                ^ nil
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1018
            ].
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1019
            bitsPerPixel := 24
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1020
        ] ifFalse:[
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1021
            (nPlanes ~~ 1) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1022
                'TIFFReader [warning]: format not supported' errorPrintCR.
317
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1023
                ^ nil
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1024
            ].
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1025
            bitsPerPixel := bitsPerSample at:1.
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1026
        ]
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1027
    ].
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1028
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1029
    bitsPerRow := width * bitsPerPixel.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1030
    bytesPerRow := bitsPerRow // 8.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1031
    ((bitsPerRow \\ 8) ~~ 0) ifTrue:[
317
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1032
        bytesPerRow := bytesPerRow + 1
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1033
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1034
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1035
    overAllBytes := bytesPerRow * height.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1036
    data := ByteArray uninitializedNew:overAllBytes.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1037
336
9789b02d95bf oops - the very last pixel was not read (in readUncompressed ...)
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1038
    offset := 0.
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1039
    stripNr := 0.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1040
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1041
    row := 1.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1042
    [row <= height] whileTrue:[
317
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1043
        stripNr := stripNr + 1.
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1044
        nBytes := stripByteCounts at:stripNr.
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1045
        inStream position:((stripOffsets at:stripNr) + 1).
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1046
317
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1047
        offset + nBytes > overAllBytes ifTrue:[
336
9789b02d95bf oops - the very last pixel was not read (in readUncompressed ...)
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1048
            nBytes := overAllBytes - offset.
317
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1049
        ].
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1050
336
9789b02d95bf oops - the very last pixel was not read (in readUncompressed ...)
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1051
        inStream nextBytes:nBytes into:data startingAt:offset+1.
317
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1052
        offset := offset + nBytes.
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1053
        row := row + rowsPerStrip
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1054
    ]
317
5de89b17ed48 care for bad strip size (how can this happen ?)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  1055
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1056
    "Modified: 10.1.1997 / 18:10:46 / cg"
440
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1057
! !
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1058
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1059
!TIFFReader methodsFor:'private - writing'!
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1060
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1061
writeBitsPerSample
14
20638e830834 *** empty log message ***
claus
parents: 11
diff changeset
  1062
"
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1063
'bitsPerSample: ' print. bitsPerSample printNewline.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1064
'store bitspersample at: ' print. outStream position printNewline.
14
20638e830834 *** empty log message ***
claus
parents: 11
diff changeset
  1065
"
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1066
    bitsPerSamplePos := outStream position.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1067
    bitsPerSample do:[:n |
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1068
	self writeShort:n
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1069
    ]
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1070
!
3f9277473954 Initial revision
claus
parents:
diff changeset
  1071
3f9277473954 Initial revision
claus
parents:
diff changeset
  1072
writeColorMap
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1073
    |n|
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1074
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1075
    colorMapPos := outStream position.
35
f13cdd0b44c7 *** empty log message ***
claus
parents: 32
diff changeset
  1076
    #(red green blue) do:[:component |
440
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1077
        n := 0.
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1078
        colorMap do:[:clr |
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1079
            |entry|
35
f13cdd0b44c7 *** empty log message ***
claus
parents: 32
diff changeset
  1080
440
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1081
            clr isNil ifTrue:[
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1082
                entry := 0
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1083
            ] ifFalse:[
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1084
                entry := clr perform:component.
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1085
                "
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1086
                 tiff map is 16 bit - scale from percent to 0..16rFFFF
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1087
                "
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1088
                entry := (entry * 16rFFFF / 100) rounded.
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1089
            ].
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1090
            self writeShort:entry.
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1091
            n := n + 1
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1092
        ].
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1093
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1094
        "
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1095
         fill to 256 entries
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1096
        "
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1097
        [n < 256] whileTrue:[
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1098
            self writeShort:0.
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1099
            n := n + 1.
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1100
        ]
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1101
    ]
440
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1102
fa1e1a56ea43 category rename
Claus Gittinger <cg@exept.de>
parents: 398
diff changeset
  1103
    "Modified: 20.2.1997 / 18:06:10 / cg"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1104
!
3f9277473954 Initial revision
claus
parents:
diff changeset
  1105
3f9277473954 Initial revision
claus
parents:
diff changeset
  1106
writeStripByteCounts
3
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
  1107
"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1108
'stripByteCounts: ' print. stripByteCounts printNewline.
3f9277473954 Initial revision
claus
parents:
diff changeset
  1109
'store stripbytecounts at: ' print. outStream position printNewline.
3
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
  1110
"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1111
    stripByteCountsPos := outStream position.
3f9277473954 Initial revision
claus
parents:
diff changeset
  1112
    stripByteCounts do:[:c |
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1113
	self writeShort:c
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1114
    ]
3f9277473954 Initial revision
claus
parents:
diff changeset
  1115
!
3f9277473954 Initial revision
claus
parents:
diff changeset
  1116
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1117
writeStripOffsets
3
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
  1118
"
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1119
'stripOffsets: ' print. stripOffsets printNewline.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1120
'store stripoffsets at: ' print. outStream position printNewline.
3
78aaa5408119 *** empty log message ***
claus
parents: 0
diff changeset
  1121
"
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1122
    stripOffsetsPos := outStream position.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1123
    stripOffsets do:[:o |
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1124
	self writeLong:o
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1125
    ]
3f9277473954 Initial revision
claus
parents:
diff changeset
  1126
!
3f9277473954 Initial revision
claus
parents:
diff changeset
  1127
3f9277473954 Initial revision
claus
parents:
diff changeset
  1128
writeTag:tagType
3f9277473954 Initial revision
claus
parents:
diff changeset
  1129
    self writeTiffTag:tagType.
3f9277473954 Initial revision
claus
parents:
diff changeset
  1130
!
3f9277473954 Initial revision
claus
parents:
diff changeset
  1131
3f9277473954 Initial revision
claus
parents:
diff changeset
  1132
writeTiffTag:tagType
3f9277473954 Initial revision
claus
parents:
diff changeset
  1133
    |value valueArray numberType count address|
3f9277473954 Initial revision
claus
parents:
diff changeset
  1134
3f9277473954 Initial revision
claus
parents:
diff changeset
  1135
    count := 1.
3f9277473954 Initial revision
claus
parents:
diff changeset
  1136
    address := nil.
3f9277473954 Initial revision
claus
parents:
diff changeset
  1137
    (tagType == 253) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1138
	"tiff class"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1139
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1140
    (tagType == 254) ifTrue:[
3f9277473954 Initial revision
claus
parents:
diff changeset
  1141
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1142
    (tagType == 255) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1143
	"SubfileType"
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1144
	value := subFileType.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1145
	numberType := #long.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1146
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1147
    (tagType == 256) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1148
	"ImageWidth"
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1149
	value := width.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1150
	numberType := #short.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1151
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1152
    (tagType == 257) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1153
	"ImageHeight"
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1154
	value := height.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1155
	numberType := #short.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1156
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1157
    (tagType == 258) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1158
	"bitspersample"
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1159
	address := bitsPerSamplePos - 1.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1160
	numberType := #short.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1161
	count := bitsPerSample size.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1162
	valueArray := bitsPerSample
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1163
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1164
    (tagType == 259) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1165
	"compression"
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1166
	value := compression.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1167
	numberType := #short.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1168
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1169
    (tagType == 262) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1170
	"photometric"
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1171
	(photometric == #whiteIs0) ifTrue:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1172
	  value := 0
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1173
	] ifFalse:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1174
	  (photometric == #blackIs0) ifTrue:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1175
	    value := 1
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1176
	  ] ifFalse:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1177
	    (photometric == #rgb) ifTrue:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1178
	      value := 2
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1179
	    ] ifFalse:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1180
	      (photometric == #palette) ifTrue:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1181
		value := 3
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1182
	      ] ifFalse:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1183
		(photometric == #transparency) ifTrue:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1184
		  value := 4
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1185
		] ifFalse:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1186
		  self error:'bad photometric'
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1187
		]
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1188
	      ]
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1189
	    ]
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1190
	  ]
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1191
	].
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1192
	numberType := #short.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1193
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1194
    (tagType == 263) ifTrue:[
3f9277473954 Initial revision
claus
parents:
diff changeset
  1195
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1196
    (tagType == 264) ifTrue:[
3f9277473954 Initial revision
claus
parents:
diff changeset
  1197
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1198
    (tagType == 265) ifTrue:[
3f9277473954 Initial revision
claus
parents:
diff changeset
  1199
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1200
    (tagType == 266) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1201
	"fillOrder"
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1202
	(fillOrder == #msb) ifTrue:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1203
	    value := 1
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1204
	] ifFalse:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1205
	  (fillOrder == #lsb) ifTrue:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1206
	    value := 2
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1207
	  ] ifFalse:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1208
	    self error:'bad fillOrder'
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1209
	  ]
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1210
	].
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1211
	numberType := #short.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1212
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1213
    (tagType == 269) ifTrue:[
3f9277473954 Initial revision
claus
parents:
diff changeset
  1214
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1215
    (tagType == 270) ifTrue:[
3f9277473954 Initial revision
claus
parents:
diff changeset
  1216
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1217
    (tagType == 271) ifTrue:[
3f9277473954 Initial revision
claus
parents:
diff changeset
  1218
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1219
    (tagType == 272) ifTrue:[
3f9277473954 Initial revision
claus
parents:
diff changeset
  1220
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1221
    (tagType == 273) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1222
	"stripoffsets"
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1223
	address := stripOffsetsPos - 1.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1224
	numberType := #long.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1225
	count := stripOffsets size.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1226
	valueArray := stripOffsets
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1227
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1228
    (tagType == 274) ifTrue:[
3f9277473954 Initial revision
claus
parents:
diff changeset
  1229
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1230
    (tagType == 277) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1231
	"samplesPerPixel"
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1232
	value := samplesPerPixel.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1233
	numberType := #short.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1234
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1235
    (tagType == 278) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1236
	"rowsperstrip"
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1237
	value := rowsPerStrip.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1238
	numberType := #short.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1239
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1240
    (tagType == 279) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1241
	"stripbytecount"
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1242
	address := stripByteCountsPos - 1.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1243
	numberType := #short.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1244
	count := stripByteCounts size.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1245
	valueArray := stripByteCounts
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1246
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1247
    (tagType == 280) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1248
	"min sample value"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1249
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1250
    (tagType == 281) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1251
	"max sample value"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1252
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1253
    (tagType == 282) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1254
	"x resolution"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1255
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1256
    (tagType == 283) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1257
	"y resolution"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1258
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1259
    (tagType == 284) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1260
	"planarconfig"
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1261
	value := planarConfiguration.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1262
	numberType := #short.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1263
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1264
    (tagType == 285) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1265
	"pageName"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1266
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1267
    (tagType == 286) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1268
	"xPosition"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1269
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1270
    (tagType == 287) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1271
	"yPosition"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1272
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1273
    (tagType == 288) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1274
	"freeOffsets"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1275
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1276
    (tagType == 289) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1277
	"freeByteCounts"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1278
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1279
    (tagType == 290) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1280
	"grayResponceUnit"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1281
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1282
    (tagType == 291) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1283
	"grayResponceCurve"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1284
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1285
    (tagType == 292) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1286
	"group3options"
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1287
	value := group3options.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1288
	numberType := #long.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1289
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1290
    (tagType == 293) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1291
	"group4options"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1292
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1293
    (tagType == 296) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1294
	"resolutionunit"
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1295
	^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1296
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1297
    (tagType == 297) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1298
	"pageNumber"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1299
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1300
    (tagType == 300) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1301
	"colorResponceUnit"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1302
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1303
    (tagType == 301) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1304
	"colorResponceCurve"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1305
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1306
    (tagType == 306) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1307
	"dateTime"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1308
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1309
    (tagType == 315) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1310
	"artist"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1311
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1312
    (tagType == 317) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1313
	"predictor"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1314
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1315
    (tagType == 320) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1316
	"colormap"
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1317
	address := colorMapPos - 1.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1318
	numberType := #short.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1319
	count := 256 "(colorMap at:1) size" * 3.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1320
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1321
3f9277473954 Initial revision
claus
parents:
diff changeset
  1322
    (value isNil and:[address isNil]) ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1323
	self error:'unhandled tag'.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1324
	^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1325
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1326
14
20638e830834 *** empty log message ***
claus
parents: 11
diff changeset
  1327
"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1328
'tag:' print. tagType print. ' typ:' print. numberType print.
3f9277473954 Initial revision
claus
parents:
diff changeset
  1329
' len:' print. count print.
3f9277473954 Initial revision
claus
parents:
diff changeset
  1330
' val:' print. value printNewline.  
14
20638e830834 *** empty log message ***
claus
parents: 11
diff changeset
  1331
"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1332
3f9277473954 Initial revision
claus
parents:
diff changeset
  1333
    self writeShort:tagType.
3f9277473954 Initial revision
claus
parents:
diff changeset
  1334
    numberType == #short ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1335
	self writeShort:3.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1336
	self writeLong:count.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1337
    ] ifFalse:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1338
	numberType == #long ifTrue:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1339
	    self writeShort:4.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1340
	    self writeLong:count.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1341
	] ifFalse:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1342
	    numberType == #byte ifTrue:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1343
		self writeShort:1.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1344
		self writeLong:count.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1345
	    ] ifFalse:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1346
		self error:'bad numbertype'
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1347
	    ]
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1348
	]
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1349
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1350
    address notNil ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1351
	(numberType == #long and:[count == 1]) ifTrue:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1352
	    self writeLong:(valueArray at:1).
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1353
	    ^ self
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1354
	].
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1355
	(numberType == #short and:[count <= 2]) ifTrue:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1356
	    self writeShort:(valueArray at:1).
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1357
	    count == 2 ifTrue:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1358
		self writeShort:(valueArray at:2).
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1359
	    ] ifFalse:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1360
		self writeShort:0
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1361
	    ].
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1362
	    ^ self
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1363
	].
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1364
	(numberType == #byte and:[count <= 4]) ifTrue:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1365
	    outStream nextPut:(valueArray at:1).
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1366
	    count > 1 ifTrue:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1367
		outStream nextPut:(valueArray at:2).
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1368
		count > 2 ifTrue:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1369
		    outStream nextPut:(valueArray at:3).
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1370
		    count > 3 ifTrue:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1371
			outStream nextPut:(valueArray at:4).
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1372
		    ] ifFalse:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1373
			outStream nextPut:0
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1374
		    ].
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1375
		] ifFalse:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1376
		    outStream nextPut:0
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1377
		].
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1378
	    ] ifFalse:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1379
		outStream nextPut:0
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1380
	    ].
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1381
	    ^ self
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1382
	].
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1383
	self writeLong:address.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1384
	^ self
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1385
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1386
    numberType == #short ifTrue:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1387
	self writeShort:value.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1388
	self writeShort:0
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1389
    ] ifFalse:[
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1390
	numberType == #long ifTrue:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1391
	    self writeLong:value
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1392
	] ifFalse:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1393
	    numberType == #byte ifTrue:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1394
		outStream nextPut:value.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1395
		outStream nextPut:0.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1396
		outStream nextPut:0.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1397
		outStream nextPut:0.
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1398
	    ] ifFalse:[
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1399
		self error:'bad numbertype'
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1400
	    ]
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1401
	]
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1402
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1403
!
3f9277473954 Initial revision
claus
parents:
diff changeset
  1404
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1405
writeUncompressedBits
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1406
    "write bits as one or multiple strips"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1407
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1408
    |offs bytesPerRow nBytes
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1409
     h "{ Class: SmallInteger }"|
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1410
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1411
    nBytes := data size.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1412
    nBytes < 16rFFFF ifTrue:[
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1413
	stripOffsets := Array with:(outStream position - 1).
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1414
	stripByteCounts := Array with:nBytes.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1415
	outStream nextPutBytes:nBytes from:data.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1416
	rowsPerStrip := height
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1417
    ] ifFalse:[
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1418
	stripOffsets := Array basicNew:height.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1419
	bytesPerRow := nBytes // height.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1420
	stripByteCounts := (Array basicNew:height) atAllPut:bytesPerRow.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1421
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1422
	offs := 1.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1423
	h := height.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1424
	1 to:h do:[:row |
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1425
	    stripOffsets at:row put:(outStream position - 1).
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1426
	    outStream nextPutBytes:bytesPerRow from:data startingAt:offs.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1427
	    offs := offs + bytesPerRow
28
8daff0234d2e *** empty log message ***
claus
parents: 25
diff changeset
  1428
	].
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1429
	rowsPerStrip := 1
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1430
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1431
"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1432
    'stripOffsets: ' print. stripOffsets printNewline.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1433
    'stripByteCounts: ' print. stripByteCounts printNewline.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1434
"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1435
! !
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1436
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1437
!TIFFReader methodsFor:'reading from file'!
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1438
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1439
fromStream:aStream
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1440
    "read a stream containing a TIFF image.
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1441
     Leave image description in instance variables."
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1442
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1443
    |char1 char2 version 
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1444
     numberOfTags "{ Class: SmallInteger }"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1445
     tagType      "{ Class: SmallInteger }"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1446
     numberType   "{ Class: SmallInteger }"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1447
     length       "{ Class: SmallInteger }"
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
  1448
     result offset ok msb
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
  1449
     bitsPerPixel bytesPerRow offset1 offset2 tmp|
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1450
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1451
    inStream := aStream.
331
304f9c439efa allow reading from ByteArray-readStreams
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
  1452
    aStream binary.
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1453
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1454
    char1 := aStream next.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1455
    char2 := aStream next.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1456
    (char1 ~~ char2) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1457
        'TIFFReader [warning]: not a tiff file' errorPrintCR.
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1458
        ^ nil
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1459
    ].
331
304f9c439efa allow reading from ByteArray-readStreams
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
  1460
    (char1 == $I asciiValue) ifTrue:[
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1461
        byteOrder := #lsb.
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1462
        msb := false.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1463
    ] ifFalse:[
331
304f9c439efa allow reading from ByteArray-readStreams
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
  1464
        (char1 == $M asciiValue) ifTrue:[
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1465
            byteOrder := #msb.
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1466
            msb := true.
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1467
        ] ifFalse:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1468
            'TIFFReader [warning]: not a tiff file' errorPrintCR.
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1469
            ^ nil
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1470
        ]
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1471
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1472
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1473
    version := self readShort.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1474
    (version ~~ 42) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1475
        'TIFFReader [warning]: version of tiff-file not supported' errorPrintCR.
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1476
        ^ nil
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1477
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1478
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1479
    "setup default values"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1480
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1481
    compression := 1. "none"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1482
    fillOrder := #msb.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1483
    planarConfiguration := 1.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1484
    photometric := nil.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1485
    bitsPerSample := 1.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1486
    samplesPerPixel := 1.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1487
    width := nil.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1488
    height := nil.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1489
    stripOffsets := nil.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1490
    rowsPerStrip := nil.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1491
    "resolutionUnit := 2."
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1492
    predictor := 1.
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
  1493
    orientation := nil.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1494
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1495
    offset := aStream nextLongMSB:msb.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1496
    aStream position:offset + 1.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1497
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1498
    numberOfTags := self readShort.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1499
    1 to:numberOfTags do:[:index |
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1500
        tagType := self readShort.
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1501
        numberType := self readShort.
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1502
        length := aStream nextLongMSB:msb.
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1503
        self decodeTiffTag:tagType numberType:numberType length:length
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1504
    ].
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1505
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1506
    offset := aStream nextLongMSB:msb.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1507
    (offset ~~ 0) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1508
        'TIFFReader [info]: more tags ignored' infoPrintCR
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1509
    ].
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1510
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1511
    "check for required tags"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1512
    ok := true.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1513
    width isNil ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1514
        'TIFFReader [warning]: missing width tag' errorPrintCR.
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1515
        ok := false
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1516
    ].
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1517
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1518
    height isNil ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1519
        'TIFFReader [warning]: missing length tag' errorPrintCR.
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1520
        ok := false
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1521
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1522
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1523
    photometric isNil ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1524
        'TIFFReader [warning]: missing photometric tag' errorPrintCR.
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1525
        ok := false
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1526
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1527
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1528
    stripOffsets isNil ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1529
        'TIFFReader [warning]: missing stripOffsets tag' errorPrintCR.
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1530
        ok := false
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1531
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1532
3f9277473954 Initial revision
claus
parents:
diff changeset
  1533
    stripByteCounts isNil ifTrue:[
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1534
        stripOffsets size == 1 ifTrue:[
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1535
            stripByteCounts := Array with:(self bitsPerPixel // 8) * width * height
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1536
        ]
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1537
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1538
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1539
    stripByteCounts isNil ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1540
        'TIFFReader [warning]: missing stripByteCounts tag' errorPrintCR.
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1541
        ok := false
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1542
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1543
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1544
    ok ifFalse:[
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1545
        ^ nil
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1546
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1547
334
1da7672635be dimensionCallBack
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  1548
    dimensionCallBack notNil ifTrue:[
1da7672635be dimensionCallBack
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  1549
        dimensionCallBack value:self
1da7672635be dimensionCallBack
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  1550
    ].
1da7672635be dimensionCallBack
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  1551
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1552
    "given all the information, read the bits"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1553
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1554
    rowsPerStrip isNil ifTrue:[
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1555
        rowsPerStrip := height
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1556
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1557
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1558
    ok := false.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1559
    (compression == 1) ifTrue:[
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1560
        result := self readUncompressedTiffImageData.
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1561
        ok := true
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1562
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1563
    (compression == 2) ifTrue:[
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1564
        result := self readCCITT3RLETiffImageData.
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1565
        ok := true
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1566
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1567
    (compression == 3) ifTrue:[
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1568
        result := self readCCITTGroup3TiffImageData.
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1569
        ok := true
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1570
    ]. 
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1571
    (compression == 4) ifTrue:[
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1572
        result := self readCCITTGroup4TiffImageData.
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1573
        ok := true
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1574
    ]. 
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1575
    (compression == 5) ifTrue:[
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1576
        result := self readLZWTiffImageData.
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1577
        ok := true
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1578
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1579
    (compression == 6) ifTrue:[
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1580
        result := self readJPEGTiffImageData.
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1581
        ok := true
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1582
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1583
    (compression == 32766) ifTrue:[
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1584
        result := self readNeXTRLE2TiffImageData.
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1585
        ok := true
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1586
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1587
    (compression == 32771) ifTrue:[
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1588
        result := self readCCITTRLEWTiffImageData.
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1589
        ok := true
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1590
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1591
    (compression == 32773) ifTrue:[
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1592
        result := self readPackbitsTiffImageData.
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1593
        ok := true
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1594
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1595
    (compression == 32865) ifTrue:[
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1596
        result := self readNeXTJPEGTiffImageData.
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1597
        ok := true
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1598
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1599
    ok ifFalse:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1600
        'TIFFReader [warning]: compression type ' errorPrint. compression errorPrint.
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1601
        ' not known' errorPrintCR
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1602
    ].
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
  1603
393
9e9f2272b524 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1604
    orientation == #vFlip ifTrue:[
9e9f2272b524 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1605
        "/ reverse rows to top-to bottom
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
  1606
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
  1607
        bytesPerRow := self bytesPerRow.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
  1608
        tmp := ByteArray new:bytesPerRow.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
  1609
        offset1 := 1.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
  1610
        offset2 := (height-1)*bytesPerRow + 1.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
  1611
        0 to:(height-1//2) do:[:row |
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
  1612
            tmp replaceFrom:1 to:bytesPerRow
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
  1613
                with:data startingAt:offset1.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
  1614
            data replaceFrom:offset1 to:offset1+bytesPerRow-1
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
  1615
                 with:data startingAt:offset2.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
  1616
            data replaceFrom:offset2 to:offset2+bytesPerRow-1
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
  1617
                 with:tmp startingAt:1.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
  1618
            offset1 := offset1 + bytesPerRow.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
  1619
            offset2 := offset2 - bytesPerRow.
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
  1620
        ].
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
  1621
    ].
393
9e9f2272b524 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1622
    orientation == #unsupported ifTrue:[
9e9f2272b524 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1623
        'TIFFReader [warning]: unsupported orientation' errorPrintCR
9e9f2272b524 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1624
    ].
392
7729a280960c handle bottom-to-top images (orientation==4)
Claus Gittinger <cg@exept.de>
parents: 359
diff changeset
  1625
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1626
    ^ result
192
947cc10f86dc commentary
Claus Gittinger <cg@exept.de>
parents: 159
diff changeset
  1627
393
9e9f2272b524 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1628
    "Modified: 31.1.1997 / 10:51:27 / cg"
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1629
! !
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1630
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1631
!TIFFReader methodsFor:'writing to file'!
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1632
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1633
save:image onFile:aFileName
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1634
    "save image as (uncompressed) TIFF file on aFileName"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1635
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1636
    |pos1 pos|
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1637
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1638
    outStream := FileStream newFileNamed:aFileName.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1639
    outStream isNil ifTrue:[
461
bacef118f54a more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  1640
        ^ Image fileCreationErrorSignal 
bacef118f54a more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  1641
            raiseWith:image
bacef118f54a more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  1642
            errorString:('file creation error: ' , aFileName asString).
bacef118f54a more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  1643
    ].
bacef118f54a more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  1644
bacef118f54a more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  1645
    image mask notNil ifTrue:[
bacef118f54a more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  1646
        Image informationLostQuerySignal
bacef118f54a more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  1647
            raiseWith:image
bacef118f54a more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  1648
            errorString:('TIFF writer does not (yet) support an imageMask').
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1649
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1650
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1651
    "save as msb"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1652
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1653
    byteOrder := #msb.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1654
"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1655
    byteOrder := #lsb.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1656
"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1657
    fillOrder := #msb.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1658
    width := image width.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1659
    height := image height.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1660
    photometric := image photometric.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1661
    samplesPerPixel := image samplesPerPixel.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1662
    bitsPerSample := image bitsPerSample.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1663
    colorMap := image colorMap.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1664
    planarConfiguration := 1.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1665
    compression := 1.   "none"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1666
    data := image bits.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1667
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1668
    currentOffset := 0.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1669
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1670
    (byteOrder == #msb) ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1671
        outStream nextPut:$M. outStream nextPut:$M.
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1672
    ] ifFalse:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1673
        outStream nextPut:$I. outStream nextPut:$I.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1674
    ].
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1675
    currentOffset := currentOffset + 2.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1676
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1677
    outStream binary.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1678
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1679
    self writeShort:42.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1680
    currentOffset := currentOffset + 2.
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1681
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1682
    pos1 := outStream position.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1683
    self writeLong:0.           "start of tags - filled in later"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1684
    currentOffset := currentOffset + 4.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1685
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1686
    "output strips"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1687
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1688
    self writeUncompressedBits. "this outputs bits as strips, sets stripOffsets and stripByteCounts"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1689
    self writeStripOffsets.     "this outputs strip offsets, sets stripOffsetsPos"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1690
    self writeStripByteCounts.  "this outputs strip bytecounts, sets stripByteCountPos"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1691
    self writeBitsPerSample.    "this outputs bitsPerSample, sets bitsPerSamplePos"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1692
    photometric == #palette ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1693
        self writeColorMap      "this outputs colorMap, sets colorMapPos"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1694
    ].
3f9277473954 Initial revision
claus
parents:
diff changeset
  1695
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1696
    pos := outStream position.                  "backpatch tag offset"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1697
    outStream position:pos1.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1698
    self writeLong:(pos - 1).                   "fill in tag offset"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1699
    outStream position:pos.
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1700
"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1701
('patch tag offset at: ', (pos1 printStringRadix:16) , ' to ',
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1702
                         (pos printStringRadix:16)) printNewline.
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1703
"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1704
    "output tag data"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1705
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1706
    photometric == #palette ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1707
        self writeShort:11.  "11 tags"
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1708
    ] ifFalse:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1709
        self writeShort:10.  "10 tags"
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1710
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1711
    self writeTag:256.               "image width"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1712
    self writeTag:257.               "image height"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1713
    self writeTag:258.               "bits per sample"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1714
    self writeTag:259.               "compression"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1715
    self writeTag:262.               "photometric"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1716
    self writeTag:273.               "strip offsets"
159
327da5085900 fixed saving of 24bit RGB images (forgot samplesPerPixel-TAG)
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1717
    self writeTag:277.               "samplesPerPixel"
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1718
    self writeTag:278.               "rowsPerStrip"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1719
    self writeTag:279.               "strip byte counts"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1720
    self writeTag:284.               "planarconfig"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1721
    photometric == #palette ifTrue:[
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1722
        self writeTag:320            "colorMap"
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1723
    ].
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1724
    self writeLong:0.                "end of tags mark"
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1725
    outStream close
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1726
461
bacef118f54a more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  1727
    "Modified: 27.2.1997 / 12:46:26 / cg"
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1728
! !
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
  1729
357
4bcb93f5892e newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
  1730
!TIFFReader class methodsFor:'documentation'!
30
9638bc775850 *** empty log message ***
claus
parents: 28
diff changeset
  1731
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1732
version
461
bacef118f54a more signals to be raised if anything happens during
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  1733
    ^ '$Header: /cvs/stx/stx/libview2/TIFFReader.st,v 1.50 1997-02-27 11:50:14 cg Exp $'
0
3f9277473954 Initial revision
claus
parents:
diff changeset
  1734
! !
135
ff507d9a242b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 117
diff changeset
  1735
TIFFReader initialize!