*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Tue, 19 Oct 2004 19:09:17 +0200
changeset 2764 3302aab746d2
parent 2763 844f86135a02
child 2765 5bc0bfbeac33
*** empty log message ***
ImageEditView.st
--- a/ImageEditView.st	Sat Oct 16 15:29:33 2004 +0200
+++ b/ImageEditView.st	Tue Oct 19 19:09:17 2004 +0200
@@ -1023,7 +1023,7 @@
     "paste the image in the clipboard at aPoint"
 
     |answer anyColorMissing choosedBox imagePoint imgX imgY copiedImage imageBox newColorMap
-     existingColors newColors allColors currentColorMap newColormap|
+     existingColors newColors allColors currentColorMap newColormap anyColorAdded oldColorMap|
 
     Object errorSignal handle:[:ex|
         ex signal == Image unrepresentableColorSignal ifFalse:[
@@ -1045,22 +1045,21 @@
                 "/ check, if its in the colormap of the
                 "/ target image.
 
-                anyColorMissing := false.
-                image colorMap notNil ifTrue:[
+                anyColorMissing := anyColorAdded := false.
+                oldColorMap := image colorMap.
+                oldColorMap notNil ifTrue:[
+                    newColorMap := oldColorMap asOrderedCollection.
                     copiedImage usedValues do:[:pixel |
-                        |pastedColor oldColorMap|
+                        |pastedColor |
 
                         pastedColor := copiedImage colorFromValue:pixel.
-                        oldColorMap := image colorMap.
-
-                        (oldColorMap detect: [:clr| clr = pastedColor] ifNone: nil) isNil
+
+                        (newColorMap detect: [:clr| clr = pastedColor] ifNone: nil) isNil
                         ifTrue:[        
-                            oldColorMap size < (1 bitShift:image depth) ifTrue:[
+                            newColorMap size < (1 bitShift:image depth) ifTrue:[
                                 "/ add to colormap
-                                newColorMap isNil ifTrue:[
-                                    newColorMap := oldColorMap asOrderedCollection.
-                                ].
                                 newColorMap add:pastedColor.
+                                anyColorAdded := true.
         "/                        Transcript showCR:'adding color:' , pastedColor displayString , ' to targets colorMap'.
                             ] ifFalse:[
         "/                        Transcript showCR:'color:' , pastedColor displayString , ' not found in targets colorMap'.
@@ -1072,6 +1071,7 @@
                         ]
                     ].
                 ].
+
                 anyColorMissing ifTrue:[
                     answer := Dialog
                                 confirmWithCancel:'Some color(s) cannot be represented (colorMap full).\Use nearest or compute colorMap ?' withCRs 
@@ -1169,7 +1169,7 @@
                     self undo.
                     ^ self.
                 ].
-                newColorMap notNil ifTrue:[
+                anyColorAdded ifTrue:[
                     image colorMap:(MappedPalette withColors:newColorMap).
                 ].
             ].
@@ -1183,7 +1183,6 @@
                 "/ which is not useful here
                 image copyFrom: copiedImage x:0 y:0 toX: imagePoint x y: imagePoint y width: copiedImage width height: copiedImage height.
             ] ifFalse:[
-
                 imgX := imagePoint x.
                 imgY := imagePoint y.
 
@@ -1204,8 +1203,7 @@
                         or:[modeSymbol == #withMask]])
                         ifTrue:[
                             newMasked ifFalse:[
-                                image 
-                                    colorAtX:dstX y:dstY put:(copiedImage colorAtX:x y:y).
+                                image colorAtX:dstX y:dstY put:(copiedImage colorAtX:x y:y).
                                 wasMasked ifTrue:[
                                     image maskAtX:dstX y:dstY put:1
                                 ].
@@ -2263,7 +2261,7 @@
 !ImageEditView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.197 2004-10-14 13:18:25 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.198 2004-10-19 17:09:17 cg Exp $'
 ! !
 
 ImageEditView initialize!