equal
deleted
inserted
replaced
26 TIFFReader comment:' |
26 TIFFReader comment:' |
27 |
27 |
28 COPYRIGHT (c) 1991 by Claus Gittinger |
28 COPYRIGHT (c) 1991 by Claus Gittinger |
29 All Rights Reserved |
29 All Rights Reserved |
30 |
30 |
31 $Header: /cvs/stx/stx/libview2/TIFFReader.st,v 1.4 1993-10-13 02:44:27 claus Exp $ |
31 $Header: /cvs/stx/stx/libview2/TIFFReader.st,v 1.5 1993-12-11 01:33:46 claus Exp $ |
32 written Summer 91 by claus |
32 written Summer 91 by claus |
33 '! |
33 '! |
34 |
34 |
35 !TIFFReader class methodsFor:'documentation'! |
35 !TIFFReader class methodsFor:'documentation'! |
36 |
36 |
56 isValidImageFile:aFileName |
56 isValidImageFile:aFileName |
57 "return true, if aFileName contains a GIF image" |
57 "return true, if aFileName contains a GIF image" |
58 |
58 |
59 |inStream char1 char2 version| |
59 |inStream char1 char2 version| |
60 |
60 |
61 inStream := FileStream readonlyFileNamed:aFileName. |
61 inStream := self streamReadingFile:aFileName. |
62 inStream isNil ifTrue:[^ false]. |
62 inStream isNil ifTrue:[^ false]. |
63 |
63 |
64 char1 := inStream next. |
64 char1 := inStream next. |
65 char2 := inStream next. |
65 char2 := inStream next. |
66 |
66 |
87 tagType "{ Class: SmallInteger }" |
87 tagType "{ Class: SmallInteger }" |
88 numberType "{ Class: SmallInteger }" |
88 numberType "{ Class: SmallInteger }" |
89 length "{ Class: SmallInteger }" |
89 length "{ Class: SmallInteger }" |
90 result offset ok| |
90 result offset ok| |
91 |
91 |
92 inStream := FileStream readonlyFileNamed:aFileName. |
92 inStream := self class streamReadingFile:aFileName. |
93 inStream isNil ifTrue:[ |
93 inStream isNil ifTrue:[^ nil]. |
94 'open error' printNewline. |
|
95 ^ nil |
|
96 ]. |
|
97 |
94 |
98 char1 := inStream next. |
95 char1 := inStream next. |
99 char2 := inStream next. |
96 char2 := inStream next. |
100 (char1 ~~ char2) ifTrue:[ |
97 (char1 ~~ char2) ifTrue:[ |
101 'not a tiff file' printNewline. |
98 'not a tiff file' printNewline. |
1081 readUncompressedTiffImageData |
1078 readUncompressedTiffImageData |
1082 |bytesPerRow bitsPerRow nPlanes |
1079 |bytesPerRow bitsPerRow nPlanes |
1083 stripNr "{ Class: SmallInteger }" |
1080 stripNr "{ Class: SmallInteger }" |
1084 offset "{ Class: SmallInteger }" |
1081 offset "{ Class: SmallInteger }" |
1085 row "{ Class: SmallInteger }" |
1082 row "{ Class: SmallInteger }" |
1086 bytesPerStrip "{ Class: SmallInteger }" |
1083 nBytes "{ Class: SmallInteger }" |
1087 bitsPerPixel | |
1084 bitsPerPixel overAllBytes| |
1088 |
1085 |
1089 nPlanes := samplesPerPixel. |
1086 nPlanes := samplesPerPixel. |
1090 |
1087 |
1091 "only support 1-sample/pixel, |
1088 "only support 1-sample/pixel, |
1092 with alpha - if separate planes, |
1089 with alpha - if separate planes, |
1124 bytesPerRow := bitsPerRow // 8. |
1121 bytesPerRow := bitsPerRow // 8. |
1125 ((bitsPerRow \\ 8) ~~ 0) ifTrue:[ |
1122 ((bitsPerRow \\ 8) ~~ 0) ifTrue:[ |
1126 bytesPerRow := bytesPerRow + 1 |
1123 bytesPerRow := bytesPerRow + 1 |
1127 ]. |
1124 ]. |
1128 |
1125 |
1129 data := ByteArray uninitializedNew:(bytesPerRow * height). |
1126 overAllBytes := bytesPerRow * height. |
|
1127 data := ByteArray uninitializedNew:overAllBytes. |
1130 |
1128 |
1131 offset := 1. |
1129 offset := 1. |
1132 stripNr := 0. |
1130 stripNr := 0. |
1133 |
1131 |
1134 row := 1. |
1132 row := 1. |
1135 bytesPerStrip := bytesPerRow * rowsPerStrip. |
|
1136 [row <= height] whileTrue:[ |
1133 [row <= height] whileTrue:[ |
1137 stripNr := stripNr + 1. |
1134 stripNr := stripNr + 1. |
|
1135 nBytes := stripByteCounts at:stripNr. |
1138 inStream position:((stripOffsets at:stripNr) + 1). |
1136 inStream position:((stripOffsets at:stripNr) + 1). |
1139 |
1137 |
1140 inStream nextBytes:(bytesPerRow * rowsPerStrip) |
1138 inStream nextBytes:nBytes |
1141 into:data |
1139 into:data |
1142 startingAt:offset. |
1140 startingAt:offset. |
1143 |
1141 offset := offset + nBytes. |
1144 offset := offset + bytesPerStrip. |
|
1145 row := row + rowsPerStrip |
1142 row := row + rowsPerStrip |
1146 ] |
1143 ] |
1147 ! |
1144 ! |
1148 |
1145 |
1149 readLZWTiffImageData |
1146 readLZWTiffImageData |