2234 activeHelpKey: settingsGridMagnification |
2239 activeHelpKey: settingsGridMagnification |
2235 label: 'Grid Magnification Limit...' |
2240 label: 'Grid Magnification Limit...' |
2236 itemValue: doChangeGridMagnification |
2241 itemValue: doChangeGridMagnification |
2237 translateLabel: true |
2242 translateLabel: true |
2238 ) |
2243 ) |
|
2244 (MenuItem |
|
2245 label: 'Pen' |
|
2246 translateLabel: true |
|
2247 submenu: |
|
2248 (Menu |
|
2249 ( |
|
2250 (MenuItem |
|
2251 label: '1' |
|
2252 itemValue: penWidth: |
|
2253 translateLabel: true |
|
2254 argument: 1 |
|
2255 ) |
|
2256 (MenuItem |
|
2257 label: '5' |
|
2258 itemValue: penWidth: |
|
2259 translateLabel: true |
|
2260 argument: 5 |
|
2261 ) |
|
2262 (MenuItem |
|
2263 label: '10' |
|
2264 itemValue: penWidth: |
|
2265 translateLabel: true |
|
2266 argument: 10 |
|
2267 ) |
|
2268 ) |
|
2269 nil |
|
2270 nil |
|
2271 ) |
|
2272 ) |
2239 ) |
2273 ) |
2240 nil |
2274 nil |
2241 nil |
2275 nil |
2242 ) |
2276 ) |
2243 ) |
2277 ) |
4112 ] |
4144 ] |
4113 |
4145 |
4114 "Modified: / 20-07-2007 / 09:18:59 / cg" |
4146 "Modified: / 20-07-2007 / 09:18:59 / cg" |
4115 ! |
4147 ! |
4116 |
4148 |
|
4149 colorize |
|
4150 "interactive Hue editing" |
|
4151 |
|
4152 |bindings hueShift lightValue saturationValue originalColormap firstChange acceptChannel |
|
4153 shiftAction avgColorHolder avgColor shiftedColor shiftProcess readySema |
|
4154 originalPixels p| |
|
4155 |
|
4156 "/ compute the averageColor in the background (while asking user) |
|
4157 readySema := Semaphore new. |
|
4158 [ |
|
4159 |image| |
|
4160 |
|
4161 image := imageEditView image. |
|
4162 originalColormap := image colorMap copy. |
|
4163 avgColor := image averageColor. |
|
4164 originalPixels := image bits. |
|
4165 readySema signal. |
|
4166 ] forkAt:7. |
|
4167 |
|
4168 acceptChannel := TriggerValue new. |
|
4169 avgColorHolder := avgColor asValue. |
|
4170 |
|
4171 firstChange := true. |
|
4172 |
|
4173 shiftedColor := [:clr :hShift :lFactor :sFactor | |
|
4174 Color |
|
4175 hue:((clr hue) ? 0 + hShift) |
|
4176 light:((clr light * lFactor / 100) "min:100") |
|
4177 saturation:(((clr saturation max:20) * sFactor / 100) "min:100")]. |
|
4178 |
|
4179 |
|
4180 shiftAction := |
|
4181 [ |
|
4182 |hShift lFactor sFactor| |
|
4183 |
|
4184 acceptChannel value:true. |
|
4185 |
|
4186 firstChange ifTrue:[ |
|
4187 imageEditView makeUndo. |
|
4188 firstChange := false. |
|
4189 ]. |
|
4190 readySema notNil ifTrue:[readySema wait. readySema := nil]. |
|
4191 |
|
4192 hShift := hueShift value. |
|
4193 lFactor := lightValue value. |
|
4194 sFactor := saturationValue value. |
|
4195 |
|
4196 avgColorHolder value:(shiftedColor value:avgColor value:hShift value:lFactor value:sFactor). |
|
4197 |
|
4198 shiftProcess notNil ifTrue:[ |
|
4199 shiftProcess terminate. |
|
4200 shiftProcess waitUntilTerminated. |
|
4201 shiftProcess := nil. |
|
4202 ]. |
|
4203 shiftProcess := |
|
4204 [ |
|
4205 [ |
|
4206 imageEditView image |
|
4207 colorMap:originalColormap copy; |
|
4208 bits:originalPixels copy; |
|
4209 release; |
|
4210 colorMapProcessing:[:clr | shiftedColor value:clr value:hShift value:lFactor value:sFactor]. |
|
4211 self updateImage. |
|
4212 self updateInfoLabel. |
|
4213 self updateImagePreView. |
|
4214 ] ensure:[ shiftProcess := nil ]. |
|
4215 ] forkAt:7. |
|
4216 ]. |
|
4217 |
|
4218 bindings := IdentityDictionary new. |
|
4219 bindings at:#hueShiftAmount put:(hueShift := 0 asValue). |
|
4220 hueShift onChangeEvaluate:shiftAction. |
|
4221 |
|
4222 bindings at:#lightAmount put:(lightValue := 100 asValue). |
|
4223 lightValue onChangeEvaluate:shiftAction. |
|
4224 |
|
4225 bindings at:#saturationAmount put:(saturationValue := 100 asValue). |
|
4226 saturationValue onChangeEvaluate:shiftAction. |
|
4227 |
|
4228 bindings at:#acceptChannel put:acceptChannel. |
|
4229 bindings at:#hlsColor put:avgColorHolder. |
|
4230 |
|
4231 (self openDialogInterface:#changeHLSDialogSpec withBindings:bindings) |
|
4232 ifFalse:[ |
|
4233 firstChange ~~ true ifTrue:[ |
|
4234 imageEditView undo |
|
4235 ] |
|
4236 ]. |
|
4237 |
|
4238 (p := shiftProcess) notNil ifTrue:[ |
|
4239 p waitUntilTerminated. |
|
4240 ]. |
|
4241 self updateImage. |
|
4242 self updateImagePreView. |
|
4243 |
|
4244 "Created: / 01-11-2007 / 23:27:37 / cg" |
|
4245 ! |
|
4246 |
4117 compressColorMap |
4247 compressColorMap |
4118 "calculates a new color map for the image, using only used colors" |
4248 "calculates a new color map for the image, using only used colors" |
4119 |
4249 |
4120 |depth newColorMap newImage oldImage usedColors oldToNew oldBits newBits tmpBits| |
4250 |depth newColorMap newImage oldImage usedColors oldToNew oldBits newBits tmpBits| |
4121 |
4251 |