#BUGFIX by exept
authorClaus Gittinger <cg@exept.de>
Sat, 07 Sep 2019 19:32:38 +0200
changeset 8795 0bec4735e8e7
parent 8794 2bd67fbc05b5
child 8796 502cb6bba147
#BUGFIX by exept fix to convert 32bit forms class: Image changed: #from:in: class: Image class changed: #fromSubForm:in:
Image.st
--- a/Image.st	Sat Aug 31 14:36:41 2019 +0200
+++ b/Image.st	Sat Sep 07 19:32:38 2019 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1991 by Claus Gittinger
               All Rights Reserved
@@ -1371,7 +1373,14 @@
     depth := aForm depth.
     formsDevice := aForm device.
 
-    photometric := (depth > 8) ifTrue:[#rgb] ifFalse:[#palette].
+    photometric := (depth > 8) 
+                        ifTrue:[
+                            (depth > 24) ifTrue:[
+                                #rgba
+                            ] ifFalse:[
+                                #rgb
+                            ] 
+                        ] ifFalse:[#palette].
 
     (formsDevice notNil and:[depth == formsDevice depth]) ifTrue:[
         "/
@@ -16299,8 +16308,30 @@
             ddepth := aDrawable depth.
         ]. 
         photometric := aDrawable photometric.
-        samplesPerPixel := ddepth == 24 ifTrue:[3] ifFalse:[1].
-        bitsPerSample := ddepth == 24 ifTrue:[#[8 8 8]] ifFalse:[ByteArray with:bpp].
+        photometric == #rgb ifTrue:[
+            samplesPerPixel := 3.
+            bitsPerSample := #(
+                                "/ 32  #[8 8 8 8]
+                                24  #[8 8 8]
+                                16  #[5 6 5]
+                                15  #[5 5 5]
+                                12  #[4 4 4]
+                             ) asMapAt:ddepth ifAbsent:[ self error. ByteArray new:3 withAll:(ddepth//3)]
+        ] ifFalse:[
+            photometric == #rgba ifTrue:[
+                samplesPerPixel := 4.
+                bitsPerSample := #(
+                                    32  #[8 8 8 8]
+                                    "/ 24  #[8 8 8]
+                                    "/ 16  #[4 4 4 4]
+                                    "/ 15  #[5 5 5]
+                                    "/ 12  #[4 4 4]
+                                 ) asMapAt:ddepth ifAbsent:[ self error. ByteArray new:4 withAll:(ddepth//4)]
+            ] ifFalse:[
+                samplesPerPixel := 1.
+                bitsPerSample := ByteArray with:bpp.
+            ]
+        ].
     ] ifFalse:[
         "get some attributes of the display device"
         visType := device visualType.