TIFFReader.st
changeset 11 1d0df18a7049
parent 6 4ac87e6bf82f
child 14 20638e830834
--- a/TIFFReader.st	Sat Dec 11 02:31:47 1993 +0100
+++ b/TIFFReader.st	Sat Dec 11 02:33:46 1993 +0100
@@ -28,7 +28,7 @@
 COPYRIGHT (c) 1991 by Claus Gittinger
               All Rights Reserved
 
-$Header: /cvs/stx/stx/libview2/TIFFReader.st,v 1.4 1993-10-13 02:44:27 claus Exp $
+$Header: /cvs/stx/stx/libview2/TIFFReader.st,v 1.5 1993-12-11 01:33:46 claus Exp $
 written Summer 91 by claus
 '!
 
@@ -58,7 +58,7 @@
 
     |inStream char1 char2 version|
 
-    inStream := FileStream readonlyFileNamed:aFileName.
+    inStream := self streamReadingFile:aFileName.
     inStream isNil ifTrue:[^ false].
 
     char1 := inStream next.
@@ -89,11 +89,8 @@
      length       "{ Class: SmallInteger }"
      result offset ok|
 
-    inStream := FileStream readonlyFileNamed:aFileName.
-    inStream isNil ifTrue:[
-        'open error' printNewline. 
-        ^ nil
-    ].
+    inStream := self class streamReadingFile:aFileName.
+    inStream isNil ifTrue:[^ nil].
 
     char1 := inStream next.
     char2 := inStream next.
@@ -1083,8 +1080,8 @@
      stripNr       "{ Class: SmallInteger }"
      offset        "{ Class: SmallInteger }"
      row           "{ Class: SmallInteger }" 
-     bytesPerStrip "{ Class: SmallInteger }"
-     bitsPerPixel |
+     nBytes        "{ Class: SmallInteger }"
+     bitsPerPixel overAllBytes|
 
     nPlanes := samplesPerPixel.
 
@@ -1126,22 +1123,22 @@
         bytesPerRow := bytesPerRow + 1
     ].
 
-    data := ByteArray uninitializedNew:(bytesPerRow * height).
+    overAllBytes := bytesPerRow * height.
+    data := ByteArray uninitializedNew:overAllBytes.
 
     offset := 1.
     stripNr := 0.
 
     row := 1.
-    bytesPerStrip := bytesPerRow * rowsPerStrip.
     [row <= height] whileTrue:[
         stripNr := stripNr + 1.
+        nBytes := stripByteCounts at:stripNr.
         inStream position:((stripOffsets at:stripNr) + 1).
 
-        inStream nextBytes:(bytesPerRow * rowsPerStrip)
-                      into:data
-                startingAt:offset.
-
-        offset := offset + bytesPerStrip.
+            inStream nextBytes:nBytes 
+                          into:data
+                    startingAt:offset.
+        offset := offset + nBytes.
         row := row + rowsPerStrip
     ]
 !