#OTHER by stefan
authorStefan Vogel <sv@exept.de>
Tue, 19 Apr 2016 16:31:06 +0200
changeset 3281 15b8e734190a
parent 3280 6ee34f6dee2f
child 3282 4e75a66b42af
#OTHER by stefan class: ImageEditor changed: #processSelectedColorsWith: fix when changing color of an image with mask
ImageEditor.st
--- a/ImageEditor.st	Tue Apr 19 15:44:55 2016 +0200
+++ b/ImageEditor.st	Tue Apr 19 16:31:06 2016 +0200
@@ -5980,7 +5980,7 @@
      the selected colors will be replaced by the value of aBlock 
      (which gets a color vector and must return a color vector)"
 
-    |img cMap modifiedColormap oldColors newImage selectedColorIndices newColors|
+    |img cMap modifiedColormap oldColors newImage selectedColorIndices newColors maskOffset|
 
     selectedColorIndices := self selectedColors value.
     selectedColorIndices isEmptyOrNil ifTrue:[^ self].
@@ -5992,17 +5992,18 @@
         ^ self
     ].
     self hasMask ifTrue:[
-        oldColors := selectedColorIndices collect:[:idx | cMap at:idx-1].
+        maskOffset := 1.
     ] ifFalse:[
-        oldColors := selectedColorIndices collect:[:idx | cMap at:idx].
+        maskOffset := 0.
     ].
+    oldColors := selectedColorIndices collect:[:idx | cMap at:idx-maskOffset].
     imageEditView makeUndo.
 
     modifiedColormap := cMap asNewArray.
 
     newColors := oldColors collect:aBlock.
     selectedColorIndices with:newColors do:[:idx :newColor | 
-        modifiedColormap at:idx put:newColor
+        modifiedColormap at:idx-maskOffset put:newColor
     ].
 
     newImage := img species new