care for nil-data when converting to an image
authorClaus Gittinger <cg@exept.de>
Thu, 23 Nov 2000 18:11:01 +0100
changeset 3386 b9294699dbcf
parent 3385 777869fdc56d
child 3387 a00c5b0b5eb7
care for nil-data when converting to an image
ImageReader.st
--- a/ImageReader.st	Thu Nov 23 14:29:32 2000 +0100
+++ b/ImageReader.st	Thu Nov 23 18:11:01 2000 +0100
@@ -1809,6 +1809,7 @@
 bitsPerPixel
     "return the number of bits per pixel"
 
+    bitsPerSample isNil ifTrue:[^ nil].
     ^ (bitsPerSample inject:0 into:[:sum :i | sum + i])
 !
 
@@ -1940,25 +1941,26 @@
     |image depth|
 
     depth := self bitsPerPixel.
-    image := Image newForDepth:depth.
-    image depth:depth.
-    inStream isFileStream ifTrue:[
-        image fileName:inStream pathName.
+    depth notNil ifTrue:[
+        image := Image newForDepth:depth.
+        image depth:depth.
+        inStream isFileStream ifTrue:[
+            image fileName:inStream pathName.
+        ].
+        image 
+            width:width 
+            height:height
+            photometric:photometric
+            samplesPerPixel:samplesPerPixel
+            bitsPerSample:bitsPerSample
+            colorMap:colorMap
+            bits:data
+            mask:mask.
+
+        imageSequence notNil ifTrue:[
+            image imageSequence:imageSequence.
+        ].
     ].
-    image 
-        width:width 
-        height:height
-        photometric:photometric
-        samplesPerPixel:samplesPerPixel
-        bitsPerSample:bitsPerSample
-        colorMap:colorMap
-        bits:data
-        mask:mask.
-
-    imageSequence notNil ifTrue:[
-        image imageSequence:imageSequence.
-    ].
-
     ^ image
 
     "Modified: / 15.1.1998 / 15:46:24 / stefan"
@@ -2145,5 +2147,5 @@
 !ImageReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/ImageReader.st,v 1.72 2000-08-21 22:44:31 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/ImageReader.st,v 1.73 2000-11-23 17:11:01 cg Exp $'
 ! !