look at useful width & height, before interpreting image data
(conflict with TGA ...)
--- a/ST80FormReader.st Mon Apr 21 18:57:34 1997 +0200
+++ b/ST80FormReader.st Mon Apr 21 19:50:12 1997 +0200
@@ -78,7 +78,7 @@
isValidImageFile:aFileName
"return true, if aFileName contains an st80-bitmap-file image"
- |code inStream ok|
+ |code inStream ok w h|
inStream := self streamReadingFile:aFileName.
inStream isNil ifTrue:[^ false].
@@ -86,8 +86,17 @@
inStream binary.
code := inStream nextWord.
ok := (code == 1).
+
+ w := inStream nextWord.
+ h := inStream nextWord.
+ ((w == 0) or:[h == 0]) ifTrue:[
+ ok := false
+ ].
+
inStream close.
^ ok
+
+ "Modified: 21.4.1997 / 19:48:56 / cg"
! !
!ST80FormReader methodsFor:'reading from file'!
@@ -104,9 +113,17 @@
code isNil ifTrue:[
^ nil
].
+ code ~~ 1 ifTrue:[
+ 'ST80FormReader [warning]: expected magic 1' errorPrintCR.
+ ^ nil
+ ].
width := aStream nextWord.
height := aStream nextWord.
+ ((width == 0) or:[height == 0]) ifTrue:[
+ 'ST80FormReader [warning]: zero width/height' errorPrintCR.
+ ^ nil
+ ].
offsetX := aStream nextWord.
offsetY := aStream nextWord.
@@ -118,7 +135,9 @@
samplesPerPixel := 1.
bitsPerSample := #(1)
- "ST80FormReader fromFile:''"
+ "ST80FormReader fromFile:''"
+
+ "Modified: 21.4.1997 / 19:47:43 / cg"
! !
!ST80FormReader methodsFor:'writing to file'!
@@ -171,6 +190,6 @@
!ST80FormReader class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/ST80FormReader.st,v 1.17 1997-02-27 11:50:58 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/ST80FormReader.st,v 1.18 1997-04-21 17:50:12 cg Exp $'
! !
ST80FormReader initialize!
--- a/STFormRdr.st Mon Apr 21 18:57:34 1997 +0200
+++ b/STFormRdr.st Mon Apr 21 19:50:12 1997 +0200
@@ -78,7 +78,7 @@
isValidImageFile:aFileName
"return true, if aFileName contains an st80-bitmap-file image"
- |code inStream ok|
+ |code inStream ok w h|
inStream := self streamReadingFile:aFileName.
inStream isNil ifTrue:[^ false].
@@ -86,8 +86,17 @@
inStream binary.
code := inStream nextWord.
ok := (code == 1).
+
+ w := inStream nextWord.
+ h := inStream nextWord.
+ ((w == 0) or:[h == 0]) ifTrue:[
+ ok := false
+ ].
+
inStream close.
^ ok
+
+ "Modified: 21.4.1997 / 19:48:56 / cg"
! !
!ST80FormReader methodsFor:'reading from file'!
@@ -104,9 +113,17 @@
code isNil ifTrue:[
^ nil
].
+ code ~~ 1 ifTrue:[
+ 'ST80FormReader [warning]: expected magic 1' errorPrintCR.
+ ^ nil
+ ].
width := aStream nextWord.
height := aStream nextWord.
+ ((width == 0) or:[height == 0]) ifTrue:[
+ 'ST80FormReader [warning]: zero width/height' errorPrintCR.
+ ^ nil
+ ].
offsetX := aStream nextWord.
offsetY := aStream nextWord.
@@ -118,7 +135,9 @@
samplesPerPixel := 1.
bitsPerSample := #(1)
- "ST80FormReader fromFile:''"
+ "ST80FormReader fromFile:''"
+
+ "Modified: 21.4.1997 / 19:47:43 / cg"
! !
!ST80FormReader methodsFor:'writing to file'!
@@ -171,6 +190,6 @@
!ST80FormReader class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/Attic/STFormRdr.st,v 1.17 1997-02-27 11:50:58 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/Attic/STFormRdr.st,v 1.18 1997-04-21 17:50:12 cg Exp $'
! !
ST80FormReader initialize!