#OTHER by stefan
class: ImageEditor
changed: #processSelectedColorsWith:
fix when changing color of an image with mask
--- 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