*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Sun, 27 Jan 2008 17:05:01 +0100
changeset 2260 9a6345ae1c56
parent 2259 6135c53d6903
child 2261 60725fccd12d
*** empty log message ***
ImageEditor.st
--- a/ImageEditor.st	Sun Jan 27 17:04:52 2008 +0100
+++ b/ImageEditor.st	Sun Jan 27 17:05:01 2008 +0100
@@ -4118,8 +4118,10 @@
 
         imageEditView makeUndo.
 
-        newImage    := Image newForDepth:depth.
+        newImage := Image newForDepth:depth.
         newImage depth:depth.
+        newImage photometric:oldImage photometric.
+
         oldFileName := oldImage fileName.
 
         Image imageErrorSignal handle:[:ex|
@@ -4133,7 +4135,7 @@
                 newImage colorMap:newColorMap.
                 newImage photometric:#palette.
                 newImage bits:(ByteArray new:(newImage bytesPerRow * newImage height)).
-            
+
                 oldImage colorsFromX:0 y:0 toX:(oldImage width-1) y:(oldImage height-1) do:
                 [:x :y :clr |
                     |newColor|
@@ -4153,7 +4155,7 @@
                 image := newImage
             ].
         ] do:[ 
-            image := newImage fromImage:oldImage
+            image := newImage fromImage:oldImage.
         ].
 
         (aMode asString startsWith:'mask') ifTrue:[
@@ -4704,6 +4706,10 @@
         imageEditView makeUndo.
 
         newImage := image copy.
+        newImage photometric == #palette ifTrue:[
+            newImage colorMap:(OrderedCollection new).
+        ].
+
         image
             colorsFromX:0 y:0 toX:(image width-1) y:(image height-1) 
             do:[:x :y :clr |
@@ -4717,6 +4723,11 @@
                 nb := (b roundTo:rndB) min:255. 
 
                 newClr := Color redByte:nr greenByte:ng blueByte:nb.
+                newImage photometric == #palette ifTrue:[
+                    (newImage colorMap includes:newClr) ifFalse:[
+                        newImage colorMap add:newClr
+                    ].
+                ].
                 newImage colorAtX:x y:y put:newClr
             ].
 
@@ -5092,21 +5103,29 @@
 doMagnifyImageBy
     "magnifies the current image (by a scale)"
 
-    |box oldSize newSize scale image|
+    |box oldSize newSize scaleString scale image|
 
     image := imageEditView image.
     oldSize := image extent.
 
-    box := EnterBox new.
-    box title:(resources string:'Scale factor (<1 to shrink; >1 to magnify):').
-    box okText:(resources string:'OK').
-    box abortText:(resources string:'Cancel').
-    box initialText:1 printString.
-    box showAtPointer.
-
-    (box accepted 
-    and: [(scale := Object readFromString:(box contents) onError:nil) notNil])
-    ifTrue:[
+    scaleString := Dialog 
+                   request:(resources string:'Scale factor (<1 to shrink; >1 to magnify):') 
+                   initialAnswer:'1'
+                   list:#('0.25' '0.5' '2' '4').     
+
+"/    box := EnterBox new.
+"/    box title:(resources string:'Scale factor (<1 to shrink; >1 to magnify):').
+"/    box okText:(resources string:'OK').
+"/    box abortText:(resources string:'Cancel').
+"/    box initialText:1 printString.
+"/    box showAtPointer.
+"/    box accepted ifTrue:[
+"/        scaleString := box contents.
+"/    ].
+
+    scale := Object readFromString:scaleString onError:nil.
+
+    scale notNil ifTrue:[
         scale isNumber ifFalse:[
             self warn:'please enter a scale factor (<1 to shrink; >1 to magnify).'.
             ^ self.