#UI_ENHANCEMENT by cg draft
authorClaus Gittinger <cg@exept.de>
Tue, 29 Aug 2017 20:00:56 +0200
changeset 3469 52837773925b
parent 3468 2cf3a445a2f6
child 3470 da26c2e9a037
#UI_ENHANCEMENT by cg class: ImageEditor changed: #defaultInfoLabel #ditherToDepth:
ImageEditor.st
--- a/ImageEditor.st	Mon Aug 28 13:06:26 2017 +0200
+++ b/ImageEditor.st	Tue Aug 29 20:00:56 2017 +0200
@@ -5506,18 +5506,27 @@
     resourceClass notNil ifTrue:[
         resourceSelector := imageEditView resourceSelector.
         resourceSelector notNil ifTrue:[
-            ^ resourceClass name, '  ', resourceSelector
+            ^ resources 
+                    string:(self modified 
+                            ifTrue:['Image (modified) from: %1  %2']
+                            ifFalse:['Image from: %1  %2'])
+                    with:resourceClass name
+                    with:resourceSelector
         ].
     ].
     
     (img := imageEditView image) notNil ifTrue:[
         img fileName notNil ifTrue:[
-            ^ resources string:'Image from: %1.' with:(img fileName asFilename baseName).
+            ^ resources 
+                    string:(self modified 
+                            ifTrue:['Image (modified) from: %1']
+                            ifFalse:['Image from: %1'])
+                     with:(img fileName asFilename baseName).
         ].    
     ].    
     ^ resources string:'No class and selector defined.'
 
-    "Modified: / 27-08-2017 / 15:02:52 / cg"
+    "Modified: / 29-08-2017 / 19:47:25 / cg"
 !
 
 openDocumentation
@@ -7528,13 +7537,14 @@
 !
 
 ditherToDepth:depth 
-    |ditherColors useStandardColors nGrey greyColorsAlready moreColors d|
-
-    useStandardColors := true.
-"/    useStandardColors := Dialog confirmWithCancel:'Dither in standard colors or use a new (optimized) colormap ?'.
-"/    useStandardColors isNil ifTrue:[^ self].
-
-    useStandardColors ifTrue:[
+    |ditherColors computeNewColormap nGrey greyColorsAlready moreColors d|
+
+    computeNewColormap := Dialog 
+                            confirmWithCancel:'Compute a new (optimized) colormap?\\(or else use a standard colormap)\\Warning: this may take some time...' withCRs
+                            default:false.
+    computeNewColormap isNil ifTrue:[^ self].
+
+    computeNewColormap ifFalse:[
         depth = 1 ifTrue:[
             ditherColors := Array with:(Color black) with:(Color white).
         ] ifFalse:[ depth = 2 ifTrue:[
@@ -7548,15 +7558,18 @@
         ] ifFalse:[ depth = 4 ifTrue:[
             ditherColors := Color vgaColors. 
         ] ifFalse:[ depth = 5 ifTrue:[
-            ditherColors := Color colorCubeWithRed:4 green:4 blue:2. 
+            ditherColors := Color colorCubeWithRed:3 green:4 blue:2.
         ] ifFalse:[ depth = 6 ifTrue:[
             ditherColors := Color colorCubeWithRed:4 green:4 blue:3.
-        ] ifFalse:[ depth <= 8 ifTrue:[
-            ditherColors := Color colorCubeWithRed:6 green:6 blue:5. 
+        ] ifFalse:[ depth = 7 ifTrue:[
+            ditherColors := Color colorCubeWithRed:5 green:5 blue:4. 
+        ] ifFalse:[ depth == 8 ifTrue:[
+            ditherColors := Color standardDitherColorsForDepth8. 
         ] ifFalse:[ 
             self error:'unsupported depth'.
-        ]]]]]]].
-
+        ]]]]]]]].
+
+        "/ add as many gray colors as possible.
         nGrey := (2 raisedTo:depth) - ditherColors size.  
         nGrey > 0 ifTrue:[
             nGrey := nGrey min:128.
@@ -7568,8 +7581,11 @@
 
             ditherColors := ditherColors , moreColors.
         ].
-    ] ifFalse:[
-        self halt:'unhandled dither color setup'.
+    ] ifTrue:[
+        ditherColors :=
+            Color
+                best:(1 bitShift:depth) 
+                ditherColorsForImage:self image
     ].
 
     self withExecuteCursorDo:[
@@ -7580,7 +7596,7 @@
     ].
 
     "Created: / 07-07-2006 / 13:20:56 / cg"
-    "Modified (format): / 24-08-2017 / 17:53:46 / cg"
+    "Modified: / 29-08-2017 / 17:37:51 / cg"
 !
 
 do3DProjection