#FEATURE by cg
class: TIFFReader
added: #readImageDataUsingDecompressor:
removed: #readImageDataUsingDecompresor:
changed:
#readDeflateTiffImageData (send #readImageDataUsingDecompressor: instead of #readImageDataUsingDecompresor:)
#readLZWTiffImageData (send #readImageDataUsingDecompressor: instead of #readImageDataUsingDecompresor:)
#readPackbitsTiffImageData (send #readImageDataUsingDecompressor: instead of #readImageDataUsingDecompresor:)
#readUncompressedTiffImageData (send #readImageDataUsingDecompressor: instead of #readImageDataUsingDecompresor:)
--- a/TIFFReader.st Tue Aug 29 23:14:17 2017 +0200
+++ b/TIFFReader.st Tue Aug 29 23:16:03 2017 +0200
@@ -897,7 +897,7 @@
!
readDeflateTiffImageData
- self readImageDataUsingDecompresor:
+ self readImageDataUsingDecompressor:
[:inBytes :inCount :outBytes :outOffset :outCount |
|zlibReader|
@@ -1037,10 +1037,10 @@
"/ ].
"/ ]
- "Modified (format): / 28-08-2017 / 03:06:39 / cg"
+ "Modified: / 29-08-2017 / 23:14:55 / cg"
!
-readImageDataUsingDecompresor:decompressorBlock
+readImageDataUsingDecompressor:decompressorBlock
|bytesPerRowIn bytesPerRow nPlanes overAllBytes
nBytes "{ Class: SmallInteger }"
stripNr "{ Class: SmallInteger }"
@@ -1058,7 +1058,7 @@
(nPlanes >= 3) ifTrue:[
(planarConfiguration ~~ PLANARCONFIG_CONTIG) ifTrue:[
- ^ self fileFormatError:'only non separate planes are supported with 3 or 4 planes'.
+ ^ self fileFormatError:('only non separate planes are supported with %1 planes' bindWith:nPlanes).
].
(nPlanes > 4) ifTrue:[
photometric == #cmyk ifTrue:[
@@ -1077,7 +1077,7 @@
(bitsPerSample conform:[:each | each == 16]) ifTrue:[
"/ ok
] ifFalse:[
- ^ self fileFormatError:'only 8 or 16 bits/channel are supported'.
+ ^ self fileFormatError:('%1 bits/sample; only 8 or 16 are supported with %2 planes' bindWith:bitsPerSample with:nPlanes).
]
].
] ifFalse:[
@@ -1127,6 +1127,13 @@
].
].
].
+
+ bitsPerSample sum isPowerOfTwo ifFalse:[
+ (#(24 48) includes:bitsPerSample sum) ifFalse:[
+ ^ self fileFormatError:'unsupported bitsPerSample: ' , bitsPerSample printString
+ ].
+ ].
+
fillOrder ~~ #msb ifTrue:[
(bitsPerSample conform:[:n | n == 8]) ifFalse:[
^ self fileFormatError:'unsupported bitsPerSample with lsb fillOrder'
@@ -1155,7 +1162,7 @@
ifFalse:[rowsPerStrip].
bytesInThisStrip := bytesPerRowIn * rowsInThisStrip.
- "/ don verify; the last strip is shorter
+ "/ don't assert; the last strip is actually shorter in many images
"/ compression == 1 ifTrue:[
"/ self assert:( nBytes == (bytesPerRowIn * rowsInThisStrip) ).
"/ ].
@@ -1238,8 +1245,7 @@
].
].
- "Created: / 27-08-2017 / 22:48:17 / cg"
- "Modified: / 28-08-2017 / 03:41:55 / cg"
+ "Created: / 29-08-2017 / 23:15:10 / cg"
!
readJBIGTiffImageData
@@ -1270,7 +1276,7 @@
!
readLZWTiffImageData
- self readImageDataUsingDecompresor:
+ self readImageDataUsingDecompressor:
[:inBytes :inCount :outBytes :outOffset :outCount |
self class
decompressLZWFrom:inBytes count:inCount
@@ -1355,7 +1361,7 @@
"/ ]
"/ ]
- "Modified: / 27-08-2017 / 22:58:36 / cg"
+ "Modified: / 29-08-2017 / 23:14:59 / cg"
!
readNeXTJPEGTiffImageData
@@ -1375,7 +1381,7 @@
!
readPackbitsTiffImageData
- self readImageDataUsingDecompresor:
+ self readImageDataUsingDecompressor:
[:inBytes :inCount :outBytes :outOffset :outCount |
self class decompressTiffPackBitsFrom:inBytes to:outBytes at:outOffset count:outCount.
].
@@ -1460,7 +1466,7 @@
"/ stripNr := stripNr + 1.
"/ ]
- "Modified: / 28-08-2017 / 00:24:21 / cg"
+ "Modified: / 29-08-2017 / 23:15:03 / cg"
!
readPixarFilmTiffImageData
@@ -1882,7 +1888,7 @@
!
readUncompressedTiffImageData
- self readImageDataUsingDecompresor:nil
+ self readImageDataUsingDecompressor:nil
"/ |bytesPerRow "{ Class: SmallInteger }"
"/ bitsPerRow "{ Class: SmallInteger }"
@@ -1983,7 +1989,7 @@
"/ where := where + nBytes.
"/ ].
- "Modified: / 27-08-2017 / 22:48:27 / cg"
+ "Modified: / 29-08-2017 / 23:15:07 / cg"
! !
!TIFFReader methodsFor:'private-reading'!