TIFFReader.st
changeset 1230 993aaef8a28a
parent 1215 e40392a58092
child 1571 cffaf89a0c6e
--- a/TIFFReader.st	Wed Sep 08 12:00:14 1999 +0200
+++ b/TIFFReader.st	Wed Sep 08 18:30:21 1999 +0200
@@ -104,8 +104,8 @@
     char2 := inStream next.
 
     ((char1 ~~ char2) or:[(char1 ~~ $I) and:[char1 ~~ $M]]) ifTrue:[
-	inStream close.
-	^ false
+        inStream close.
+        ^ false
     ].
 
     inStream binary.
@@ -234,13 +234,13 @@
                     photometric := #palette
                   ] ifFalse:[
                     (value == 4) ifTrue:[
-                      photometric := #transparency
+                      photometric := #transparencyMask
                     ] ifFalse:[
                       (value == 5) ifTrue:[
-                        photometric := #separated  "/ color separations
+                        photometric := #cmyk  "/ color separations
                       ] ifFalse:[
                         (value == 6) ifTrue:[
-                          photometric := #ycbr    "/ CCIR 601
+                          photometric := #ycbcr    "/ CCIR 601
                         ] ifFalse:[
                           (value == 8) ifTrue:[
                             photometric := #cielab  "/ 1976 CIE L*a*b*
@@ -1410,9 +1410,7 @@
 
     nPlanes := samplesPerPixel.
 
-    "only support 1-sample/pixel,
-     with alpha - if separate planes,
-     or rgb - if non separate planes and no alpha"
+    "/ not all formats are supported here,
 
     (nPlanes == 2) ifTrue:[
         (planarConfiguration ~~ 2) ifTrue:[
@@ -1424,19 +1422,29 @@
         bitsPerSample := Array with:bitsPerPixel.
         samplesPerPixel := 1.
     ] ifFalse:[
-        (nPlanes == 3) ifTrue:[
+        (nPlanes == 4) ifTrue:[
             (planarConfiguration ~~ 1) ifTrue:[
                 ^ self fileFormatError:'only non separate planes supported'.
             ].
-            bitsPerSample ~= #(8 8 8) ifTrue:[
-                ^ self fileFormatError:'only 8/8/8 rgb images supported'.
+            bitsPerSample ~= #(8 8 8 8) ifTrue:[
+                ^ self fileFormatError:'only 8/8/8/8 cmyk images supported'.
             ].
-            bitsPerPixel := 24
+            bitsPerPixel := 32.
         ] ifFalse:[
-            (nPlanes ~~ 1) ifTrue:[
-                ^ self fileFormatError:'format not supported'.
-            ].
-            bitsPerPixel := bitsPerSample at:1.
+            (nPlanes == 3) ifTrue:[
+                (planarConfiguration ~~ 1) ifTrue:[
+                    ^ self fileFormatError:'only non separate planes supported'.
+                ].
+                bitsPerSample ~= #(8 8 8) ifTrue:[
+                    ^ self fileFormatError:'only 8/8/8 rgb images supported'.
+                ].
+                bitsPerPixel := 24
+            ] ifFalse:[
+                (nPlanes ~~ 1) ifTrue:[
+                    ^ self fileFormatError:('unsupported format: nplanes=' , nPlanes printString).
+                ].
+                bitsPerPixel := bitsPerSample at:1.
+            ]
         ]
     ].
 
@@ -1469,6 +1477,7 @@
         "/ read it 4k-wise; this leads to a better behavior,
         "/ when big images reading from a slow cdrom
         inStream nextBytes:nBytes into:data startingAt:offset+1 blockSize:4096.
+
         offset := offset + nBytes.
         row := row + rowsPerStrip
     ]
@@ -2196,6 +2205,6 @@
 !TIFFReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/TIFFReader.st,v 1.63 1999-08-04 14:13:59 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/TIFFReader.st,v 1.64 1999-09-08 16:30:21 cg Exp $'
 ! !
 TIFFReader initialize!