4116 ]. |
4116 ]. |
4117 ]. |
4117 ]. |
4118 |
4118 |
4119 imageEditView makeUndo. |
4119 imageEditView makeUndo. |
4120 |
4120 |
4121 newImage := Image newForDepth:depth. |
4121 newImage := Image newForDepth:depth. |
4122 newImage depth:depth. |
4122 newImage depth:depth. |
|
4123 newImage photometric:oldImage photometric. |
|
4124 |
4123 oldFileName := oldImage fileName. |
4125 oldFileName := oldImage fileName. |
4124 |
4126 |
4125 Image imageErrorSignal handle:[:ex| |
4127 Image imageErrorSignal handle:[:ex| |
4126 Color colorErrorSignal handle:[:ex| |
4128 Color colorErrorSignal handle:[:ex| |
4127 colorMapMode value:prevMode. |
4129 colorMapMode value:prevMode. |
4131 newImage := Image newForDepth:depth. |
4133 newImage := Image newForDepth:depth. |
4132 newImage width:oldImage width height:oldImage height depth:depth. |
4134 newImage width:oldImage width height:oldImage height depth:depth. |
4133 newImage colorMap:newColorMap. |
4135 newImage colorMap:newColorMap. |
4134 newImage photometric:#palette. |
4136 newImage photometric:#palette. |
4135 newImage bits:(ByteArray new:(newImage bytesPerRow * newImage height)). |
4137 newImage bits:(ByteArray new:(newImage bytesPerRow * newImage height)). |
4136 |
4138 |
4137 oldImage colorsFromX:0 y:0 toX:(oldImage width-1) y:(oldImage height-1) do: |
4139 oldImage colorsFromX:0 y:0 toX:(oldImage width-1) y:(oldImage height-1) do: |
4138 [:x :y :clr | |
4140 [:x :y :clr | |
4139 |newColor| |
4141 |newColor| |
4140 |
4142 |
4141 (newColorMap includes:clr) |
4143 (newColorMap includes:clr) |
4151 newImage colorAtX:x y:y put:newColor. |
4153 newImage colorAtX:x y:y put:newColor. |
4152 ]. |
4154 ]. |
4153 image := newImage |
4155 image := newImage |
4154 ]. |
4156 ]. |
4155 ] do:[ |
4157 ] do:[ |
4156 image := newImage fromImage:oldImage |
4158 image := newImage fromImage:oldImage. |
4157 ]. |
4159 ]. |
4158 |
4160 |
4159 (aMode asString startsWith:'mask') ifTrue:[ |
4161 (aMode asString startsWith:'mask') ifTrue:[ |
4160 image mask isNil ifTrue:[ |
4162 image mask isNil ifTrue:[ |
4161 false "(Dialog confirm:'Generate mask from black ?' default:false)" ifTrue:[ |
4163 false "(Dialog confirm:'Generate mask from black ?' default:false)" ifTrue:[ |
4702 image := self image. |
4704 image := self image. |
4703 "/ usedColors := image usedColorsMax:4096. |
4705 "/ usedColors := image usedColorsMax:4096. |
4704 imageEditView makeUndo. |
4706 imageEditView makeUndo. |
4705 |
4707 |
4706 newImage := image copy. |
4708 newImage := image copy. |
|
4709 newImage photometric == #palette ifTrue:[ |
|
4710 newImage colorMap:(OrderedCollection new). |
|
4711 ]. |
|
4712 |
4707 image |
4713 image |
4708 colorsFromX:0 y:0 toX:(image width-1) y:(image height-1) |
4714 colorsFromX:0 y:0 toX:(image width-1) y:(image height-1) |
4709 do:[:x :y :clr | |
4715 do:[:x :y :clr | |
4710 |r g b nr ng nb newClr| |
4716 |r g b nr ng nb newClr| |
4711 |
4717 |
4715 nr := (r roundTo:rndR) min:255. |
4721 nr := (r roundTo:rndR) min:255. |
4716 ng := (g roundTo:rndG) min:255. |
4722 ng := (g roundTo:rndG) min:255. |
4717 nb := (b roundTo:rndB) min:255. |
4723 nb := (b roundTo:rndB) min:255. |
4718 |
4724 |
4719 newClr := Color redByte:nr greenByte:ng blueByte:nb. |
4725 newClr := Color redByte:nr greenByte:ng blueByte:nb. |
|
4726 newImage photometric == #palette ifTrue:[ |
|
4727 (newImage colorMap includes:newClr) ifFalse:[ |
|
4728 newImage colorMap add:newClr |
|
4729 ]. |
|
4730 ]. |
4720 newImage colorAtX:x y:y put:newClr |
4731 newImage colorAtX:x y:y put:newClr |
4721 ]. |
4732 ]. |
4722 |
4733 |
4723 imageEditView image:newImage. |
4734 imageEditView image:newImage. |
4724 imageEditView setModified. |
4735 imageEditView setModified. |
5090 ! |
5101 ! |
5091 |
5102 |
5092 doMagnifyImageBy |
5103 doMagnifyImageBy |
5093 "magnifies the current image (by a scale)" |
5104 "magnifies the current image (by a scale)" |
5094 |
5105 |
5095 |box oldSize newSize scale image| |
5106 |box oldSize newSize scaleString scale image| |
5096 |
5107 |
5097 image := imageEditView image. |
5108 image := imageEditView image. |
5098 oldSize := image extent. |
5109 oldSize := image extent. |
5099 |
5110 |
5100 box := EnterBox new. |
5111 scaleString := Dialog |
5101 box title:(resources string:'Scale factor (<1 to shrink; >1 to magnify):'). |
5112 request:(resources string:'Scale factor (<1 to shrink; >1 to magnify):') |
5102 box okText:(resources string:'OK'). |
5113 initialAnswer:'1' |
5103 box abortText:(resources string:'Cancel'). |
5114 list:#('0.25' '0.5' '2' '4'). |
5104 box initialText:1 printString. |
5115 |
5105 box showAtPointer. |
5116 "/ box := EnterBox new. |
5106 |
5117 "/ box title:(resources string:'Scale factor (<1 to shrink; >1 to magnify):'). |
5107 (box accepted |
5118 "/ box okText:(resources string:'OK'). |
5108 and: [(scale := Object readFromString:(box contents) onError:nil) notNil]) |
5119 "/ box abortText:(resources string:'Cancel'). |
5109 ifTrue:[ |
5120 "/ box initialText:1 printString. |
|
5121 "/ box showAtPointer. |
|
5122 "/ box accepted ifTrue:[ |
|
5123 "/ scaleString := box contents. |
|
5124 "/ ]. |
|
5125 |
|
5126 scale := Object readFromString:scaleString onError:nil. |
|
5127 |
|
5128 scale notNil ifTrue:[ |
5110 scale isNumber ifFalse:[ |
5129 scale isNumber ifFalse:[ |
5111 self warn:'please enter a scale factor (<1 to shrink; >1 to magnify).'. |
5130 self warn:'please enter a scale factor (<1 to shrink; >1 to magnify).'. |
5112 ^ self. |
5131 ^ self. |
5113 ]. |
5132 ]. |
5114 newSize := oldSize * scale. |
5133 newSize := oldSize * scale. |