XWDReader.st
changeset 51 ac84315b8181
parent 49 f7938135fb9a
child 83 97fd04d167c8
--- a/XWDReader.st	Thu Mar 23 17:51:31 1995 +0100
+++ b/XWDReader.st	Thu Mar 23 17:54:02 1995 +0100
@@ -8,6 +8,11 @@
  be provided or otherwise made available to, or used by, any
  other person.  No title to or ownership of the software is
  hereby transferred.
+
+
+ The above copyright does not apply to:
+	XWDReader>>save:onFile:
+ which is in the public domain.
 "
 
 ImageReader subclass:#XWDReader
@@ -21,7 +26,7 @@
 COPYRIGHT (c) 1995 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libview2/XWDReader.st,v 1.5 1995-03-18 05:13:10 claus Exp $
+$Header: /cvs/stx/stx/libview2/XWDReader.st,v 1.6 1995-03-23 16:54:02 claus Exp $
 '!
 
 !XWDReader class methodsFor:'documentation'!
@@ -37,12 +42,17 @@
  be provided or otherwise made available to, or used by, any
  other person.  No title to or ownership of the software is
  hereby transferred.
+
+
+ The above copyright does not apply to:
+	XWDReader>>save:onFile:
+ which is in the public domain.
 "
 !
 
 version
 "
-$Header: /cvs/stx/stx/libview2/XWDReader.st,v 1.5 1995-03-18 05:13:10 claus Exp $
+$Header: /cvs/stx/stx/libview2/XWDReader.st,v 1.6 1995-03-23 16:54:02 claus Exp $
 "
 !
 
@@ -53,6 +63,17 @@
 "
 ! !
 
+!XWDReader class methodsFor:'queries'!
+
+canRepresent:anImage
+    "return true, if anImage can be represented in my file format.
+     Only depth8 palette images are supported."
+
+    anImage depth ~~ 8 ifTrue:[^ false].
+    anImage photometric ~~ #palette ifTrue:[^ false].
+    ^ true
+! !
+
 !XWDReader methodsFor:'image reading'!
 
 fromStream: aStream 
@@ -154,16 +175,14 @@
 	    DISTRIBUTION    world
 	    VERSION         1.0
 	    DATE            July 1993
+
+	thanks to Brad for giving us the base for this mehtod.
     "
 
-    | aStream rgbColor paletteColors ncolors cindex dumpName headerSize |
+    |aStream rgbColor paletteColors ncolors cindex dumpName headerSize|
 
-    image bitsPerPixel ~~ 8 ifTrue:[
-	self error:'XWD format only supports 8bit images'.
-	^ nil
-    ].
-    image photometric ~~ #palette ifTrue:[
-	self error:'XWD format only supports palette images'.
+    (self class canRepresent:image) ifFalse:[
+	self error:'XWD format only supports 8bit palette images'.
 	^ nil
     ].
 
@@ -249,4 +268,3 @@
      (Image fromFile: '/tmp/st.xwd') inspect 
     "
 ! !
-