diff -r cb2815b77100 -r 947cc10f86dc TIFFReader.st --- a/TIFFReader.st Mon Apr 22 13:02:23 1996 +0200 +++ b/TIFFReader.st Mon Apr 22 19:39:03 1996 +0200 @@ -11,13 +11,13 @@ " ImageReader subclass:#TIFFReader - instanceVariableNames:'planarConfiguration subFileType stripOffsets rowsPerStrip + instanceVariableNames:'planarConfiguration subFileType stripOffsets rowsPerStrip fillOrder compression group3options predictor stripByteCounts currentOffset stripOffsetsPos stripByteCountsPos bitsPerSamplePos colorMapPos' - classVariableNames:'' - poolDictionaries:'' - category:'Graphics-Images support' + classVariableNames:'' + poolDictionaries:'' + category:'Graphics-Images support' ! !TIFFReader class methodsFor:'documentation'! @@ -1377,7 +1377,8 @@ !TIFFReader methodsFor:'reading from file'! fromStream:aStream - "read an image from aStream" + "read a stream containing a TIFF image. + Leave image description in instance variables." |char1 char2 version numberOfTags "{ Class: SmallInteger }" @@ -1391,28 +1392,28 @@ char1 := aStream next. char2 := aStream next. (char1 ~~ char2) ifTrue:[ - 'TIFFReader: not a tiff file' errorPrintNL. - ^ nil + 'TIFFReader: not a tiff file' errorPrintNL. + ^ nil ]. (char1 == $I) ifTrue:[ - byteOrder := #lsb. - msb := false. + byteOrder := #lsb. + msb := false. ] ifFalse:[ - (char1 == $M) ifTrue:[ - byteOrder := #msb. - msb := true. - ] ifFalse:[ - 'TIFFReader: not a tiff file' errorPrintNL. - ^ nil - ] + (char1 == $M) ifTrue:[ + byteOrder := #msb. + msb := true. + ] ifFalse:[ + 'TIFFReader: not a tiff file' errorPrintNL. + ^ nil + ] ]. aStream binary. version := self readShort. (version ~~ 42) ifTrue:[ - 'TIFFReader: version of tiff-file not supported' errorPrintNL. - ^ nil + 'TIFFReader: version of tiff-file not supported' errorPrintNL. + ^ nil ]. "setup default values" @@ -1435,106 +1436,108 @@ numberOfTags := self readShort. 1 to:numberOfTags do:[:index | - tagType := self readShort. - numberType := self readShort. - length := aStream nextLongMSB:msb. - self decodeTiffTag:tagType numberType:numberType length:length + tagType := self readShort. + numberType := self readShort. + length := aStream nextLongMSB:msb. + self decodeTiffTag:tagType numberType:numberType length:length ]. offset := aStream nextLongMSB:msb. (offset ~~ 0) ifTrue:[ - 'TIFFReader: more tags ignored' errorPrintNL + 'TIFFReader: more tags ignored' errorPrintNL ]. "check for required tags" ok := true. width isNil ifTrue:[ - 'TIFFReader: missing width tag' errorPrintNL. - ok := false + 'TIFFReader: missing width tag' errorPrintNL. + ok := false ]. height isNil ifTrue:[ - 'TIFFReader: missing length tag' errorPrintNL. - ok := false + 'TIFFReader: missing length tag' errorPrintNL. + ok := false ]. photometric isNil ifTrue:[ - 'TIFFReader: missing photometric tag' errorPrintNL. - ok := false + 'TIFFReader: missing photometric tag' errorPrintNL. + ok := false ]. stripOffsets isNil ifTrue:[ - 'TIFFReader: missing stripOffsets tag' errorPrintNL. - ok := false + 'TIFFReader: missing stripOffsets tag' errorPrintNL. + ok := false ]. stripByteCounts isNil ifTrue:[ - stripOffsets size == 1 ifTrue:[ - stripByteCounts := Array with:(self bitsPerPixel // 8) * width * height - ] + stripOffsets size == 1 ifTrue:[ + stripByteCounts := Array with:(self bitsPerPixel // 8) * width * height + ] ]. stripByteCounts isNil ifTrue:[ - 'TIFFReader: missing stripByteCounts tag' errorPrintNL. - ok := false + 'TIFFReader: missing stripByteCounts tag' errorPrintNL. + ok := false ]. ok ifFalse:[ - ^ nil + ^ nil ]. "given all the information, read the bits" rowsPerStrip isNil ifTrue:[ - rowsPerStrip := height + rowsPerStrip := height ]. ok := false. (compression == 1) ifTrue:[ - result := self readUncompressedTiffImageData. - ok := true + result := self readUncompressedTiffImageData. + ok := true ]. (compression == 2) ifTrue:[ - result := self readCCITT3RLETiffImageData. - ok := true + result := self readCCITT3RLETiffImageData. + ok := true ]. (compression == 3) ifTrue:[ - result := self readCCITTGroup3TiffImageData. - ok := true + result := self readCCITTGroup3TiffImageData. + ok := true ]. (compression == 4) ifTrue:[ - result := self readCCITTGroup4TiffImageData. - ok := true + result := self readCCITTGroup4TiffImageData. + ok := true ]. (compression == 5) ifTrue:[ - result := self readLZWTiffImageData. - ok := true + result := self readLZWTiffImageData. + ok := true ]. (compression == 6) ifTrue:[ - result := self readJPEGTiffImageData. - ok := true + result := self readJPEGTiffImageData. + ok := true ]. (compression == 32766) ifTrue:[ - result := self readNeXTRLE2TiffImageData. - ok := true + result := self readNeXTRLE2TiffImageData. + ok := true ]. (compression == 32771) ifTrue:[ - result := self readCCITTRLEWTiffImageData. - ok := true + result := self readCCITTRLEWTiffImageData. + ok := true ]. (compression == 32773) ifTrue:[ - result := self readPackbitsTiffImageData. - ok := true + result := self readPackbitsTiffImageData. + ok := true ]. (compression == 32865) ifTrue:[ - result := self readNeXTJPEGTiffImageData. - ok := true + result := self readNeXTJPEGTiffImageData. + ok := true ]. ok ifFalse:[ - 'TIFFReader: compression type ' errorPrint. compression errorPrint. - ' not known' errorPrintNL + 'TIFFReader: compression type ' errorPrint. compression errorPrint. + ' not known' errorPrintNL ]. ^ result + + "Modified: 22.4.1996 / 19:12:12 / cg" ! ! !TIFFReader methodsFor:'writing to file'! @@ -1630,6 +1633,6 @@ !TIFFReader class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libview2/TIFFReader.st,v 1.28 1996-02-04 15:35:54 cg Exp $' + ^ '$Header: /cvs/stx/stx/libview2/TIFFReader.st,v 1.29 1996-04-22 17:38:48 cg Exp $' ! ! TIFFReader initialize!