ImageEditView.st
changeset 4149 758a4573b5e4
parent 4137 1a5fdfd6cd4f
child 4203 a257aa6878ac
--- a/ImageEditView.st	Wed Oct 24 19:24:07 2012 +0200
+++ b/ImageEditView.st	Mon Oct 29 12:41:35 2012 +0100
@@ -2576,7 +2576,7 @@
 !
 
 saveMethod
-    ((resourceSelector trimBlanks isEmptyOrNil) | resourceClass isBehavior not) ifTrue: [
+    (resourceSelector trimBlanks notEmptyOrNil and:[ resourceClass isBehavior ]) ifFalse: [
         ^ self saveMethodAs.
     ].
 
@@ -2585,7 +2585,27 @@
             (self confirm:(ex errorString,'\\Debug?' withCRs)) ifTrue:[ ex reject ].
             ^ false                                 
         ] do: [   
-            |category imageStoreStream sel mthd imageKey|
+            |img depth bestDepth numColorsUsed category imageStoreStream sel mthd imageKey|
+
+            img := self image.
+            depth := img depth.
+            numColorsUsed := (img usedColorsMax:256) size.
+            bestDepth := image depth.
+            #(8 4 2 1) do:[:d |
+                depth > d ifTrue:[
+                    numColorsUsed <= (1 << d) ifTrue:[
+                        bestDepth := d
+                    ]
+                ]
+            ].
+            bestDepth < depth ifTrue:[
+                (Dialog 
+                    confirm:(resources stringWithCRs:'Hint:\\You can save some code space, by converting the image from a depth-%1 to a depth-%2 image first.\(only %3 colors used)\\Save anyway?'
+                                with:depth with:bestDepth with:numColorsUsed))
+                ifFalse:[
+                    ^ false
+                ]
+            ].
 
             SmalltalkCodeGeneratorTool
                 createImageSpecMethodFor:self image 
@@ -2757,11 +2777,11 @@
 !ImageEditView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.250 2012-07-27 09:08:32 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.251 2012-10-29 11:41:35 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.250 2012-07-27 09:08:32 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.251 2012-10-29 11:41:35 cg Exp $'
 ! !
 
 ImageEditView initialize!