#BUGFIX by cg
authorClaus Gittinger <cg@exept.de>
Mon, 20 Feb 2017 18:17:00 +0100
changeset 7916 eb973a816455
parent 7915 0d245ddb2030
child 7917 fb1dcd2edc4e
#BUGFIX by cg class: Image changed: #colormapFromImage:photometric:
Image.st
--- a/Image.st	Mon Feb 20 11:02:27 2017 +0100
+++ b/Image.st	Mon Feb 20 18:17:00 2017 +0100
@@ -13186,48 +13186,55 @@
     |usedColors|
 
     samplesPerPixel == 3 ifTrue:[
-        photometric := photometricOrNil ? #rgb
-    ] ifFalse:[
-        photometricOrNil isNil ifTrue:[
-            photometric := anImage photometric.
-        ] ifFalse:[
-            photometric := photometricOrNil.
-        ].
-        photometric == #palette ifTrue:[
-            self setColorMap:(anImage colorMap copy).
-            "
-             must generate/compress the colormap, if source image has higher depth
-             than myself.
+        photometric := photometricOrNil ? #rgb.
+        ^ self.
+    ].
+    samplesPerPixel == 4 ifTrue:[
+        photometric := photometricOrNil ? #rgba.
+        ^ self.
+    ].
+
+    photometricOrNil isNil ifTrue:[
+        photometric := anImage photometric.
+    ] ifFalse:[
+        photometric := photometricOrNil.
+    ].
+    
+    photometric == #palette ifTrue:[
+        self setColorMap:(anImage colorMap copy).
+        "
+         must generate/compress the colormap, if source image has higher depth
+         than myself.
+        "
+        (colorMap isNil
+        or:[anImage bitsPerPixel > self bitsPerPixel]) ifTrue:[
             "
-            (colorMap isNil
-            or:[anImage bitsPerPixel > self bitsPerPixel]) ifTrue:[
-                "
-                 get used colors are extracted into our colorMap
-                 (the at-put below will set the pixelValue according the
-                 new colorIndex
-                "
-                self setColorMap:(anImage usedColors asArray).
-                colorMap size > (1 bitShift:self bitsPerPixel) ifTrue:[
-                    'Image [warning]: possibly too many colors in image' errorPrintCR
-                ]
+             get used colors are extracted into our colorMap
+             (the at-put below will set the pixelValue according the
+             new colorIndex
+            "
+            self setColorMap:(anImage usedColors asArray).
+            colorMap size > (1 bitShift:self bitsPerPixel) ifTrue:[
+                'Image [warning]: possibly too many colors in image' errorPrintCR
             ]
-        ] ifFalse:[
-            (photometric == #blackIs0
-            or:[ photometric == #whiteIs0 ]) ifTrue:[
-            ] ifFalse:[
-                usedColors := anImage usedColors asArray.
-                usedColors size > (1 bitShift:self bitsPerPixel) ifTrue:[
-                    'Image [warning]: possibly too many colors in image' errorPrintCR.
-                    usedColors := usedColors copyTo:(1 bitShift:self bitsPerPixel).
-                ].
-                self setColorMap:usedColors.
-                photometric := #palette
-            ]
-        ]
-    ].
-
-    "Created: 20.9.1995 / 00:58:42 / claus"
-    "Modified: 10.1.1997 / 17:52:21 / cg"
+        ].
+        ^ self.
+    ].
+    
+    (photometric == #blackIs0 or:[ photometric == #whiteIs0 ]) ifTrue:[
+        ^ self. "/ nothing to do
+    ].
+    
+    usedColors := anImage usedColors asArray.
+    usedColors size > (1 bitShift:self bitsPerPixel) ifTrue:[
+        'Image [warning]: possibly too many colors in image' errorPrintCR.
+        usedColors := usedColors copyTo:(1 bitShift:self bitsPerPixel).
+    ].
+    self setColorMap:usedColors.
+    photometric := #palette
+
+    "Created: / 20-09-1995 / 00:58:42 / claus"
+    "Modified: / 20-02-2017 / 18:16:26 / cg"
 !
 
 fromDeviceForm:aForm maskForm:aMaskFormOrNil