ST80FormReader.st
changeset 43 e85c7d392833
parent 32 6bdcb6da4d4f
child 51 ac84315b8181
--- a/ST80FormReader.st	Sat Feb 18 16:52:56 1995 +0100
+++ b/ST80FormReader.st	Sat Feb 18 16:58:20 1995 +0100
@@ -10,6 +10,8 @@
  hereby transferred.
 "
 
+'From Smalltalk/X, Version:2.10.4 on 18-feb-1995 at 2:18:48 am'!
+
 ImageReader subclass:#ST80FormReader
 	 instanceVariableNames:''
 	 classVariableNames:''
@@ -21,7 +23,7 @@
 COPYRIGHT (c) 1993 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libview2/ST80FormReader.st,v 1.5 1994-11-17 14:29:42 claus Exp $
+$Header: /cvs/stx/stx/libview2/ST80FormReader.st,v 1.6 1995-02-18 15:58:02 claus Exp $
 '!
 
 !ST80FormReader class methodsFor:'documentation'!
@@ -42,7 +44,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libview2/ST80FormReader.st,v 1.5 1994-11-17 14:29:42 claus Exp $
+$Header: /cvs/stx/stx/libview2/ST80FormReader.st,v 1.6 1995-02-18 15:58:02 claus Exp $
 "
 !
 
@@ -56,6 +58,23 @@
 "
 ! !
 
+!ST80FormReader class methodsFor:'testing'!
+
+isValidImageFile:aFileName
+    "return true, if aFileName contains an st80-bitmap-file image"
+
+    |code inStream ok|
+
+    inStream := self streamReadingFile:aFileName.
+    inStream isNil ifTrue:[^ false].
+
+    inStream binary.
+    code := inStream nextWord.
+    ok := (code == 1).
+    inStream close.
+    ^ ok
+! !
+
 !ST80FormReader methodsFor:'writing to file'!
 
 save:image onFile:aFileName
@@ -95,53 +114,27 @@
     "ST80FormReader save:(Image fromFile:'bitmaps/SBrowser.xbm') onFile:'test.form'"
 ! !
 
-!ST80FormReader class methodsFor:'testing'!
-
-isValidImageFile:aFileName
-    "return true, if aFileName contains an st80-bitmap-file image"
-
-    |code inStream|
-
-    inStream := self streamReadingFile:aFileName.
-    inStream isNil ifTrue:[^ false].
-
-    inStream binary.
-    code := inStream nextWord.
-    code == 1 ifFalse:[
-	inStream close.
-	^ false
-    ].
-    inStream close.
-    ^ true
-! !
-
 !ST80FormReader methodsFor:'reading from file'!
 
-fromFile:aFileName
+fromStream:aStream
     |nBytes code offsetX offsetY|
 
-    inStream := self class streamReadingFile:aFileName.
-    inStream isNil ifTrue:[
-	'open error' printNewline.
-	^ nil
+    inStream := aStream.
+    inStream binary.
+
+    code := inStream nextWord.
+    code isNil ifTrue:[
+        ^ nil
     ].
 
-    inStream binary.
-    code := inStream nextWord.
-    code isNil ifTrue:[
-	inStream close.
-	^ nil
-    ].
-
-    width := inStream nextWord.
-    height := inStream nextWord.
-    offsetX := inStream nextWord.
-    offsetY := inStream nextWord.
+    width := aStream nextWord.
+    height := aStream nextWord.
+    offsetX := aStream nextWord.
+    offsetY := aStream nextWord.
 
     nBytes := width + 15 // 16 * 2 * height.
     data := ByteArray new:nBytes.
-    inStream nextBytes:nBytes into:data.
-    inStream close.
+    aStream nextBytes:nBytes into:data.
 
     photometric := #whiteIs0.
     samplesPerPixel := 1.
@@ -149,3 +142,4 @@
 
     "ST80FormReader fromFile:''" 
 ! !
+