care for funny number of colors (nColor > (1<<depth))
authorClaus Gittinger <cg@exept.de>
Fri, 10 Apr 1998 12:15:25 +0200
changeset 898 cdf6cc132b53
parent 897 feac294893a5
child 899 a2676b9f61ba
care for funny number of colors (nColor > (1<<depth))
WinIconRdr.st
WindowsIconReader.st
--- a/WinIconRdr.st	Thu Apr 09 20:22:42 1998 +0200
+++ b/WinIconRdr.st	Fri Apr 10 12:15:25 1998 +0200
@@ -495,6 +495,13 @@
                 srcIndex := srcIndex + 1.
             ]
         ].
+        numColor > (1 bitShift:inDepth) ifTrue:[
+            'funny number of colors in image' infoPrintCR.
+            numColor := 1 bitShift:inDepth.
+            rMap := rMap copyTo:numColor.
+            gMap := gMap copyTo:numColor.
+            bMap := bMap copyTo:numColor.
+        ].
     ].
 
     "/ check for valid compression
@@ -542,6 +549,15 @@
         bitsPerSample := #(8 8 8).
         ^ self
     ].
+    inDepth == 1 ifTrue:[
+        photometric := #blackIs0.
+        samplesPerPixel := 1.
+        bitsPerSample := #(1).
+        ^ self
+    ].
+    inDepth ~~ 8 ifTrue:[
+        self halt:'unsupported depth'.
+    ].
 
     photometric := #palette.
     samplesPerPixel := 1.
@@ -549,7 +565,7 @@
     colorMap := Colormap redVector:rMap greenVector:gMap blueVector:bMap.
 
     "Modified: / 17.9.1995 / 18:48:46 / claus"
-    "Modified: / 3.2.1998 / 20:19:41 / cg"
+    "Modified: / 10.4.1998 / 00:28:55 / cg"
 !
 
 fromWindowsICOFile:aFilename 
@@ -790,6 +806,6 @@
 !WindowsIconReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/Attic/WinIconRdr.st,v 1.38 1998-02-03 19:22:21 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/Attic/WinIconRdr.st,v 1.39 1998-04-10 10:15:25 cg Exp $'
 ! !
 WindowsIconReader initialize!
--- a/WindowsIconReader.st	Thu Apr 09 20:22:42 1998 +0200
+++ b/WindowsIconReader.st	Fri Apr 10 12:15:25 1998 +0200
@@ -495,6 +495,13 @@
                 srcIndex := srcIndex + 1.
             ]
         ].
+        numColor > (1 bitShift:inDepth) ifTrue:[
+            'funny number of colors in image' infoPrintCR.
+            numColor := 1 bitShift:inDepth.
+            rMap := rMap copyTo:numColor.
+            gMap := gMap copyTo:numColor.
+            bMap := bMap copyTo:numColor.
+        ].
     ].
 
     "/ check for valid compression
@@ -542,6 +549,15 @@
         bitsPerSample := #(8 8 8).
         ^ self
     ].
+    inDepth == 1 ifTrue:[
+        photometric := #blackIs0.
+        samplesPerPixel := 1.
+        bitsPerSample := #(1).
+        ^ self
+    ].
+    inDepth ~~ 8 ifTrue:[
+        self halt:'unsupported depth'.
+    ].
 
     photometric := #palette.
     samplesPerPixel := 1.
@@ -549,7 +565,7 @@
     colorMap := Colormap redVector:rMap greenVector:gMap blueVector:bMap.
 
     "Modified: / 17.9.1995 / 18:48:46 / claus"
-    "Modified: / 3.2.1998 / 20:19:41 / cg"
+    "Modified: / 10.4.1998 / 00:28:55 / cg"
 !
 
 fromWindowsICOFile:aFilename 
@@ -790,6 +806,6 @@
 !WindowsIconReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/WindowsIconReader.st,v 1.38 1998-02-03 19:22:21 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/WindowsIconReader.st,v 1.39 1998-04-10 10:15:25 cg Exp $'
 ! !
 WindowsIconReader initialize!