WindowsIconReader.st
changeset 3581 cbd1af2f743b
parent 3579 94a3b7222275
child 3583 ccf4b1d2548a
--- a/WindowsIconReader.st	Fri Mar 04 19:43:52 2016 +0100
+++ b/WindowsIconReader.st	Fri Mar 04 19:53:34 2016 +0100
@@ -937,7 +937,8 @@
     numColor ~~ 0 ifTrue:[
         "read the colormap - notice: its in BGR order (sigh)"
 
-        numColor > (2 raisedTo:inDepth) ifTrue:[
+        numColor > 4096 ifTrue:[
+            "/ colormap only allowed up to 12bit
             ^ self fileFormatError:'unreasonable colormap size'.
         ].    
         colorMap := self
@@ -985,11 +986,32 @@
     dataStart notNil ifTrue:[
         aStream position:dataStart.
     ].
+    
+    inDepth <= 8 ifTrue:[
+        photometric := #palette.
 
-    inDepth <= 8 ifTrue:[
+        inDepth == 1 ifTrue:[
+            colorMap isNil ifTrue:[
+                photometric := #blackIs0
+            ] ifFalse:[
+                colorMap size == 2 ifTrue:[
+                    ((colorMap at:1) = (Color white)
+                    and:[(colorMap at:2) = (Color black)]) ifTrue:[
+                        photometric := #whiteIs0.
+                        colorMap := nil.
+                    ] ifFalse:[
+                        ((colorMap at:1) = (Color black)
+                        and:[(colorMap at:2) = (Color white)]) ifTrue:[
+                            photometric := #blackIs0.
+                            colorMap := nil.
+                        ].                    
+                    ].                    
+                ].
+            ].
+        ].
+
         samplesPerPixel := 1.
         bitsPerSample := Array with:inDepth.
-        photometric := #palette.
     ] ifFalse:[
         inDepth == 16 ifTrue:[
             photometric := #palette.