# HG changeset patch # User Claus Gittinger # Date 1438019184 -7200 # Node ID 2dbc0662a8c7823dc9f83d404d4d08e779303673 # Parent cd187ade19da2cd12565f09cdcaeae90048dbff3 class: ImageEditor changed: #colorMapMode: diff -r cd187ade19da -r 2dbc0662a8c7 ImageEditor.st --- a/ImageEditor.st Mon Jul 27 19:02:25 2015 +0200 +++ b/ImageEditor.st Mon Jul 27 19:46:24 2015 +0200 @@ -1,5 +1,3 @@ -"{ Encoding: utf8 }" - " COPYRIGHT (c) 1997-1998 by eXept Software AG All Rights Reserved @@ -5398,6 +5396,8 @@ oldFileName := oldImage fileName. Image imageErrorSignal handle:[:ex| + "/ arrive here only if not all colors can be represented; + "/ then do a more expensive nearest color search Color colorErrorSignal handle:[:ex| colorMapMode value:prevMode. imageEditView undo. @@ -5411,26 +5411,29 @@ bits:(ByteArray new:(newImage bytesPerRow * newImage height)); mask:oldImage mask. - oldImage colorsFromX:0 y:0 toX:(oldImage width-1) y:(oldImage height-1) do: - [:x :y :clr | - |newColor| - - (newColorMap includes:clr) - ifTrue: [newColor := clr] - ifFalse: [ - newColor := clr nearestIn:newColorMap. - useNearest ifFalse:[ - (newColor deltaFrom:clr) > 0.5 ifTrue:[ - newColor := oldImage colorFromValue:0 + oldImage + colorsFromX:0 y:0 + toX:(oldImage width-1) y:(oldImage height-1) + do:[:x :y :clr | + |newColor| + + (newColorMap includes:clr) + ifTrue: [newColor := clr] + ifFalse: [ + newColor := clr nearestIn:newColorMap. + useNearest ifFalse:[ + (newColor deltaFrom:clr) > 0.5 ifTrue:[ + newColor := oldImage colorFromValue:0 + ] ] - ] - ]. - newImage colorAtX:x y:y put:newColor. - ]. + ]. + newImage colorAtX:x y:y put:newColor. + ]. + image := newImage ]. ] do:[ - image := newImage fromImage:oldImage photometric:newImage photometric. + image := newImage fromImage:oldImage photometric:oldImage photometric. ]. (aMode asString startsWith:'mask') ifTrue:[