diff -r c5068006116d -r 06c3681a79b3 ImageEditor.st --- a/ImageEditor.st Wed Aug 03 20:06:23 2005 +0200 +++ b/ImageEditor.st Wed Aug 03 22:20:46 2005 +0200 @@ -2913,10 +2913,23 @@ colorMapMode setValue:colorMapModeKey. listOfColors := self listOfColors. + image depth > 12 ifTrue:[ listOfColors removeAll. image colorMap isEmptyOrNil ifTrue:[ someOrAllUsedColors := image usedColorsMax:10000. + someOrAllUsedColors := someOrAllUsedColors asArray. + someOrAllUsedColors sort:[:a :b | + a redByte == b redByte ifTrue:[ + a greenByte == b greenByte ifTrue:[ + a blueByte < b blueByte + ] ifFalse:[ + a greenByte < b greenByte + ] + ] ifFalse:[ + a redByte < b redByte + ] + ]. listOfColors addAll:someOrAllUsedColors. "/ listOfColors add:Color black; add:Color white. ] ifFalse:[ @@ -2948,7 +2961,7 @@ ! update:something with:aParameter from:changedObject - |clrIndex img clr| + |clrIndex img clr changedColor| img := self image. @@ -2978,9 +2991,15 @@ (self hasMask) ifTrue:[ clrIndex := clrIndex - 1. ]. - - (img colorMap ? drawingColormap) at:clrIndex put:(changedObject at:aParameter). - self colorMapChanged. + changedColor := changedObject at:aParameter. + img colorMap notNil ifTrue:[ + img colorMap at:clrIndex put:changedColor. + self colorMapChanged. + ] ifFalse:[ + drawingColormap notNil ifTrue:[ + drawingColormap at:clrIndex put:changedColor. + ]. + ]. ^ self ]. ^ self @@ -3114,19 +3133,41 @@ !ImageEditor methodsFor:'data access'! -atColor:aOldColor put:aNewColor +atColor:aOldColor put:newColor "a color changed to a new color " - |index list| + |index list oldColor image newImage| list := self listOfColors. index := list identityIndexOf:aOldColor. index ~~ 0 ifTrue:[ - list at:index put:aNewColor + oldColor := list at:index. + list at:index put:newColor ] ifFalse:[ self error:'internal error' mayProceed:true. - list add:aNewColor + list add:newColor + ]. + + image := self image. + (image colorMap isNil + and:[drawingColormap isNil]) ifTrue:[ + oldColor notNil ifTrue:[ + imageEditView makeUndo. + newImage := image copy. + newImage + colorsFromX:0 y:0 toX:(image width-1) y:(image height-1) + do:[:x :y :clr | + |newClr| + + newClr := (clr = oldColor) ifTrue:newColor ifFalse:clr. + newImage colorAtX:x y:y put:newClr + ]. + imageEditView image:newImage. + imageEditView setModified. + self updateImage. + self updateImagePreView. + ] ]. ! @@ -3790,6 +3831,7 @@ tmpBits := oldImage bits ] ifFalse:[ colorMapMode value:prevMode. + self findColorMapMode. self warn:('Too many used colors in image (', oldImage usedColors size printString , ').'). ^ self "/ (self confirm:('Too many used colors in image (', oldImage usedColors size printString , ').\\Dither ?' withCRs))