--- a/TargaReader.st Tue Jul 09 16:11:19 2002 +0200
+++ b/TargaReader.st Wed Jul 17 12:56:36 2002 +0200
@@ -10,6 +10,8 @@
hereby transferred.
"
+"{ Package: 'stx:libview2' }"
+
ImageReader subclass:#TargaReader
instanceVariableNames:'orientation'
classVariableNames:''
@@ -71,12 +73,22 @@
isValidImageFile:aFileName
"return true, if aFileName contains a targa-file image"
- |aStream w h depth flags|
+ |aStream w h depth flags imageType ok|
+
+ ok := true.
aStream := self streamReadingFile:aFileName.
aStream isNil ifTrue:[^ false].
aStream binary.
- aStream skip:12. "/ skip 12 bytes
+
+ aStream next. "lenID"
+ aStream next. "hasColorMap"
+ imageType := aStream next.
+ aStream skip:2. "cmapOffset"
+ aStream skip:2. "cmapLength"
+ aStream next. "cmapEntrySize"
+ aStream skip:2. "xOrg"
+ aStream skip:2. "yOrg"
w := aStream nextShortMSB:false.
h := aStream nextShortMSB:false.
@@ -84,12 +96,22 @@
depth := aStream next.
flags := aStream next.
- (#(8 "16" 24 32) includes:depth) ifFalse:[
- aStream close. ^ false
+ "/ MapRGB == 1
+ "/ RawRGB == 2
+ "/ RawMono == 3
+ "/ MapEnCode == 9
+ "/ RawEnCode == 10
+
+ (#(1 2 3 9 10) includes:imageType) ifFalse:[
+ "/ 'TargaReader [warning]: unsupported imageType: ' errorPrint. imageType errorPrintCR.
+ ok := false
+ ] ifTrue:[
+ (#(8 "16" 24 32) includes:depth) ifFalse:[
+ ok := false
+ ].
].
-
aStream close.
- ^ true
+ ^ ok
"
TargaReader isValidImageFile:'bitmaps/test.tga'
@@ -496,6 +518,6 @@
!TargaReader class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/TargaReader.st,v 1.19 1998-10-13 17:58:40 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/TargaReader.st,v 1.20 2002-07-17 10:56:36 cg Exp $'
! !
TargaReader initialize!