18 selectedColorIndex postOpenAction imageSeqNr drawingColormap |
18 selectedColorIndex postOpenAction imageSeqNr drawingColormap |
19 lastShiftUsedWrap lastGrabbedScreenArea |
19 lastShiftUsedWrap lastGrabbedScreenArea |
20 allowedToChangeImageDimensionAndDepth savedImage savedFile' |
20 allowedToChangeImageDimensionAndDepth savedImage savedFile' |
21 classVariableNames:'DefaultRelativeSizes LastColormapMode LastDirectory |
21 classVariableNames:'DefaultRelativeSizes LastColormapMode LastDirectory |
22 LastSizeString LastURL MaskClipboard LastDepth |
22 LastSizeString LastURL MaskClipboard LastDepth |
23 LastNumThresholdGrayColors' |
23 LastNumThresholdGrayColors LastMagnifyTo LastMagnifyBy |
|
24 LastMagnifySmoothing' |
24 poolDictionaries:'' |
25 poolDictionaries:'' |
25 category:'Interface-UIPainter' |
26 category:'Interface-UIPainter' |
26 ! |
27 ! |
27 |
28 |
28 !ImageEditor class methodsFor:'documentation'! |
29 !ImageEditor class methodsFor:'documentation'! |
8331 doMagnifyImage |
8332 doMagnifyImage |
8332 "magnifies the current image to a new size" |
8333 "magnifies the current image to a new size" |
8333 |
8334 |
8334 |box newSize image antiAliased| |
8335 |box newSize image antiAliased| |
8335 |
8336 |
8336 antiAliased := false asValue. |
8337 antiAliased := (LastMagnifySmoothing ? false) asValue. |
8337 image := imageEditView image. |
8338 image := imageEditView image. |
8338 |
8339 |
8339 box := EnterBox new. |
8340 box := EnterBox new. |
8340 box title:(resources string:'Images new size:'). |
8341 box title:(resources string:'Images new size:'). |
8341 box okText:(resources string:'OK'). |
8342 box okText:(resources string:'OK'). |
8342 box abortText:(resources string:'Cancel'). |
8343 box abortText:(resources string:'Cancel'). |
8343 box initialText:image extent printString. |
8344 box initialText:(LastMagnifyTo ? image extent) printString. |
8344 box verticalPanel add:(CheckBox label:(resources string:'Antialias/Smooth') model:antiAliased). |
8345 box verticalPanel add:(CheckBox label:(resources string:'Antialias/Smooth') model:antiAliased). |
8345 box showAtPointer. |
8346 box showAtPointer. |
8346 |
8347 |
8347 (box accepted |
8348 (box accepted |
8348 and: [(newSize := self pointFromString:(box contents)) notNil]) |
8349 and: [(newSize := self pointFromString:(box contents)) notNil]) |
8349 ifTrue:[ |
8350 ifTrue:[ |
8350 newSize isPoint ifFalse:[ |
8351 newSize isPoint ifFalse:[ |
8351 self warn:'Please enter the new size as ''x @ y''.'. |
8352 self warn:'Please enter the new size as ''x @ y''.'. |
8352 ^ self. |
8353 ^ self. |
8353 ]. |
8354 ]. |
|
8355 LastMagnifyTo := newSize. |
|
8356 LastMagnifySmoothing := antiAliased value. |
8354 antiAliased value ifTrue:[ |
8357 antiAliased value ifTrue:[ |
8355 ((newSize x < image width) or:[(newSize y < image height)]) ifTrue:[ |
8358 ((newSize x < image width) or:[(newSize y < image height)]) ifTrue:[ |
8356 imageEditView magnifySmoothingTo:newSize. |
8359 imageEditView magnifySmoothingTo:newSize. |
8357 ] ifFalse:[ |
8360 ] ifFalse:[ |
8358 imageEditView magnifyAntiAliasedImageTo:newSize. |
8361 imageEditView magnifyAntiAliasedImageTo:newSize. |
8368 ! |
8371 ! |
8369 |
8372 |
8370 doMagnifyImageBy |
8373 doMagnifyImageBy |
8371 "magnifies the current image (by a scale)" |
8374 "magnifies the current image (by a scale)" |
8372 |
8375 |
8373 |oldSize newSize scaleString scale image antiAliased smoothing| |
8376 |oldSize newSize scaleString scale image smoothing| |
8374 |
8377 |
8375 image := imageEditView image. |
8378 image := imageEditView image. |
8376 oldSize := image extent. |
8379 oldSize := image extent. |
8377 |
8380 |
8378 antiAliased := false asValue. |
8381 smoothing := (LastMagnifySmoothing ? false) asValue. |
8379 smoothing := false asValue. |
|
8380 |
8382 |
8381 Dialog modifyingBoxWith:[:box | |
8383 Dialog modifyingBoxWith:[:box | |
8382 box verticalPanel add:(CheckBox label:(resources string:'Antialias/Smooth') model:antiAliased). |
8384 box verticalPanel add:(CheckBox label:(resources string:'Antialias/Smooth') model:smoothing). |
8383 "/ box verticalPanel add:(CheckBox label:(resources string:'Smoothing') model:smoothing). |
8385 "/ box verticalPanel add:(CheckBox label:(resources string:'Smoothing') model:smoothing). |
8384 ] do:[ |
8386 ] do:[ |
8385 scaleString := Dialog |
8387 scaleString := Dialog |
8386 request:(resources string:'Scale factor (<1 to shrink; >1 to magnify):') |
8388 request:(resources string:'Scale factor (<1 to shrink; >1 to magnify):') |
8387 initialAnswer:'1' |
8389 initialAnswer:(LastMagnifyBy ? 1) printString |
8388 list:#('0.1' '0.25' '0.3' '0.5' '1.5' '2' '3' '4'). |
8390 list:#('0.1' '0.25' '0.3' '0.5' '1.5' '2' '3' '4'). |
8389 ]. |
8391 ]. |
8390 scaleString isNil ifTrue:[^ self]. |
8392 scaleString isNil ifTrue:[^ self]. |
8391 |
8393 |
8392 scale := Object readFromString:scaleString onError:nil. |
8394 scale := Object readFromString:scaleString onError:nil. |
8394 scale notNil ifTrue:[ |
8396 scale notNil ifTrue:[ |
8395 scale isNumber ifFalse:[ |
8397 scale isNumber ifFalse:[ |
8396 self warn:'please enter a scale factor (<1 to shrink; >1 to magnify).'. |
8398 self warn:'please enter a scale factor (<1 to shrink; >1 to magnify).'. |
8397 ^ self. |
8399 ^ self. |
8398 ]. |
8400 ]. |
|
8401 |
|
8402 LastMagnifyBy := scale. |
|
8403 LastMagnifySmoothing := smoothing value. |
|
8404 |
8399 newSize := oldSize * scale. |
8405 newSize := oldSize * scale. |
8400 antiAliased value ifTrue:[ |
8406 smoothing value ifTrue:[ |
8401 scale < 1 ifTrue:[ |
8407 scale < 1 ifTrue:[ |
8402 imageEditView magnifySmoothingBy:scale. |
8408 imageEditView magnifySmoothingBy:scale. |
8403 ] ifFalse:[ |
8409 ] ifFalse:[ |
8404 imageEditView magnifyAntiAliasedImageTo:newSize. |
8410 imageEditView magnifyAntiAliasedImageTo:newSize. |
8405 ]. |
8411 ]. |