# HG changeset patch # User Claus Gittinger # Date 1547474615 -3600 # Node ID 74101a749a34e2cf097570b91e535ab1c70d99cd # Parent b97f51aaa9ac9ba348799c2b8db84741956f35df #BUGFIX by cg class: ImageEditor changed: #changeHLSOfColors: #makeSelectedColorShifted #processSelectedColorsWith: diff -r b97f51aaa9ac -r 74101a749a34 ImageEditor.st --- a/ImageEditor.st Thu Jan 03 14:19:29 2019 +0100 +++ b/ImageEditor.st Mon Jan 14 15:03:35 2019 +0100 @@ -1,5 +1,3 @@ -"{ Encoding: utf8 }" - " COPYRIGHT (c) 1997-1998 by eXept Software AG All Rights Reserved @@ -5836,8 +5834,8 @@ resourceSelector notNil ifTrue:[ ^ resources string:(self modified - ifTrue:['ImageEditor (modified): %1 » %2'] - ifFalse:['ImageEditor: %1 » %2']) + ifTrue:['ImageEditor (modified): %1 » %2'] + ifFalse:['ImageEditor: %1 » %2']) with:resourceClass name with:resourceSelector ]. @@ -5870,8 +5868,8 @@ resourceSelector notNil ifTrue:[ ^ resources string:(self modified - ifTrue:['Image (modified) from: %1 » %2'] - ifFalse:['Image from: %1 » %2']) + ifTrue:['Image (modified) from: %1 » %2'] + ifFalse:['Image from: %1 » %2']) with:resourceClass name with:resourceSelector ]. @@ -6803,10 +6801,12 @@ image := imageEditView image. originalColormap := image colorMap copy. originalPixels := image bits. - red := (colorsToShift collect:[:clr | clr red]) average. - green := (colorsToShift collect:[:clr | clr green]) average. - blue := (colorsToShift collect:[:clr | clr blue]) average. - avgColor := Color red:red green:green blue:blue. + colorsToShift size > 0 ifTrue:[ + red := (colorsToShift collect:[:clr | clr red]) average. + green := (colorsToShift collect:[:clr | clr green]) average. + blue := (colorsToShift collect:[:clr | clr blue]) average. + avgColor := Color red:red green:green blue:blue. + ]. avgColorHolder value:avgColor. previewImage := self image magnifiedPreservingRatioTo:100@100. @@ -6891,16 +6891,20 @@ bindings at:#hueShiftAmount put:(hueShift := 0 asValue). hueShift onChangeEvaluate:shiftAction. - bindings at:#lightAmount put:(lightValue := 100 asValue). + bindings at:#lightAmount put:(lightValue := 1.0 asValue). lightValue onChangeEvaluate:shiftAction. - bindings at:#saturationAmount put:(saturationValue := 100 asValue). + bindings at:#saturationAmount put:(saturationValue := 1.0 asValue). saturationValue onChangeEvaluate:shiftAction. bindings at:#acceptChannel put:acceptChannel. bindings at:#hlsColor put:avgColorHolder. bindings at:#previewImageHolder put:previewImageHolder. + bindings at:#resetHueShift put:[ hueShift value: 0 ]. + bindings at:#resetLightFactor put:[ lightValue value: 1.0 ]. + bindings at:#resetSaturationFactor put:[ saturationValue value: 1.0 ]. + (self openDialogInterface:#changeHLSDialogSpec withBindings:bindings) ifFalse:[ anyChange ifTrue:[ @@ -6918,6 +6922,7 @@ ]. "Modified (comment): / 28-08-2017 / 13:04:44 / cg" + "Modified: / 14-01-2019 / 14:52:50 / Claus Gittinger" ! clearColormapEntry0AndMaskedPixels @@ -7461,10 +7466,13 @@ "/ if there is a mask, it is at position 1 in the table cmapOffset := self hasTransparentColorInColorList ifTrue:[1] ifFalse:[0]. - colors := self selectedColors value collect:[:idx | cMap at:idx-cmapOffset]. + colors := self selectedColors value + select:[:idx | idx > cmapOffset] + thenCollect:[:idx | cMap at:idx-cmapOffset]. self changeHLSOfColors:colors. "Modified: / 05-09-2017 / 09:03:47 / cg" + "Modified: / 14-01-2019 / 14:46:51 / Claus Gittinger" ! makeSelectedColorSlightlyBrighter @@ -7662,6 +7670,11 @@ oldColors := cMap asArray. processingSubset := false. ] ifFalse:[ + selectedColorIndices := selectedColorIndices select:[:idx | idx > maskOffset]. + selectedColorIndices isEmpty ifTrue:[ + Dialog warn:'Please select any non-mask color'. + ^ self. + ]. oldColors := selectedColorIndices collect:[:idx | cMap at:idx-maskOffset]. processingSubset := true. ]. @@ -7669,7 +7682,7 @@ imageEditView makeUndo. modifiedColormap := cMap asNewArray. - (selectedColorIndices max - maskOffset) > modifiedColormap size ifTrue:[ + (selectedColorIndices max - maskOffset) > modifiedColormap size ifTrue:[ |t| t := Array new:(selectedColorIndices max - maskOffset). t replaceFrom:1 with:modifiedColormap. @@ -7708,7 +7721,7 @@ self selectedColors value:selectedColorIndices. "Modified: / 08-10-2017 / 09:20:13 / cg" - "Modified: / 27-05-2018 / 10:34:25 / Claus Gittinger" + "Modified: / 14-01-2019 / 14:56:49 / Claus Gittinger" ! reduceNumberOfColors