825 orientation: horizontal |
825 orientation: horizontal |
826 stop: 1000 |
826 stop: 1000 |
827 step: 1 |
827 step: 1 |
828 ) |
828 ) |
829 (LabelSpec |
829 (LabelSpec |
|
830 label: 'Color Shift' |
|
831 name: 'Label2' |
|
832 layout: (LayoutFrame 5 0 110 0 -15 0.5 132 0) |
|
833 translateLabel: true |
|
834 ) |
|
835 (LabelSpec |
830 name: 'HueColorLabel' |
836 name: 'HueColorLabel' |
831 layout: (LayoutFrame 10 0.0 109 0 -10 1.0 148 0) |
837 layout: (LayoutFrame 18 0.0 133 0 -41 0.5 217 0) |
|
838 level: -1 |
832 backgroundChannel: hlsColor |
839 backgroundChannel: hlsColor |
833 translateLabel: true |
840 translateLabel: true |
|
841 ) |
|
842 (LabelSpec |
|
843 label: 'Preview' |
|
844 name: 'Label3' |
|
845 layout: (LayoutFrame 5 0.5 110 0 -5 1 132 0) |
|
846 translateLabel: true |
|
847 ) |
|
848 (LabelSpec |
|
849 name: 'PreviewLabel' |
|
850 layout: (LayoutFrame 36 0.5 133 0 -23 1.0 217 0) |
|
851 level: -1 |
|
852 translateLabel: true |
|
853 labelChannel: previewImageHolder |
834 ) |
854 ) |
835 (HorizontalPanelViewSpec |
855 (HorizontalPanelViewSpec |
836 name: 'HorizontalPanel1' |
856 name: 'HorizontalPanel1' |
837 layout: (LayoutFrame 0 0.0 -30 1 0 1.0 0 1) |
857 layout: (LayoutFrame 0 0.0 -30 1 0 1.0 0 1) |
838 horizontalLayout: fitSpace |
858 horizontalLayout: fitSpace |
4012 changeHLS |
4032 changeHLS |
4013 "interactive Hue/Light/Saturation editing" |
4033 "interactive Hue/Light/Saturation editing" |
4014 |
4034 |
4015 |bindings hueShift lightValue saturationValue originalColormap firstChange acceptChannel |
4035 |bindings hueShift lightValue saturationValue originalColormap firstChange acceptChannel |
4016 shiftAction avgColorHolder avgColor shiftedColor shiftProcess readySema |
4036 shiftAction avgColorHolder avgColor shiftedColor shiftProcess readySema |
4017 originalPixels p| |
4037 originalPixels p previewImage previewImageHolder originalPreviewColormap originalPreviewPixels |
|
4038 anyChange | |
4018 |
4039 |
4019 "/ compute the averageColor in the background (while asking user) |
4040 "/ compute the averageColor in the background (while asking user) |
|
4041 avgColorHolder := nil asValue. |
|
4042 previewImageHolder := nil asValue. |
|
4043 |
4020 readySema := Semaphore new. |
4044 readySema := Semaphore new. |
4021 [ |
4045 [ |
4022 |image| |
4046 |image| |
4023 |
4047 |
4024 image := imageEditView image. |
4048 image := imageEditView image. |
4025 originalColormap := image colorMap copy. |
4049 originalColormap := image colorMap copy. |
|
4050 originalPixels := image bits. |
4026 avgColor := image averageColor. |
4051 avgColor := image averageColor. |
4027 originalPixels := image bits. |
4052 avgColorHolder value:avgColor. |
|
4053 |
|
4054 previewImage := self image magnifiedPreservingRatioTo:100@100. |
|
4055 previewImageHolder value: previewImage. |
|
4056 originalPreviewColormap := previewImage colorMap copy. |
|
4057 originalPreviewPixels := previewImage bits. |
|
4058 |
4028 readySema signal. |
4059 readySema signal. |
4029 ] forkAt:7. |
4060 ] forkAt:7. |
4030 |
4061 |
4031 acceptChannel := TriggerValue new. |
4062 acceptChannel := TriggerValue new. |
4032 avgColorHolder := avgColor asValue. |
|
4033 |
4063 |
4034 firstChange := true. |
4064 firstChange := true. |
|
4065 anyChange := false. |
4035 |
4066 |
4036 shiftedColor := [:clr :hShift :lFactor :sFactor | |
4067 shiftedColor := [:clr :hShift :lFactor :sFactor | |
4037 Color |
4068 Color |
4038 hue:((clr hue) ? 0 + hShift) |
4069 hue:((clr hue) ? 0 + hShift) |
4039 light:((clr light * lFactor / 100) "min:100") |
4070 light:((clr light * lFactor / 100) "min:100") |
4046 acceptChannel value:true. |
4077 acceptChannel value:true. |
4047 |
4078 |
4048 firstChange ifTrue:[ |
4079 firstChange ifTrue:[ |
4049 imageEditView makeUndo. |
4080 imageEditView makeUndo. |
4050 firstChange := false. |
4081 firstChange := false. |
|
4082 anyChange := true. |
4051 ]. |
4083 ]. |
4052 readySema notNil ifTrue:[readySema wait. readySema := nil]. |
4084 readySema notNil ifTrue:[readySema wait. readySema := nil]. |
4053 |
4085 |
4054 hShift := hueShift value. |
4086 hShift := hueShift value. |
4055 lFactor := lightValue value. |
4087 lFactor := lightValue value. |
4056 sFactor := saturationValue value. |
4088 sFactor := saturationValue value. |
4057 |
4089 |
4058 avgColorHolder value:(shiftedColor value:avgColor value:hShift value:lFactor value:sFactor). |
4090 avgColorHolder value:(shiftedColor value:avgColor value:hShift value:lFactor value:sFactor). |
|
4091 |
|
4092 previewImage |
|
4093 colorMap:originalPreviewColormap copy; |
|
4094 bits:originalPreviewPixels copy; |
|
4095 release; |
|
4096 colorMapProcessing:[:clr | shiftedColor value:clr value:hShift value:lFactor value:sFactor]. |
|
4097 previewImageHolder value:nil; value:previewImage. |
4059 |
4098 |
4060 shiftProcess notNil ifTrue:[ |
4099 shiftProcess notNil ifTrue:[ |
4061 shiftProcess terminate. |
4100 shiftProcess terminate. |
4062 shiftProcess waitUntilTerminated. |
4101 shiftProcess waitUntilTerminated. |
4063 shiftProcess := nil. |
4102 shiftProcess := nil. |
4087 bindings at:#saturationAmount put:(saturationValue := 100 asValue). |
4126 bindings at:#saturationAmount put:(saturationValue := 100 asValue). |
4088 saturationValue onChangeEvaluate:shiftAction. |
4127 saturationValue onChangeEvaluate:shiftAction. |
4089 |
4128 |
4090 bindings at:#acceptChannel put:acceptChannel. |
4129 bindings at:#acceptChannel put:acceptChannel. |
4091 bindings at:#hlsColor put:avgColorHolder. |
4130 bindings at:#hlsColor put:avgColorHolder. |
|
4131 bindings at:#previewImageHolder put:previewImageHolder. |
4092 |
4132 |
4093 (self openDialogInterface:#changeHLSDialogSpec withBindings:bindings) |
4133 (self openDialogInterface:#changeHLSDialogSpec withBindings:bindings) |
4094 ifFalse:[ |
4134 ifFalse:[ |
4095 firstChange ~~ true ifTrue:[ |
4135 anyChange ifTrue:[ |
4096 imageEditView undo |
4136 imageEditView undo |
4097 ] |
4137 ] |
4098 ]. |
4138 ]. |
4099 |
4139 |
4100 (p := shiftProcess) notNil ifTrue:[ |
4140 (p := shiftProcess) notNil ifTrue:[ |
4101 p waitUntilTerminated. |
4141 p waitUntilTerminated. |
4102 ]. |
4142 ]. |
4103 self updateImage. |
4143 |
4104 self updateImagePreView. |
4144 anyChange ifTrue:[ |
|
4145 self updateImage. |
|
4146 self updateImagePreView. |
|
4147 ]. |
4105 ! |
4148 ! |
4106 |
4149 |
4107 clearMaskedPixels |
4150 clearMaskedPixels |
4108 "clear all masked pixels (to pixelValue 0)" |
4151 "clear all masked pixels (to pixelValue 0)" |
4109 |
4152 |