author | Claus Gittinger <cg@exept.de> |
Tue, 01 Oct 2019 20:18:22 +0200 | |
changeset 6160 | b8552438cfbe |
parent 6150 | d78950c03598 |
child 6161 | 3353ad05fdb3 |
permissions | -rw-r--r-- |
636 | 1 |
" |
704 | 2 |
COPYRIGHT (c) 1997 by eXept Software AG |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
3 |
All Rights Reserved |
636 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
1763
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
12 |
"{ Package: 'stx:libwidg2' }" |
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
13 |
|
4714 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
1 | 16 |
ImageView subclass:#ImageEditView |
4041 | 17 |
instanceVariableNames:'readOnly magnification imageReaderClass resourceClass |
5499 | 18 |
resourceSelector mouseKeyColorMode undoImages originalImage |
19 |
modifiedHolder editMode lastPastePoint imageInfoHolder |
|
20 |
activityInfoHolder pickedColorHolder drawingColors drawingPixels |
|
21 |
drawingColorHolders drawingPixelHolders clickInfoCallBack |
|
22 |
penWidth sprayProcess sprayPosition spraySpot drawingAlpha |
|
23 |
floodFillMaxHueError floodFillMaxLightError |
|
24 |
userAllowedToChangeDrawingColor' |
|
5618 | 25 |
classVariableNames:'Clipboard ClipboardMagnified ClipboardImage |
26 |
ClipboardImageMagnified LastMagnification GridMagnificationLimit |
|
27 |
MaxUndos LastSaveDirectory LastSaveClass EditModePoint |
|
28 |
EditModeBox EditModeFilledBox EditModeFill EditModeCopy |
|
29 |
EditModePasteUnder EditModePaste EditModePasteWithMask |
|
30 |
EditModeSpecialOperation EditModeSpray EditModeCircle |
|
31 |
EditModeSmooth EditModeFilledCircle |
|
5491 | 32 |
EditModeSpecialOperationCropSubImage EditModeMaskOutsideRect |
6150 | 33 |
EditModeMaskOutsideCircle EditModePasteMasked EditModePointBlend' |
1035 | 34 |
poolDictionaries:'' |
1706 | 35 |
category:'Views-Misc' |
1 | 36 |
! |
37 |
||
636 | 38 |
!ImageEditView class methodsFor:'documentation'! |
39 |
||
40 |
copyright |
|
41 |
" |
|
704 | 42 |
COPYRIGHT (c) 1997 by eXept Software AG |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
43 |
All Rights Reserved |
636 | 44 |
|
45 |
This software is furnished under a license and may be used |
|
46 |
only in accordance with the terms of that license and with the |
|
47 |
inclusion of the above copyright notice. This software may not |
|
48 |
be provided or otherwise made available to, or used by, any |
|
49 |
other person. No title to or ownership of the software is |
|
50 |
hereby transferred. |
|
51 |
" |
|
52 |
! |
|
53 |
||
54 |
documentation |
|
55 |
" |
|
2747 | 56 |
An ImageEditView is a view which can be used by applications |
57 |
like the Image Editor for editing or inspecting (bitmap-) images. |
|
636 | 58 |
|
59 |
[see also:] |
|
2747 | 60 |
ImageEditor Image |
636 | 61 |
|
62 |
[author:] |
|
2747 | 63 |
Thomas Zwick |
636 | 64 |
" |
65 |
! ! |
|
353 | 66 |
|
1245 | 67 |
!ImageEditView class methodsFor:'initialization'! |
68 |
||
69 |
initialize |
|
2915 | 70 |
MaxUndos := 10. |
5413 | 71 |
GridMagnificationLimit := 6 @ 6. |
1245 | 72 |
|
2889 | 73 |
EditModePoint := #point. |
6150 | 74 |
EditModePointBlend := #pointBlend. |
2889 | 75 |
EditModeBox := #box. |
3476 | 76 |
EditModeCircle := #circle. |
2889 | 77 |
EditModePaste := #paste. |
78 |
EditModePasteUnder := #pasteUnder. |
|
79 |
EditModePasteWithMask := #pasteWithMask. |
|
5772 | 80 |
EditModePasteMasked := #pasteMasked. |
2889 | 81 |
EditModeFilledBox := #filledBox. |
5491 | 82 |
EditModeFilledCircle := #filledCircle. |
2889 | 83 |
EditModeFill := #fill. |
84 |
EditModeCopy := #copy. |
|
3476 | 85 |
EditModeSpray := #spray. |
4715 | 86 |
EditModeSmooth := #smooth. |
5491 | 87 |
EditModeMaskOutsideRect := #maskOutsideRect. |
88 |
EditModeMaskOutsideCircle := #maskOutsideCircle. |
|
89 |
EditModeSpecialOperation := #specialOperation. |
|
90 |
EditModeSpecialOperationCropSubImage := #specialOperationCropSubImage. |
|
2889 | 91 |
|
1245 | 92 |
" |
93 |
self initialize |
|
94 |
" |
|
5491 | 95 |
|
96 |
"Modified: / 20-02-2017 / 16:54:11 / cg" |
|
5772 | 97 |
"Modified: / 27-05-2018 / 10:42:00 / Claus Gittinger" |
1245 | 98 |
! ! |
99 |
||
1706 | 100 |
!ImageEditView class methodsFor:'accessing'! |
101 |
||
2889 | 102 |
editModeBox |
103 |
^ EditModeBox |
|
104 |
! |
|
105 |
||
106 |
editModeCopy |
|
107 |
^ EditModeCopy |
|
108 |
! |
|
109 |
||
110 |
editModeFill |
|
111 |
^ EditModeFill |
|
112 |
! |
|
113 |
||
114 |
editModeFilledBox |
|
115 |
^ EditModeFilledBox |
|
116 |
! |
|
117 |
||
118 |
editModePaste |
|
119 |
^ EditModePaste |
|
120 |
! |
|
121 |
||
5772 | 122 |
editModePasteMasked |
123 |
^ EditModePasteMasked |
|
124 |
||
125 |
"Created: / 27-05-2018 / 10:43:22 / Claus Gittinger" |
|
126 |
! |
|
127 |
||
2889 | 128 |
editModePasteUnder |
129 |
^ EditModePasteUnder |
|
130 |
! |
|
131 |
||
132 |
editModePasteWithMask |
|
133 |
^ EditModePasteWithMask |
|
134 |
! |
|
135 |
||
136 |
editModePoint |
|
137 |
^ EditModePoint |
|
138 |
! |
|
139 |
||
4715 | 140 |
editModeSmooth |
141 |
^ EditModeSmooth |
|
142 |
! |
|
143 |
||
2889 | 144 |
editModeSpecialOperation |
145 |
^ EditModeSpecialOperation |
|
146 |
! |
|
147 |
||
1706 | 148 |
gridMagnificationLimit |
149 |
^ GridMagnificationLimit |
|
150 |
! |
|
151 |
||
152 |
gridMagnificationLimit:anInteger |
|
153 |
GridMagnificationLimit := anInteger |
|
3980 | 154 |
! |
155 |
||
156 |
lastSaveDirectory |
|
157 |
^ LastSaveDirectory |
|
158 |
||
159 |
"Created: / 14-12-2010 / 14:49:01 / cg" |
|
160 |
! |
|
161 |
||
162 |
lastSaveDirectory:aStringOrFilename |
|
163 |
LastSaveDirectory := aStringOrFilename |
|
164 |
||
165 |
"Created: / 14-12-2010 / 14:49:18 / cg" |
|
1706 | 166 |
! ! |
167 |
||
2480 | 168 |
!ImageEditView class methodsFor:'helpers'! |
169 |
||
170 |
copyImageToClipboard:copiedImage |
|
5618 | 171 |
ClipboardImageMagnified := nil. |
172 |
ClipboardImage := copiedImage. |
|
173 |
||
174 |
"Modified: / 08-10-2017 / 08:55:10 / cg" |
|
2480 | 175 |
! ! |
176 |
||
2634 | 177 |
!ImageEditView class methodsFor:'resources'! |
178 |
||
179 |
classResources |
|
180 |
^ ImageEditor classResources |
|
181 |
! ! |
|
182 |
||
7 | 183 |
!ImageEditView methodsFor:'accessing'! |
184 |
||
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
185 |
activityInfoHolder |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
186 |
"return the value of the instance variable 'activityInfoHolder' (automatically generated)" |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
187 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
188 |
^ activityInfoHolder |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
189 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
190 |
"Created: / 29.7.1998 / 18:49:39 / cg" |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
191 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
192 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
193 |
activityInfoHolder:something |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
194 |
"set the value of the instance variable 'activityInfoHolder' (automatically generated)" |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
195 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
196 |
activityInfoHolder := something. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
197 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
198 |
"Created: / 29.7.1998 / 18:49:39 / cg" |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
199 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
200 |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
201 |
clearModified |
2915 | 202 |
self modified:false |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
203 |
! |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
204 |
|
1693 | 205 |
clickInfoCallBack:aTwoArgBlock |
206 |
clickInfoCallBack := aTwoArgBlock |
|
207 |
||
208 |
"Created: / 10.2.2000 / 23:07:14 / cg" |
|
209 |
! |
|
210 |
||
2440 | 211 |
clipBoard |
5413 | 212 |
|clipboardObject| |
213 |
||
214 |
clipboardObject := self getClipboardObject. |
|
215 |
clipboardObject isImage ifTrue:[ |
|
216 |
^ clipboardObject |
|
217 |
]. |
|
5618 | 218 |
^ ClipboardImage. |
219 |
||
220 |
"Modified: / 08-10-2017 / 08:52:27 / cg" |
|
221 |
! |
|
222 |
||
223 |
clipBoardImage |
|
5772 | 224 |
"if there is an image in the clobal clipboard, |
225 |
return that (and thus support copy-paste from another smalltalk application). |
|
5618 | 226 |
Otherwise return the local clipboardImage from a classVar to support copy-paste |
227 |
within this smalltalk session." |
|
228 |
||
229 |
|clipboardObject| |
|
230 |
||
231 |
clipboardObject := self getClipboardObject. |
|
232 |
clipboardObject isImage ifTrue:[ |
|
233 |
^ clipboardObject |
|
234 |
]. |
|
235 |
^ ClipboardImage. |
|
236 |
||
237 |
"Created: / 08-10-2017 / 08:55:59 / cg" |
|
5772 | 238 |
"Modified (comment): / 27-05-2018 / 11:12:58 / Claus Gittinger" |
2440 | 239 |
! |
240 |
||
5593 | 241 |
drawingAlpha |
242 |
"return the alpha value for drawing; |
|
243 |
if the current drawing color is nil, ONLY the alpha value will be changed" |
|
244 |
||
245 |
^ drawingAlpha ? 100 |
|
246 |
||
247 |
"Created: / 05-09-2017 / 09:11:32 / cg" |
|
5594 | 248 |
"Modified: / 05-09-2017 / 10:47:18 / cg" |
5593 | 249 |
! |
250 |
||
251 |
drawingAlpha:anAlphaValue |
|
252 |
"set the alpha value for drawing; |
|
253 |
if the current drawing color is nil, ONLY the alpha value will be changed" |
|
254 |
||
255 |
drawingAlpha := anAlphaValue |
|
256 |
||
257 |
"Created: / 05-09-2017 / 09:11:26 / cg" |
|
258 |
! |
|
259 |
||
3610
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
260 |
drawingColorHolders |
5499 | 261 |
drawingColorHolders isNil ifTrue:[ |
262 |
drawingColorHolders := Array with:(nil asValue) with:(nil asValue). "/ left/right mouse colors |
|
263 |
]. |
|
3610
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
264 |
^ drawingColorHolders |
5499 | 265 |
|
266 |
"Modified: / 23-02-2017 / 10:14:49 / cg" |
|
3610
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
267 |
! |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
268 |
|
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
269 |
drawingColors |
5593 | 270 |
"return the two colors in which I will draw (left / right mouse button colors)" |
271 |
||
3610
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
272 |
^ drawingColorHolders collect:[:each | each value]. |
5499 | 273 |
|
274 |
"Modified: / 23-02-2017 / 10:17:14 / cg" |
|
5593 | 275 |
"Modified (comment): / 05-09-2017 / 09:12:14 / cg" |
3610
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
276 |
! |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
277 |
|
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
278 |
drawingColors:anArrayTwoColors |
5593 | 279 |
"set the two colors in which I will draw (left / right mouse button colors)" |
280 |
||
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
281 |
(drawingColorHolders at:1) value:(anArrayTwoColors at:1). |
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
282 |
(drawingColorHolders at:2) value:(anArrayTwoColors at:2). |
5499 | 283 |
|
284 |
"Modified: / 23-02-2017 / 10:17:21 / cg" |
|
5593 | 285 |
"Modified (comment): / 05-09-2017 / 09:12:07 / cg" |
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
286 |
! |
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
287 |
|
5485 | 288 |
editMode |
289 |
"is one of the edit modes: |
|
290 |
||
291 |
EditModePoint |
|
292 |
EditModeBox |
|
293 |
EditModePaste |
|
294 |
EditModePasteUnder |
|
5772 | 295 |
EditModePasteMasked |
5485 | 296 |
EditModePasteWithMask |
297 |
EditModeFilledBox |
|
298 |
EditModeFill |
|
299 |
EditModeCopy |
|
300 |
EditModeSpecialOperation |
|
301 |
EditModeSpray |
|
302 |
EditModeCircle |
|
6150 | 303 |
EditModeSmooth |
304 |
EditModePointBlend |
|
5485 | 305 |
" |
306 |
||
307 |
^editMode |
|
5772 | 308 |
|
309 |
"Modified (comment): / 27-05-2018 / 10:41:44 / Claus Gittinger" |
|
5485 | 310 |
! |
311 |
||
312 |
editMode: anEditModeSymbol |
|
313 |
"must be one of the edit modes: |
|
314 |
||
315 |
EditModePoint |
|
316 |
EditModeBox |
|
317 |
EditModePaste |
|
318 |
EditModePasteUnder |
|
319 |
EditModePasteWithMask |
|
5772 | 320 |
EditModePasteMasked |
5485 | 321 |
EditModeFilledBox |
322 |
EditModeFill |
|
323 |
EditModeCopy |
|
324 |
EditModeSpecialOperation |
|
325 |
EditModeSpray |
|
326 |
EditModeCircle |
|
327 |
EditModeSmooth |
|
6150 | 328 |
EditModePointBlend |
5485 | 329 |
" |
330 |
||
331 |
editMode := anEditModeSymbol |
|
5772 | 332 |
|
333 |
"Modified (comment): / 27-05-2018 / 10:42:21 / Claus Gittinger" |
|
5485 | 334 |
! |
335 |
||
5483 | 336 |
floodFillMaxHueError:aFraction |
337 |
floodFillMaxHueError := aFraction. |
|
338 |
||
339 |
"Modified (format): / 17-02-2017 / 15:26:59 / cg" |
|
340 |
! |
|
341 |
||
342 |
floodFillMaxLightError:aFraction |
|
343 |
floodFillMaxLightError := aFraction. |
|
344 |
||
345 |
"Modified (format): / 17-02-2017 / 15:27:03 / cg" |
|
346 |
! |
|
347 |
||
2915 | 348 |
image:anImage scroll:doScroll |
3706 | 349 |
self image:anImage scroll:doScroll invalidate:true |
350 |
! |
|
351 |
||
352 |
image:anImage scroll:doScroll invalidate:doInvalidate |
|
2915 | 353 |
|retVal fileName| |
354 |
||
355 |
anImage isImage ifTrue:[ |
|
356 |
true "(image isNil or: [self checkModified])" ifTrue: [ |
|
357 |
image notNil ifTrue: [ |
|
358 |
fileName := image fileName. |
|
359 |
anImage fileName isNil ifTrue: [anImage fileName: fileName]. |
|
360 |
]. |
|
3706 | 361 |
super image:anImage scroll:doScroll invalidate:doInvalidate. |
2915 | 362 |
retVal := self. |
363 |
]. |
|
364 |
] ifFalse: [ |
|
3706 | 365 |
super image:nil scroll:true invalidate:doInvalidate. |
2915 | 366 |
]. |
3706 | 367 |
|
2915 | 368 |
"/ self changed:#image. |
369 |
image isNil ifTrue:[ |
|
370 |
self clearModified. |
|
371 |
] ifFalse:[ |
|
372 |
self setModified. |
|
373 |
]. |
|
374 |
self updateImageInfo: self imageInfoString. |
|
375 |
^ retVal |
|
376 |
||
377 |
"Modified: / 10.2.2000 / 23:33:12 / cg" |
|
378 |
! |
|
379 |
||
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
380 |
imageInfoHolder |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
381 |
^ imageInfoHolder |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
382 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
383 |
"Created: / 29.7.1998 / 18:29:50 / cg" |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
384 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
385 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
386 |
imageInfoHolder:something |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
387 |
imageInfoHolder := something. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
388 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
389 |
"Created: / 29.7.1998 / 18:29:50 / cg" |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
390 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
391 |
|
624 | 392 |
magnification |
393 |
||
394 |
^magnification |
|
395 |
||
255 | 396 |
! |
397 |
||
636 | 398 |
magnification: aPoint |
1037 | 399 |
|oldOrg| |
255 | 400 |
|
627 | 401 |
magnification ~= aPoint |
624 | 402 |
ifTrue: |
403 |
[ |
|
5618 | 404 |
oldOrg := self viewOrigin / magnification. |
405 |
magnification := aPoint asPoint. |
|
406 |
||
407 |
self scrollTo:(oldOrg * magnification) rounded redraw:false. |
|
1037 | 408 |
"/ self scrollToTopLeft. |
5618 | 409 |
self contentsChanged. |
410 |
self invalidate. |
|
411 |
ClipboardImageMagnified := nil. |
|
686 | 412 |
] |
1037 | 413 |
|
5618 | 414 |
"Modified: / 08-10-2017 / 08:54:54 / cg" |
624 | 415 |
! |
255 | 416 |
|
2913 | 417 |
modified |
418 |
^ modifiedHolder value |
|
419 |
! |
|
420 |
||
2747 | 421 |
modified:aBoolean |
422 |
modifiedHolder value:aBoolean |
|
423 |
! |
|
424 |
||
425 |
modifiedHolder |
|
426 |
^ modifiedHolder |
|
427 |
! |
|
428 |
||
5485 | 429 |
mouseKeyColorMode |
430 |
||
431 |
^mouseKeyColorMode printString |
|
432 |
! |
|
433 |
||
434 |
mouseKeyColorMode:aMode |
|
435 |
||
436 |
mouseKeyColorMode := aMode |
|
437 |
! |
|
438 |
||
3265 | 439 |
penWidth |
440 |
^ penWidth ? 1 |
|
441 |
||
442 |
"Created: / 01-11-2007 / 23:34:49 / cg" |
|
443 |
! |
|
444 |
||
5405 | 445 |
penWidth:anInteger |
446 |
penWidth := anInteger |
|
3265 | 447 |
|
448 |
"Created: / 01-11-2007 / 23:34:56 / cg" |
|
449 |
! |
|
450 |
||
4041 | 451 |
readOnly |
452 |
^ readOnly |
|
453 |
! |
|
454 |
||
5405 | 455 |
readOnly:aBoolean |
456 |
readOnly := aBoolean. |
|
4041 | 457 |
! |
458 |
||
2915 | 459 |
removelastUndo |
460 |
undoImages removeLast |
|
461 |
! |
|
462 |
||
627 | 463 |
resourceClass |
2915 | 464 |
^ resourceClass |
627 | 465 |
! |
466 |
||
2915 | 467 |
resourceClass: aClassOrClassNameString |
468 |
"support for names will vanish - obsolete left over from tz" |
|
469 |
||
470 |
resourceClass := aClassOrClassNameString. |
|
471 |
resourceClass notNil ifTrue:[ |
|
472 |
resourceClass isBehavior ifFalse: [ |
|
473 |
resourceClass := Smalltalk classNamed:aClassOrClassNameString |
|
474 |
] |
|
475 |
] |
|
2908
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
476 |
! |
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
477 |
|
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
478 |
resourceClassName |
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
479 |
resourceClass isNil ifTrue:[^ '']. |
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
480 |
^ resourceClass name |
627 | 481 |
! |
482 |
||
483 |
resourceMessage |
|
2909 | 484 |
(resourceClass isNil or:[resourceSelector isNil]) ifTrue:[^ '']. |
2908
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
485 |
^ resourceClass name, ' ', resourceSelector |
627 | 486 |
! |
487 |
||
488 |
resourceSelector |
|
2915 | 489 |
^ resourceSelector |
627 | 490 |
! |
491 |
||
492 |
resourceSelector: aStringOrSymbol |
|
2909 | 493 |
aStringOrSymbol isNil ifTrue:[ |
494 |
resourceSelector := nil |
|
495 |
] ifFalse:[ |
|
496 |
resourceSelector := aStringOrSymbol asSymbol |
|
497 |
] |
|
627 | 498 |
! |
499 |
||
5480 | 500 |
selectMaskForDrawing |
5483 | 501 |
image mask isNil ifTrue:[ |
502 |
Logger warning:'image has no mask'. |
|
503 |
^ self. |
|
504 |
]. |
|
5484 | 505 |
"/ self selectedColorIndex:1. |
506 |
self selectedColor:(Color noColor). |
|
507 |
self selectedColorIndex:nil. |
|
5480 | 508 |
|
509 |
"Created: / 16-02-2017 / 09:57:40 / cg" |
|
5484 | 510 |
"Modified: / 17-02-2017 / 16:30:50 / cg" |
5480 | 511 |
! |
512 |
||
627 | 513 |
selectedColor |
3730 | 514 |
|clr| |
515 |
||
516 |
clr := (drawingColorHolders at:mouseKeyColorMode) value. |
|
3931 | 517 |
clr isNil ifTrue:[ clr := Color black ]. |
5593 | 518 |
|
3730 | 519 |
image hasAlphaChannel ifTrue:[ |
5594 | 520 |
clr isPseudoColor ifTrue:[ |
521 |
"/ the mask is selected - return a pseudoColor holding ONLY the alpha value |
|
522 |
"/ will be detected in the drawing operations to change the alpha value only |
|
523 |
^ TranslucentColor new |
|
524 |
alpha:((drawingAlpha ? 100) / 100) |
|
525 |
]. |
|
526 |
||
3730 | 527 |
^ (TranslucentColor |
528 |
scaledRed:clr scaledRed |
|
529 |
scaledGreen:clr scaledGreen |
|
530 |
scaledBlue:clr scaledBlue) |
|
5594 | 531 |
alpha:((drawingAlpha ? 100) / 100) |
3730 | 532 |
]. |
533 |
^ clr |
|
3931 | 534 |
|
5594 | 535 |
"Modified (format): / 05-09-2017 / 12:21:53 / cg" |
1246 | 536 |
! |
537 |
||
538 |
selectedColor: aColor |
|
4853 | 539 |
(drawingColorHolders at:(mouseKeyColorMode min:drawingColorHolders size)) value:aColor |
5499 | 540 |
|
541 |
"Modified: / 23-02-2017 / 10:17:02 / cg" |
|
627 | 542 |
! |
543 |
||
1246 | 544 |
selectedColorIndex |
2915 | 545 |
^ (drawingPixelHolders at:mouseKeyColorMode) value |
1246 | 546 |
! |
547 |
||
548 |
selectedColorIndex: aPixelIndex |
|
4853 | 549 |
(drawingPixelHolders at:(mouseKeyColorMode min:drawingPixelHolders size)) value: aPixelIndex |
995 | 550 |
! |
551 |
||
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
552 |
setModified |
5497 | 553 |
"remember being modified (to ask about saving, when closing)" |
554 |
||
2915 | 555 |
self modified:true |
5497 | 556 |
|
557 |
"Modified (comment): / 22-02-2017 / 22:24:34 / cg" |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
558 |
! |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
559 |
|
4111 | 560 |
spraySpot |
561 |
^ spraySpot |
|
562 |
||
563 |
"Created: / 15-02-2012 / 22:38:04 / cg" |
|
564 |
! |
|
565 |
||
3476 | 566 |
spraySpot:something |
567 |
spraySpot := something. |
|
568 |
! |
|
569 |
||
995 | 570 |
undoImages |
2915 | 571 |
^ undoImages |
5484 | 572 |
! |
573 |
||
574 |
userAllowedToChangeDrawingColor:aBoolean |
|
575 |
"for special applications, whre user is only allowed to draw |
|
576 |
in the predefined color (eg. expecco)" |
|
577 |
||
578 |
userAllowedToChangeDrawingColor := aBoolean |
|
579 |
||
580 |
"Created: / 17-02-2017 / 16:24:37 / cg" |
|
627 | 581 |
! ! |
582 |
||
583 |
!ImageEditView methodsFor:'drawing'! |
|
584 |
||
1036 | 585 |
drawFrame |
5413 | 586 |
"draws a black frame around the image's bounds" |
587 |
||
5432 | 588 |
gc paint:self blackColor. |
589 |
gc lineWidth: (magnification x//3 min: 3). |
|
590 |
gc displayRectangle: ((0@0) extent:(image extent * magnification) + margin). |
|
591 |
gc lineWidth:1. |
|
1036 | 592 |
! |
593 |
||
594 |
drawFramesIn: aRectangle |
|
5413 | 595 |
"draws the pixel frame grid" |
596 |
||
597 |
|origin lineStartingPoint lineEndingPoint oldColor mX mY| |
|
598 |
||
599 |
magnification >= GridMagnificationLimit ifTrue: [ |
|
600 |
mX := magnification x. |
|
601 |
mY := magnification y. |
|
602 |
||
1706 | 603 |
origin := aRectangle origin - 1. |
5413 | 604 |
lineStartingPoint := origin + (0 @ mY). |
1706 | 605 |
lineEndingPoint := lineStartingPoint + (aRectangle width@0). |
5413 | 606 |
|
5432 | 607 |
oldColor := gc paint. |
5584 | 608 |
gc paint:Color gray. |
609 |
"/ gc xoring:[ |
|
5432 | 610 |
gc displayLineFrom: lineStartingPoint to: lineEndingPoint. |
5413 | 611 |
lineStartingPoint x to: lineStartingPoint x + aRectangle width - mX by: mX |
612 |
do:[:x| |
|
5432 | 613 |
gc displayLineFrom: x@(origin y) to: x@(origin y + mY) |
1706 | 614 |
]. |
5584 | 615 |
"/ ]. |
5432 | 616 |
gc paint: oldColor. |
1036 | 617 |
] |
5584 | 618 |
|
619 |
"Modified: / 29-08-2017 / 21:58:07 / cg" |
|
1036 | 620 |
! |
621 |
||
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
622 |
drawPasteRectangleAt: aPoint |
2889 | 623 |
|currentPoint gridCorrection extent| |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
624 |
|
1706 | 625 |
magnification >= GridMagnificationLimit ifFalse: [gridCorrection := 0] ifTrue: [gridCorrection := 1]. |
1449 | 626 |
currentPoint := aPoint // magnification*magnification + margin. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
627 |
|
2085 | 628 |
self repairDamage. |
629 |
||
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
630 |
currentPoint ~= lastPastePoint ifTrue:[ |
5618 | 631 |
ClipboardImageMagnified isNil ifTrue:[ |
632 |
ClipboardImageMagnified := (ClipboardImage magnifiedBy: magnification) onDevice:device |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
633 |
]. |
5618 | 634 |
extent := ClipboardImageMagnified extent. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
635 |
|
1967 | 636 |
"/ currentPoint := currentPoint - self viewOrigin. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
637 |
|
2085 | 638 |
self redraw: (((lastPastePoint ? currentPoint)"-self viewOrigin") extent: extent). |
3267 | 639 |
"/ self repairDamage. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
640 |
|
2085 | 641 |
false " (extent x > 400 or: [extent y > 400])" ifTrue:[ |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
642 |
self xoring: [ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
643 |
self fillRectangle: (currentPoint extent: extent) |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
644 |
] |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
645 |
] ifFalse:[ |
5618 | 646 |
ClipboardImageMagnified notNil ifTrue:[ |
647 |
self displayDeviceForm: ClipboardImageMagnified |
|
2089 | 648 |
x: currentPoint x - self viewOrigin x |
649 |
y: currentPoint y - self viewOrigin y. |
|
650 |
]. |
|
2889 | 651 |
editMode == EditModePastUnder ifTrue:[ |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
652 |
self redrawImageX:currentPoint x y:currentPoint y width:extent x height:extent y unmaskedOnly:true |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
653 |
] |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
654 |
] |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
655 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
656 |
lastPastePoint := currentPoint. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
657 |
|
5618 | 658 |
"Modified: / 08-10-2017 / 08:54:49 / cg" |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
659 |
! |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
660 |
|
662 | 661 |
fillFramedRectangle: aRectangle |
662 |
||
663 |
self fillRectangle: aRectangle. |
|
664 |
self drawFramesIn: aRectangle |
|
665 |
! |
|
666 |
||
1449 | 667 |
redraw:aRectangle |
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
668 |
self |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
669 |
invalidate:(aRectangle origin "+ self viewOrigin" extent:aRectangle extent) |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
670 |
repairNow:true. |
1449 | 671 |
|
2053
5c19fe5b2db3
invalidate rather than redraw
Claus Gittinger <cg@exept.de>
parents:
2034
diff
changeset
|
672 |
"Modified: / 15.11.2001 / 16:43:53 / cg" |
1449 | 673 |
! |
674 |
||
627 | 675 |
redrawImageX:x y:y width:w height:h |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
676 |
self redrawImageX:x y:y width:w height:h unmaskedOnly:false |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
677 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
678 |
"Modified: / 18.5.1999 / 20:14:03 / cg" |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
679 |
! |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
680 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
681 |
redrawImageX:x y:y width:w height:h unmaskedOnly:unmaskedOnly |
3319 | 682 |
"redraw the magnified (editing) view of the image" |
636 | 683 |
|
5413 | 684 |
self |
685 |
redrawImageX:x y:y width:w height:h |
|
686 |
unmaskedOnly:unmaskedOnly processColorsWith:[:colorIn | colorIn]. |
|
687 |
||
688 |
"Created: / 18.5.1999 / 20:13:39 / cg" |
|
689 |
"Modified: / 18.5.1999 / 20:36:20 / cg" |
|
690 |
! |
|
691 |
||
692 |
redrawImageX:x y:y width:w height:h unmaskedOnly:unmaskedOnly processColorsWith:aColorBlock |
|
693 |
"redraw the magnified (editing) view of the image" |
|
694 |
||
5591 | 695 |
|ih iw magX magY minX maxX minY maxY lastColor lastY runW x0 |
696 |
isMasked mask photometric |
|
697 |
lastPixelColor |
|
698 |
sizeOfMaskPoint offsetOfMaskPoint |
|
699 |
useNearestColor isRGBA isRGBLike drawPixel |
|
700 |
showPixelValue pixelValueFont savedFont ascent| |
|
1180 | 701 |
|
4999 | 702 |
useNearestColor := device visualType == #PseudoColor. |
627 | 703 |
|
1037 | 704 |
mask := image mask. |
5591 | 705 |
photometric := image photometric. |
706 |
isRGBA := photometric == #rgba. |
|
707 |
isRGBLike := #(rgb rgba argb) includes:photometric. |
|
627 | 708 |
ih := image height. |
709 |
iw := image width. |
|
662 | 710 |
magX := magnification x. |
711 |
magY := magnification y. |
|
627 | 712 |
|
662 | 713 |
minX := (x // magX - 1) max: 0. |
725 | 714 |
minX >= iw ifTrue:[minX := (iw - 1) max: 0]. |
662 | 715 |
minY := (y // magY - 1) max: 0. |
725 | 716 |
minY >= ih ifTrue:[minY := (ih - 1) max: 0]. |
662 | 717 |
maxX := (x + w) // magX + 1. |
627 | 718 |
maxX > iw ifTrue:[maxX := iw]. |
662 | 719 |
maxY := (y + h) // magY + 1. |
627 | 720 |
maxY > ih ifTrue:[maxY := ih]. |
721 |
||
5591 | 722 |
showPixelValue := "(image depth <= 12) and:["(magX > 32) and:[magY > 32]"]". |
723 |
showPixelValue ifTrue:[ |
|
724 |
pixelValueFont := TextView defaultFont asSize:(magY // 6). |
|
725 |
pixelValueFont := pixelValueFont onDevice:gc device. |
|
726 |
savedFont := gc font. |
|
727 |
gc font:pixelValueFont. |
|
728 |
ascent := pixelValueFont ascent + 2. |
|
729 |
]. |
|
730 |
||
731 |
drawPixel := |
|
732 |
[:x :y :clr | |
|
733 |
|origin pixelColor pixelValue s| |
|
734 |
||
735 |
origin := (x * magX + margin)@(y * magY + margin). |
|
736 |
(unmaskedOnly and:[isMasked]) ifFalse:[ |
|
737 |
self fillFramedRectangle: (origin extent: runW@magY). |
|
738 |
isMasked ifTrue:[ |
|
739 |
gc xoring:[ |
|
740 |
gc fillRectangle: (origin + offsetOfMaskPoint extent: sizeOfMaskPoint) |
|
741 |
] |
|
742 |
] ifFalse:[ |
|
743 |
pixelValueFont notNil ifTrue:[ |
|
744 |
pixelColor := gc paint. |
|
745 |
gc paint:(pixelColor contrastingColorFor:pixelColor). |
|
746 |
pixelValue := image pixelAtX:x y:y. |
|
747 |
isRGBLike ifTrue:[ |
|
748 |
s := pixelValue hexPrintString. |
|
749 |
] ifFalse:[ |
|
750 |
s := pixelValue printString. |
|
751 |
]. |
|
752 |
gc displayString:s x:(origin x + 1) y:(origin y + ascent). |
|
753 |
]. |
|
754 |
]. |
|
755 |
] |
|
756 |
]. |
|
757 |
||
627 | 758 |
lastY := -1. |
759 |
x0 := minX. |
|
760 |
runW := 0. |
|
5591 | 761 |
isMasked := false. |
762 |
sizeOfMaskPoint := (magnification//3) min:8. |
|
763 |
offsetOfMaskPoint := (magnification - sizeOfMaskPoint) // 2. |
|
764 |
||
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
765 |
image |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
766 |
colorsFromX:minX y:minY toX:maxX-1 y:maxY-1 |
5413 | 767 |
do:[:xx :yy :colorIn| |
768 |
|color| |
|
769 |
||
770 |
color := aColorBlock value:colorIn. |
|
771 |
||
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
772 |
shown ifFalse:[^ self]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
773 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
774 |
yy ~~ lastY ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
775 |
runW ~~ 0 ifTrue:[ |
5591 | 776 |
drawPixel value:x0 value:lastY value:lastColor. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
777 |
runW := 0. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
778 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
779 |
x0 := xx. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
780 |
lastY := yy. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
781 |
]. |
1160 | 782 |
|
5591 | 783 |
(color ~= lastColor or:[showPixelValue]) ifTrue:[ |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
784 |
runW ~~ 0 ifTrue:[ |
5591 | 785 |
drawPixel value:x0 value:yy value:lastColor. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
786 |
runW := 0. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
787 |
]. |
5591 | 788 |
|
789 |
lastColor := lastPixelColor := color. |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
790 |
useNearestColor ifTrue:[ |
4999 | 791 |
lastColor := lastColor nearestOn:device |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
792 |
]. |
5432 | 793 |
gc paint:lastColor. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
794 |
mask notNil ifTrue:[ |
5591 | 795 |
isMasked := false. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
796 |
(mask pixelAtX:xx y:yy) == 0 ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
797 |
unmaskedOnly ifFalse:[ |
5432 | 798 |
gc paint: (lastColor := self viewBackground). |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
799 |
]. |
5591 | 800 |
isMasked := true. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
801 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
802 |
lastColor := nil. |
5485 | 803 |
] ifFalse:[ |
804 |
isRGBA ifTrue:[ |
|
5591 | 805 |
isMasked := false. |
5485 | 806 |
colorIn alphaByte == 0 ifTrue:[ |
807 |
unmaskedOnly ifFalse:[ |
|
808 |
gc paint: (lastColor := self viewBackground). |
|
809 |
]. |
|
5591 | 810 |
isMasked := true. |
5485 | 811 |
] ifFalse:[ |
812 |
]. |
|
813 |
lastColor := nil. |
|
814 |
] |
|
815 |
]. |
|
1160 | 816 |
runW := 0. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
817 |
x0 := xx. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
818 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
819 |
runW := runW + magX |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
820 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
821 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
822 |
runW ~~ 0 ifTrue:[ |
5591 | 823 |
drawPixel value:x0 value:lastY value:lastColor. |
824 |
]. |
|
825 |
||
826 |
savedFont notNil ifTrue:[ |
|
827 |
gc font:savedFont. |
|
627 | 828 |
]. |
1037 | 829 |
|
5485 | 830 |
"Created: / 18-05-1999 / 20:13:39 / cg" |
5591 | 831 |
"Modified: / 01-09-2017 / 11:39:09 / cg" |
627 | 832 |
! |
833 |
||
834 |
redrawX:x y:y width:w height:h |
|
636 | 835 |
|
5413 | 836 |
|xI yI devImage imgWidth imgHeight mX mY magnifiedWidth magnifiedHeight| |
627 | 837 |
|
1037 | 838 |
image isNil ifTrue:[^self]. |
662 | 839 |
|
1037 | 840 |
magnification = (1@1) ifTrue: [ |
4212 | 841 |
Error handle:[:ex | |
2092 | 842 |
Transcript showCR:'cannot convert image: ', ex description. |
1510
fd0cd6065dc6
catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
843 |
] do:[ |
4999 | 844 |
devImage := image onDevice:device. |
1763
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
845 |
devImage ~~ image ifTrue:[ |
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
846 |
image := devImage. |
1764 | 847 |
self changed:#image. |
1763
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
848 |
]. |
1510
fd0cd6065dc6
catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
849 |
]. |
4999 | 850 |
image device == device ifTrue:[ |
5413 | 851 |
super redrawX:x y:y width:w height:h. |
852 |
self drawFrame. |
|
853 |
^ self. |
|
1510
fd0cd6065dc6
catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
854 |
]. |
1037 | 855 |
]. |
627 | 856 |
|
3476 | 857 |
"/ self clippingRectangle: (x@y extent:w@h). |
5413 | 858 |
"/ draw the image itself |
627 | 859 |
self redrawImageX:x y:y width:w height:h. |
860 |
||
4233 | 861 |
imgWidth := image width. |
862 |
imgHeight := image height. |
|
863 |
||
3476 | 864 |
"/ beyond of image ? |
5413 | 865 |
adjust == #center ifTrue:[ |
4233 | 866 |
xI := (width - imgWidth) // 2 - margin. |
867 |
yI := (height - imgHeight) // 2 - margin. |
|
5413 | 868 |
] ifFalse:[ |
1449 | 869 |
xI := yI := margin |
627 | 870 |
]. |
1967 | 871 |
|
5413 | 872 |
mX := magnification x. |
873 |
mY := magnification y. |
|
874 |
magnifiedWidth := mX * imgWidth. |
|
875 |
magnifiedHeight := mY * imgHeight. |
|
876 |
||
877 |
"/ draw the rest to the right and at the bottom |
|
878 |
(x + w - 1) > (xI + magnifiedWidth) ifTrue:[ |
|
879 |
self |
|
880 |
clearRectangleX:(xI + magnifiedWidth) y:y |
|
881 |
width:(x + w - magnifiedWidth - xI) height:h |
|
627 | 882 |
]. |
5413 | 883 |
(y + h - 1) > (yI + magnifiedHeight) ifTrue:[ |
884 |
self |
|
885 |
clearRectangleX:margin y:(yI + magnifiedHeight) |
|
886 |
width:w height:(y + h - magnifiedHeight - yI) |
|
627 | 887 |
]. |
888 |
self drawFrame. |
|
5413 | 889 |
self clippingBounds: nil. |
1037 | 890 |
|
891 |
"Modified: / 31.7.1998 / 02:22:45 / cg" |
|
3476 | 892 |
! |
893 |
||
894 |
startSpray |
|
895 |
spraySpot isNil ifTrue:[ |
|
896 |
spraySpot := 8 |
|
897 |
]. |
|
898 |
||
899 |
sprayProcess isNil ifTrue:[ |
|
900 |
sprayProcess := [ |
|
901 |
|p rnd norm sprayPoint dly angle x y dist| |
|
902 |
||
903 |
rnd := Random new. |
|
3477 | 904 |
Distributions::NormalDistribution notNil ifTrue:[ |
905 |
norm := Distributions::NormalDistribution mean:0 deviation:0.5. |
|
906 |
]. |
|
3487 | 907 |
dly := Delay forMilliseconds:20. |
3476 | 908 |
[true] whileTrue:[ |
909 |
10 timesRepeat:[ |
|
910 |
p := sprayPosition. |
|
911 |
p notNil ifTrue:[ |
|
912 |
angle := rnd next * 359.999. "/ the angle is uniformly ditributed |
|
3477 | 913 |
norm notNil ifTrue:[ |
914 |
dist := norm next * spraySpot. "/ the distance is a normalDistribution |
|
915 |
] ifFalse:[ |
|
916 |
dist := (rnd nextBetween:-1 and:1) * spraySpot. |
|
917 |
]. |
|
3476 | 918 |
sprayPoint := (Point r:dist degrees:angle)*magnification. |
919 |
||
920 |
x := p x + sprayPoint x truncated. |
|
921 |
y := p y + sprayPoint y truncated. |
|
4111 | 922 |
self pointAt:(x@y) width:1. |
3476 | 923 |
]. |
924 |
]. |
|
925 |
dly wait. |
|
926 |
]. |
|
927 |
] fork. |
|
928 |
] |
|
929 |
||
4111 | 930 |
"Modified: / 15-02-2012 / 22:44:54 / cg" |
3476 | 931 |
! |
932 |
||
933 |
stopSpray |
|
934 |
sprayProcess notNil ifTrue:[ |
|
935 |
sprayProcess terminate. |
|
936 |
sprayProcess := nil |
|
937 |
]. |
|
627 | 938 |
! ! |
939 |
||
940 |
!ImageEditView methodsFor:'event handling'! |
|
941 |
||
942 |
buttonMotion:state x:x y:y |
|
1693 | 943 |
|p| |
944 |
||
2072
abd4e246f393
care for negative pos in buttonMotion (win32 klusge)
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
945 |
(x < 0 or:[y < 0]) ifTrue:[ |
abd4e246f393
care for negative pos in buttonMotion (win32 klusge)
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
946 |
^ self |
abd4e246f393
care for negative pos in buttonMotion (win32 klusge)
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
947 |
]. |
5413 | 948 |
"/ readOnly ifTrue:[^ self]. |
2072
abd4e246f393
care for negative pos in buttonMotion (win32 klusge)
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
949 |
|
1693 | 950 |
p := x@y. |
951 |
||
952 |
state ~~ 0 ifTrue:[ |
|
3476 | 953 |
"/ button down |
954 |
||
955 |
"/ self selectedColor notNil ifTrue:[ |
|
956 |
(self imageContainsPoint:p) ifTrue:[ |
|
6150 | 957 |
((editMode == EditModePoint) or:[editMode == EditModePointBlend]) ifTrue:[ |
3476 | 958 |
self pointAt:p. |
959 |
^ self |
|
960 |
]. |
|
4715 | 961 |
(editMode == EditModeSmooth) ifTrue:[ |
962 |
self smoothAt:p. |
|
963 |
^ self |
|
964 |
]. |
|
3476 | 965 |
sprayProcess notNil ifTrue:[ |
966 |
sprayPosition := p. |
|
5481 | 967 |
^ self |
3476 | 968 |
]. |
1246 | 969 |
]. |
1693 | 970 |
self drawCursorAt:p. |
3476 | 971 |
^ self |
972 |
]. |
|
973 |
||
5413 | 974 |
"/ button is up (care for paste-mode, dragging the pasted image) |
3476 | 975 |
self drawCursorAt:p. |
5481 | 976 |
|
977 |
"/ if in pastemode, highlight the affected rectangle (image to be pasted is in ClipBoard) |
|
5618 | 978 |
(self inPasteMode and:[ ClipboardImage notNil ]) ifTrue: [ |
5481 | 979 |
"/ with shift, paste is offset by pasted image's size |
980 |
"/ (i.e. click-point will be corner of pasted rectangle) |
|
3476 | 981 |
self sensor shiftDown ifTrue:[ |
5655 | 982 |
p := p - (ClipboardImage extent * magnification) |
3476 | 983 |
]. |
5481 | 984 |
(self imageContainsPastePoint:p) ifTrue:[ |
985 |
(self sensor hasButtonMotionEventFor:self) ifFalse:[ |
|
986 |
self drawPasteRectangleAt:p |
|
987 |
] |
|
988 |
] ifFalse: [ |
|
989 |
self cursor:Cursor stop. |
|
990 |
self releasePasteDrawing |
|
991 |
] |
|
686 | 992 |
] |
1019
e68414752bc9
only change the cursor for myself.
Claus Gittinger <cg@exept.de>
parents:
1013
diff
changeset
|
993 |
|
5655 | 994 |
"Modified: / 07-12-2017 / 17:53:35 / cg" |
624 | 995 |
! |
255 | 996 |
|
627 | 997 |
buttonPress:button x:x y:y |
2889 | 998 |
|p clr masked| |
627 | 999 |
|
1693 | 1000 |
p := x@y. |
1001 |
||
5481 | 1002 |
"/ with shift, paste is offset by pasted image's size |
1003 |
"/ (i.e. click-point will be corner of pasted rectangle) |
|
5618 | 1004 |
(self inPasteMode and:[ ClipboardImage notNil ]) ifTrue:[ |
3278 | 1005 |
self sensor shiftDown ifTrue:[ |
5655 | 1006 |
p := p - (ClipboardImage extent * magnification) |
3278 | 1007 |
] |
1008 |
]. |
|
1009 |
||
1693 | 1010 |
self drawCursorAt:p. |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1011 |
|
5481 | 1012 |
(self imageContainsPoint:p) ifTrue:[ |
5480 | 1013 |
"/ shift click: select the pixel-color |
5481 | 1014 |
(self inPasteMode not and:[self sensor shiftDown]) ifTrue:[ |
5484 | 1015 |
userAllowedToChangeDrawingColor ifTrue:[ |
1016 |
(image maskAt:(p // magnification)) == 0 ifTrue:[ |
|
1017 |
masked := true. |
|
1018 |
] ifFalse:[ |
|
1019 |
masked := false. |
|
1020 |
clr := image colorAt:(p // magnification). |
|
1021 |
]. |
|
1022 |
pickedColorHolder notNil ifTrue:[ |
|
1023 |
pickedColorHolder value:clr. |
|
1024 |
]. |
|
1025 |
self selectedColor:clr. |
|
1026 |
masked ifTrue:[self selectedColorIndex:nil]. |
|
1027 |
self changed:#selectedColor with:clr. |
|
1028 |
]. |
|
1246 | 1029 |
] ifFalse:[ |
5480 | 1030 |
"/ normal click: |
5413 | 1031 |
(readOnly not |
1032 |
or:[editMode == EditModeCopy |
|
1033 |
or:[editMode == EditModeSpecialOperation]] |
|
1034 |
) ifTrue:[ |
|
4853 | 1035 |
(button between:1 and:2) ifTrue:[ |
1036 |
mouseKeyColorMode := button. |
|
1037 |
self makeUndo. |
|
1038 |
||
1039 |
clickInfoCallBack notNil ifTrue:[ |
|
1040 |
"/ still a kludge, but less ugly ... |
|
1041 |
clickInfoCallBack value:button value:p |
|
1042 |
]. |
|
1043 |
"/ editMode is something like #point, #rectangle etc. |
|
5480 | 1044 |
"/ so we call pointAt: / rectAt: / filledBoxAt: etc. here |
4853 | 1045 |
[ |
1046 |
self perform: (editMode, 'At:') asSymbol with:p |
|
1047 |
] on:Error do:[:ex | |
|
1048 |
(Dialog confirm:('Error during operation: ', ex description,'\\Debug ?') withCRs ) |
|
1049 |
ifTrue:[ |
|
1050 |
ex reject |
|
1051 |
]. |
|
4041 | 1052 |
]. |
2889 | 1053 |
]. |
1054 |
]. |
|
1246 | 1055 |
] |
686 | 1056 |
] |
995 | 1057 |
|
5655 | 1058 |
"Modified: / 07-12-2017 / 17:53:23 / cg" |
632 | 1059 |
! |
1060 |
||
994
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
1061 |
buttonRelease:button x:x y:y |
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
1062 |
|
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
1063 |
self drawCursorAt: x@y. |
4041 | 1064 |
readOnly ifTrue:[^ self]. |
1246 | 1065 |
|
5481 | 1066 |
(self imageContainsPoint: x@y) ifTrue: [ |
3476 | 1067 |
sprayProcess notNil ifTrue:[ |
1068 |
self stopSpray |
|
1069 |
]. |
|
1070 |
||
1763
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
1071 |
image release. |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1072 |
|
5481 | 1073 |
"/ "/ cg: what a kludge - please change to use a valueHolder, |
1074 |
"/ "/ which gets the information ... |
|
1075 |
"/ masterApplication imagePreView invalidate. |
|
1693 | 1076 |
|
1077 |
"/ cg: still a kludge - but less ugly |
|
1078 |
self changed:#subImageIn with:(image bounds). |
|
994
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
1079 |
] |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1080 |
|
5481 | 1081 |
"Modified: / 16-02-2017 / 16:57:24 / cg" |
994
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
1082 |
! |
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
1083 |
|
2508 | 1084 |
inPasteMode |
2889 | 1085 |
^ (editMode notNil and:[editMode startsWith:#paste]) |
2508 | 1086 |
! |
1087 |
||
5669 | 1088 |
keyboardZoom:largerBoolean |
5671 | 1089 |
"CTRL+/- zoom action" |
1090 |
||
1091 |
self magnification:( |
|
1092 |
largerBoolean |
|
1093 |
ifTrue:[(magnification + 1) min:63] |
|
1094 |
ifFalse:[(magnification - 1) max:1]) |
|
5277 | 1095 |
! |
1096 |
||
686 | 1097 |
pointerLeave:state |
1098 |
||
688 | 1099 |
super pointerLeave: state. |
686 | 1100 |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1101 |
self updateImageInfo: self imageInfoString. |
1019
e68414752bc9
only change the cursor for myself.
Claus Gittinger <cg@exept.de>
parents:
1013
diff
changeset
|
1102 |
self cursor:Cursor normal. |
995 | 1103 |
|
2508 | 1104 |
self inPasteMode ifTrue: [ |
1246 | 1105 |
self releasePasteDrawing |
1106 |
] |
|
995 | 1107 |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1108 |
"Modified: / 29.7.1998 / 18:27:42 / cg" |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1109 |
! ! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1110 |
|
636 | 1111 |
!ImageEditView methodsFor:'image editing'! |
627 | 1112 |
|
5491 | 1113 |
askForSpecialOperation |
1114 |
"let user ask for which special operation to apply to the selected imageBox, |
|
1115 |
then perform it." |
|
1116 |
||
5497 | 1117 |
|listOfOpSpecs listOfOpNames listOfOpSelectors operation| |
1118 |
||
1119 |
listOfOpSpecs := OrderedCollection new. |
|
5491 | 1120 |
|
5497 | 1121 |
listOfOpSpecs addAll: |
5491 | 1122 |
#( |
5497 | 1123 |
('edit separately' editIcon #edit) |
1124 |
('extract subimage' cropSubImageIcon #editSubImage) |
|
5491 | 1125 |
). |
1126 |
||
1127 |
self readOnly ifFalse:[ |
|
5497 | 1128 |
listOfOpSpecs addAll: |
1129 |
#( |
|
1130 |
('-' nil nil) |
|
1131 |
('flip vertical' flipVerticalIcon flipVertical) |
|
1132 |
('flip horizontal' flipHorizontalIcon flipHorizontal) |
|
1133 |
('-' nil nil) |
|
1134 |
('slightly brightened' slightlyBrighterIcon slightlyBrightened) |
|
1135 |
('slightly darkened' slightlyDarkerIcon slightlyDarkened) |
|
1136 |
('brightened' brighterIcon brightened) |
|
1137 |
('darkened' darkerIcon darkened) |
|
1138 |
('-' nil nil) |
|
1139 |
('make grey' nil makeGrey) |
|
1140 |
('greyed' nil greyed) |
|
1141 |
('grey pattern' nil greyPattern) |
|
1142 |
('grey pattern (unmasked)' nil unmaskedGreyPattern) |
|
1143 |
('-' nil nil) |
|
1144 |
('reversed' nil reversed) |
|
1145 |
('-' nil nil) |
|
1146 |
('change hue' nil changeHue) |
|
1147 |
('colorize' nil colorize) |
|
1148 |
('-' nil nil) |
|
1149 |
('gradient fill horizontal' fillHorizontalGradientRectIcon gradientFillHorizontal) |
|
1150 |
('gradient fill vertical' fillVerticalGradientRectIcon gradientFillVertical) |
|
5499 | 1151 |
"/ unfinished |
1152 |
"/ ('gradient fill diagonal' fillDiagonalGradientRectIcon gradientFillDiagonal) |
|
5497 | 1153 |
('-' nil nil) |
1154 |
('auto gradient fill horizontal' fillHorizontalGradientRectIcon autoGradientFillHorizontal) |
|
1155 |
('auto gradient fill vertical' fillVerticalGradientRectIcon autoGradientFillVertical) |
|
5499 | 1156 |
"/ unfinished |
1157 |
"/ ('auto gradient fill diagonal' fillDiagonalGradientRectIcon autoGradientFillDiagonal) |
|
5497 | 1158 |
). |
5491 | 1159 |
]. |
1160 |
||
5497 | 1161 |
listOfOpNames := listOfOpSpecs collect:[:entry | |
1162 |
|name iconSelector icon| |
|
1163 |
name := entry first. |
|
1164 |
iconSelector := entry second. |
|
1165 |
iconSelector notNil ifTrue:[ |
|
1166 |
icon := self class perform:iconSelector ifNotUnderstood:[ImageEditor perform:iconSelector]. |
|
1167 |
LabelAndIcon label:name icon:icon |
|
1168 |
] ifFalse:[ |
|
1169 |
name |
|
1170 |
]. |
|
1171 |
]. |
|
1172 |
||
1173 |
listOfOpSelectors := listOfOpSpecs collect:#third. |
|
1174 |
||
5491 | 1175 |
operation := Dialog |
1176 |
choose:(resources string:'Which Operation:') |
|
1177 |
fromList:listOfOpNames |
|
1178 |
values:listOfOpSelectors |
|
5497 | 1179 |
lines:20 |
5491 | 1180 |
cancel:nil. |
1181 |
||
1182 |
^ operation |
|
1183 |
||
1184 |
"Created: / 20-02-2017 / 17:37:23 / cg" |
|
5499 | 1185 |
"Modified: / 23-02-2017 / 15:54:42 / cg" |
5491 | 1186 |
! |
1187 |
||
5492 | 1188 |
autoCropLeft:doLeft right:doRight top:doTop bottom:doBottom |
1189 |
|yMinNew yMaxNew xMinNew xMaxNew |
|
1190 |
pix stillCropping xMax yMax| |
|
1191 |
||
5531 | 1192 |
image isNil ifTrue:[^ self]. |
1193 |
||
5492 | 1194 |
xMax := image width - 1. |
1195 |
yMax := image height - 1. |
|
1196 |
||
1197 |
xMinNew := 0. |
|
1198 |
doLeft ifTrue:[ |
|
1199 |
pix := image pixelAtX:xMinNew y:0. |
|
1200 |
stillCropping := true. |
|
1201 |
[stillCropping] whileTrue:[ |
|
1202 |
0 to:yMax do:[:y | |
|
5531 | 1203 |
(image pixelAtX:xMinNew y:y) ~= pix ifTrue:[ |
5492 | 1204 |
stillCropping := false |
1205 |
] |
|
1206 |
]. |
|
1207 |
stillCropping ifTrue:[ |
|
1208 |
xMinNew := xMinNew + 1. |
|
1209 |
xMinNew >= image width ifTrue:[ |
|
1210 |
self warn:(resources string:'Image is all the same color - no crop.'). |
|
1211 |
^ self |
|
1212 |
] |
|
1213 |
]. |
|
1214 |
]. |
|
1215 |
]. |
|
1216 |
||
1217 |
xMaxNew := xMax. |
|
1218 |
doRight ifTrue:[ |
|
1219 |
stillCropping := true. |
|
1220 |
pix := image pixelAtX:xMaxNew y:0. |
|
1221 |
[stillCropping] whileTrue:[ |
|
1222 |
0 to:yMax do:[:y | |
|
5531 | 1223 |
(image pixelAtX:xMaxNew y:y) ~= pix ifTrue:[ |
5492 | 1224 |
stillCropping := false |
1225 |
] |
|
1226 |
]. |
|
1227 |
stillCropping ifTrue:[ |
|
1228 |
xMaxNew := xMaxNew - 1. |
|
1229 |
]. |
|
1230 |
]. |
|
1231 |
]. |
|
1232 |
||
1233 |
yMinNew := 0. |
|
1234 |
doTop ifTrue:[ |
|
1235 |
pix := image pixelAtX:xMinNew y:yMinNew. |
|
1236 |
stillCropping := true. |
|
1237 |
[stillCropping] whileTrue:[ |
|
1238 |
xMinNew to:xMaxNew do:[:x | |
|
5531 | 1239 |
(image pixelAtX:x y:yMinNew) ~= pix ifTrue:[ |
5492 | 1240 |
stillCropping := false |
1241 |
] |
|
1242 |
]. |
|
1243 |
stillCropping ifTrue:[ |
|
1244 |
yMinNew := yMinNew + 1. |
|
1245 |
]. |
|
1246 |
]. |
|
1247 |
]. |
|
1248 |
||
1249 |
yMaxNew := yMax. |
|
5531 | 1250 |
doBottom ifTrue:[ |
5492 | 1251 |
stillCropping := true. |
1252 |
pix := image pixelAtX:xMaxNew y:yMaxNew. |
|
1253 |
[stillCropping] whileTrue:[ |
|
1254 |
xMinNew to:xMaxNew do:[:x | |
|
5531 | 1255 |
(image pixelAtX:x y:yMaxNew) ~= pix ifTrue:[ |
5492 | 1256 |
stillCropping := false |
1257 |
] |
|
1258 |
]. |
|
1259 |
stillCropping ifTrue:[ |
|
1260 |
yMaxNew := yMaxNew - 1. |
|
1261 |
]. |
|
1262 |
]. |
|
1263 |
]. |
|
1264 |
||
1265 |
(xMinNew == 0 |
|
1266 |
and:[xMaxNew == (image width - 1) |
|
1267 |
and:[yMinNew == 0 |
|
1268 |
and:[yMaxNew == (image height - 1)]]]) ifTrue:[ |
|
1269 |
self warn:(resources string:'No border found - no crob.'). |
|
1270 |
^ self |
|
1271 |
]. |
|
1272 |
||
1273 |
"/ self warn:'extract subImage ' |
|
1274 |
"/ , (xMinNew @ yMinNew) printString |
|
1275 |
"/ , ' -> ' |
|
1276 |
"/ , (xMaxNew @ yMaxNew) printString. |
|
1277 |
||
1278 |
self makeUndo. |
|
1279 |
self |
|
1280 |
makeSubImageX:xMinNew y:yMinNew |
|
1281 |
width:(xMaxNew - xMinNew + 1) |
|
1282 |
height:(yMaxNew - yMinNew + 1) |
|
1283 |
||
1284 |
"Created: / 20-02-2017 / 17:59:05 / cg" |
|
5531 | 1285 |
"Modified: / 12-04-2017 / 09:33:08 / cg" |
5492 | 1286 |
! |
1287 |
||
2480 | 1288 |
copyImageToClipboard |
5531 | 1289 |
image isNil ifTrue:[^ self]. |
1290 |
||
2480 | 1291 |
self class copyImageToClipboard:image. |
4264 | 1292 |
self setClipboardObject:image. |
5531 | 1293 |
|
1294 |
"Modified: / 12-04-2017 / 09:27:07 / cg" |
|
2480 | 1295 |
! |
1296 |
||
1228 | 1297 |
cropLeft:doLeft right:doRight top:doTop bottom:doBottom |
5531 | 1298 |
<resource: #obsolete> |
1299 |
||
1300 |
self autoCropLeft:doLeft right:doRight top:doTop bottom:doBottom |
|
1301 |
||
1302 |
"Created: / 07-09-1998 / 14:25:52 / cg" |
|
1303 |
"Modified: / 12-04-2017 / 09:31:04 / cg" |
|
1121 | 1304 |
! |
1305 |
||
5435 | 1306 |
drawingColorOrNil |
1307 |
|cmap| |
|
1308 |
||
1309 |
cmap := image colorMap. |
|
1310 |
(cmap isNil or:[cmap isFixedPalette or:[cmap isMappedPalette]]) ifTrue:[ |
|
1311 |
^ self selectedColor. |
|
1312 |
]. |
|
1313 |
^ nil |
|
1314 |
||
1315 |
"Created: / 03-02-2017 / 21:58:01 / cg" |
|
5594 | 1316 |
"Modified: / 05-09-2017 / 10:49:34 / cg" |
5435 | 1317 |
! |
1318 |
||
1319 |
drawingPixelOrNil |
|
1320 |
|cmap| |
|
1321 |
||
1322 |
cmap := image colorMap. |
|
1323 |
(cmap isNil or:[cmap isFixedPalette or:[cmap isMappedPalette]]) ifTrue:[ |
|
1324 |
^ nil. |
|
1325 |
]. |
|
1326 |
^ self selectedColorIndex. |
|
1327 |
||
1328 |
"Created: / 03-02-2017 / 21:58:28 / cg" |
|
1329 |
! |
|
1330 |
||
4032 | 1331 |
flipSubImage:how in:imageBox |
1332 |
"/ now, do it |
|
4624 | 1333 |
"/ caveat: this should go into image class |
4032 | 1334 |
|
1335 |
|x0 y0 x1 y1 image t| |
|
1336 |
||
4623 | 1337 |
self makeUndo. |
1338 |
||
4032 | 1339 |
x0 := imageBox left. |
1340 |
y0 := imageBox top. |
|
1341 |
x1 := imageBox right-1. |
|
1342 |
y1 := imageBox bottom-1. |
|
1343 |
||
1344 |
image := self image. |
|
1345 |
||
1346 |
how == #vertical ifTrue:[ |
|
1347 |
0 to:((y1-y0)//2) do:[:dy | |
|
1348 |
x0 to:x1 do:[:x | |
|
1349 |
t := image pixelAtX:x y:(y0+dy). |
|
1350 |
image pixelAtX:x y:(y0+dy) put:(image pixelAtX:x y:(y1-dy)). |
|
1351 |
image pixelAtX:x y:(y1-dy) put:t. |
|
4624 | 1352 |
image mask notNil ifTrue:[ |
1353 |
t := image maskAtX:x y:(y0+dy). |
|
1354 |
image maskAtX:x y:(y0+dy) put:(image maskAtX:x y:(y1-dy)). |
|
1355 |
image maskAtX:x y:(y1-dy) put:t. |
|
1356 |
]. |
|
4032 | 1357 |
]. |
1358 |
] |
|
1359 |
] ifFalse:[ |
|
1360 |
0 to:((x1-x0)//2) do:[:dx | |
|
1361 |
y0 to:y1 do:[:y | |
|
1362 |
t := image pixelAtX:(x0+dx) y:y. |
|
1363 |
image pixelAtX:(x0+dx) y:y put:(image pixelAtX:(x1-dx) y:y). |
|
1364 |
image pixelAtX:(x1-dx) y:y put:t. |
|
4623 | 1365 |
|
4624 | 1366 |
image mask notNil ifTrue:[ |
1367 |
t := image maskAtX:(x0+dx) y:y. |
|
1368 |
image maskAtX:(x0+dx) y:y put:(image maskAtX:(x1-dx) y:y). |
|
1369 |
image maskAtX:(x1-dx) y:y put:t. |
|
1370 |
]. |
|
4032 | 1371 |
]. |
1372 |
] |
|
1373 |
]. |
|
1374 |
||
1375 |
self setModified. |
|
1376 |
||
1377 |
"Created: / 07-04-2011 / 09:34:23 / cg" |
|
1378 |
! |
|
1379 |
||
5497 | 1380 |
gradientFillIn:imageBox orientation:orientation auto:auto |
5499 | 1381 |
"/ with auto, pick 2 bounding pixels and do a gradient fill with those; |
1382 |
"/ (don't know what diagonal should do, yet) |
|
5497 | 1383 |
"/ if auto is false, use color1/color2 for the fill |
1384 |
||
1385 |
|x0 y0 x1 y1 image n color1 color2 |
|
5499 | 1386 |
r0 g0 b0 dR dG dB i cX cY A B qAB a b pD1x pD1y pD2x pD2y |
1387 |
dxH dyH hX hY dH dP f | |
|
5497 | 1388 |
|
1389 |
self makeUndo. |
|
1390 |
||
1391 |
x0 := imageBox left. |
|
1392 |
y0 := imageBox top. |
|
1393 |
x1 := imageBox right-1. |
|
1394 |
y1 := imageBox bottom-1. |
|
1395 |
image := self image. |
|
1396 |
||
1397 |
self setModified. |
|
1398 |
||
1399 |
auto ifTrue:[ |
|
1400 |
orientation == #vertical ifTrue:[ |
|
1401 |
n := y1-y0-1. |
|
1402 |
n = 0 ifTrue:[^ self]. |
|
1403 |
x0 to:x1 do:[:x | |
|
1404 |
color1 := image colorAtX:x y:y0. |
|
1405 |
color2 := image colorAtX:x y:y1. |
|
1406 |
r0 := color1 red. |
|
1407 |
g0 := color1 green. |
|
1408 |
b0 := color1 blue. |
|
1409 |
dR := (color2 red - color1 red) / n. |
|
1410 |
dG := (color2 green - color1 green) / n. |
|
1411 |
dB := (color2 blue - color1 blue) / n. |
|
1412 |
i := 1. |
|
1413 |
y0+1 to:y1-1 do:[:y | |
|
1414 |
|clr| |
|
1415 |
clr := Color red:(r0 + (i*dR)) green:(g0 + (i*dG)) blue:(b0 + (i*dB)). |
|
1416 |
image colorAtX:x y:y put:clr. |
|
1417 |
i := i+1. |
|
1418 |
]. |
|
1419 |
]. |
|
1420 |
^ self. |
|
1421 |
]. |
|
1422 |
||
1423 |
orientation == #horizontal ifTrue:[ |
|
1424 |
n := x1-x0-1. |
|
1425 |
n = 0 ifTrue:[^ self]. |
|
1426 |
y0 to:y1 do:[:y | |
|
1427 |
color1 := image colorAtX:x0 y:y. |
|
1428 |
color2 := image colorAtX:x1 y:y. |
|
1429 |
r0 := color1 red. |
|
1430 |
g0 := color1 green. |
|
1431 |
b0 := color1 blue. |
|
1432 |
dR := (color2 red - color1 red) / n. |
|
1433 |
dG := (color2 green - color1 green) / n. |
|
1434 |
dB := (color2 blue - color1 blue) / n. |
|
1435 |
i := 1. |
|
1436 |
x0+1 to:x1-1 do:[:x | |
|
1437 |
|clr| |
|
1438 |
clr := Color red:(r0 + (i*dR)) green:(g0 + (i*dG)) blue:(b0 + (i*dB)). |
|
1439 |
image colorAtX:x y:y put:clr. |
|
1440 |
i := i+1. |
|
1441 |
]. |
|
1442 |
]. |
|
1443 |
^ self. |
|
1444 |
]. |
|
1445 |
^ self. |
|
1446 |
]. |
|
1447 |
||
5499 | 1448 |
color1 := (self drawingColorHolders at:1) value. |
5497 | 1449 |
color1 isNil ifTrue:[ color1 := Color black ]. |
5499 | 1450 |
color2 := (self drawingColorHolders at:2) value. |
5497 | 1451 |
color2 isNil ifTrue:[ color2 := Color white ]. |
1452 |
||
1453 |
r0 := color1 red. |
|
1454 |
g0 := color1 green. |
|
1455 |
b0 := color1 blue. |
|
1456 |
||
1457 |
orientation == #vertical ifTrue:[ |
|
1458 |
n := y1-y0. |
|
1459 |
n = 0 ifTrue:[^ self]. |
|
1460 |
||
5499 | 1461 |
dR := (color2 red - r0) / n. |
1462 |
dG := (color2 green - g0) / n. |
|
1463 |
dB := (color2 blue - b0) / n. |
|
5497 | 1464 |
|
1465 |
x0 to:x1 do:[:x | |
|
1466 |
i := 0. |
|
1467 |
y0 to:y1 do:[:y | |
|
1468 |
|clr| |
|
1469 |
clr := Color red:(r0 + (i*dR)) green:(g0 + (i*dG)) blue:(b0 + (i*dB)). |
|
1470 |
image colorAtX:x y:y put:clr. |
|
1471 |
i := i+1. |
|
1472 |
]. |
|
1473 |
]. |
|
1474 |
^ self. |
|
1475 |
]. |
|
1476 |
orientation == #horizontal ifTrue:[ |
|
1477 |
n := x1-x0. |
|
1478 |
n = 0 ifTrue:[^ self ]. |
|
1479 |
||
5499 | 1480 |
dR := (color2 red - r0) / n. |
1481 |
dG := (color2 green - g0) / n. |
|
1482 |
dB := (color2 blue - b0) / n. |
|
5497 | 1483 |
|
1484 |
y0 to:y1 do:[:y | |
|
1485 |
i := 1. |
|
1486 |
x0+1 to:x1-1 do:[:x | |
|
1487 |
|clr| |
|
1488 |
clr := Color red:(r0 + (i*dR)) green:(g0 + (i*dG)) blue:(b0 + (i*dB)). |
|
1489 |
image colorAtX:x y:y put:clr. |
|
1490 |
i := i+1. |
|
1491 |
]. |
|
1492 |
]. |
|
1493 |
^ self. |
|
1494 |
]. |
|
1495 |
||
1496 |
orientation == #diagonal ifTrue:[ |
|
5499 | 1497 |
cX := (x1+1 + x0) / 2. |
1498 |
cY := (y1+1 + y0) / 2. |
|
1499 |
A := cY-y0. |
|
1500 |
B := cX-x0. |
|
1501 |
(A=0 or:[B=0]) ifTrue:[^ self]. |
|
1502 |
||
1503 |
qAB := A/B. |
|
5497 | 1504 |
|
5499 | 1505 |
"/ {(cX-10) rounded . (cX-5) rounded . cX rounded . (cX+5)rounded . (cX+10)rounded } |
1506 |
x0 to:x1 |
|
1507 |
do:[:x | |
|
1508 |
b := cX-x. |
|
1509 |
b = 0 ifTrue:[ |
|
1510 |
pD1x := pD2x := cX. |
|
1511 |
pD1y := pD2y := cY. |
|
1512 |
] ifFalse:[ |
|
1513 |
"/ (A/B) = (a/b) -> a = (A/B)*b |
|
1514 |
a := qAB*b. |
|
1515 |
pD1x := ((cX-b) max:x0) min:x1. |
|
1516 |
pD1y := ((cY+a) max:y0) min:y1. |
|
1517 |
pD2x := ((cX-b) max:x0) min:x1. |
|
1518 |
pD2y := ((cY-a) max:y0) min:y1. |
|
1519 |
]. |
|
1520 |
"/ {(cY-10)rounded . (cY-5)rounded . cY rounded. (cY+5)rounded. (cY+10)rounded } |
|
1521 |
y0 to:y1 |
|
1522 |
do:[:y | |
|
1523 |
"/ the edge-point to interpolate against... |
|
1524 |
"/ take a line from C through x/y and compute where it hits the edge H |
|
1525 |
a := y-cY. |
|
1526 |
b := x-cX. |
|
1527 |
(a = 0) ifTrue:[ |
|
1528 |
"/ exactly in the middle |
|
1529 |
hX := (x < cX) ifTrue:[x0] ifFalse:[x1]. |
|
1530 |
hY := cY. |
|
5497 | 1531 |
] ifFalse:[ |
5499 | 1532 |
(b = 0) ifTrue:[ |
1533 |
hX := cX. |
|
1534 |
hY := (y < cY) ifTrue:[y0] ifFalse:[y1]. |
|
1535 |
] ifFalse:[ |
|
1536 |
"/ (dH/A) = (b/a) -> dH = (b/a)*A |
|
1537 |
y <= pD1y ifTrue:[ |
|
1538 |
"/ in left-upper half |
|
1539 |
(y <= pD2y) ifTrue:[ |
|
1540 |
"/ in upper quadrant |
|
1541 |
dxH := (b/a)*A. |
|
1542 |
hX := cX-dxH. |
|
1543 |
hY := y0. |
|
1544 |
] ifFalse:[ |
|
1545 |
"/ in left quadrant |
|
1546 |
dyH := (a/b)*B negated. |
|
1547 |
hY := cY+dyH. |
|
1548 |
hX := x0. |
|
1549 |
]. |
|
1550 |
] ifFalse:[ |
|
1551 |
"/ in right-lower half |
|
1552 |
y >= pD2y ifTrue:[ |
|
1553 |
"/ in lower quadrant |
|
1554 |
dxH := (b/a)*A negated. |
|
1555 |
hX := cX-dxH. |
|
1556 |
hY := y1. |
|
1557 |
] ifFalse:[ |
|
1558 |
"/ in right quadrant |
|
1559 |
dyH := (a/b)*B. |
|
1560 |
hY := cY+dyH. |
|
1561 |
hX := x1. |
|
1562 |
]. |
|
1563 |
]. |
|
1564 |
]. |
|
1565 |
hX := hX min:x1. |
|
1566 |
hY := hY min:y1. |
|
5497 | 1567 |
]. |
5499 | 1568 |
|
1569 |
"/ the color at H |
|
1570 |
color2 := image colorAtX:hX rounded y:hY rounded. |
|
1571 |
||
1572 |
"/ the distance between H and C |
|
1573 |
dH := (hX@hY) dist:(cX@cY). |
|
1574 |
"/ the distance between P and C |
|
1575 |
dP := (x@y) dist:(cX@cY). |
|
1576 |
"/ the fraction (0 at H; 1 at C) |
|
1577 |
f := 1 - (dP / dH). |
|
1578 |
self assert:(f between:0 and:1). |
|
1579 |
||
1580 |
"/ the new color |
|
1581 |
dR := color2 red + ((r0-color2 red ) * f). |
|
1582 |
dG := color2 green + ((g0-color2 green) * f). |
|
1583 |
dB := color2 blue + ((b0-color2 blue) * f). |
|
1584 |
image colorAtX:x y:y put:(Color red:dR green:dG blue:dB). |
|
1585 |
||
1586 |
"/ y <= pD1y ifTrue:[ |
|
1587 |
"/ "/ in left-upper half |
|
1588 |
"/ (y <= pD2y) ifTrue:[ |
|
1589 |
"/ "/ in upper quadrant |
|
1590 |
"/ image colorAtX:x y:y put:Color red. |
|
1591 |
"/ ] ifFalse:[ |
|
1592 |
"/ "/ in left quadrant |
|
1593 |
"/ image colorAtX:x y:y put:Color green. |
|
1594 |
"/ ]. |
|
1595 |
"/ ] ifFalse:[ |
|
1596 |
"/ "/ in right-lower half |
|
1597 |
"/ y >= pD2y ifTrue:[ |
|
1598 |
"/ "/ in lower quadrant |
|
1599 |
"/ image colorAtX:x y:y put:Color blue. |
|
1600 |
"/ ] ifFalse:[ |
|
1601 |
"/ "/ in right quadrant |
|
1602 |
"/ image colorAtX:x y:y put:Color yellow. |
|
1603 |
"/ ]. |
|
1604 |
"/ |
|
1605 |
"/ ]. |
|
1606 |
]. |
|
5497 | 1607 |
]. |
5499 | 1608 |
"/ image colorAtX:cX rounded y:cY rounded put:Color magenta. |
1609 |
||
1610 |
"/ clr2 := image colorAtX:p2X y:p2Y. |
|
1611 |
"/ |
|
1612 |
"/ cTop := image colorAtX:x y:y0. |
|
1613 |
"/ cBot := image colorAtX:x y:y1. |
|
1614 |
"/ "/ point on diagonal |
|
1615 |
"/ xD := x. |
|
1616 |
"/ yD := (y1-y0)/(x1-x0)*x. |
|
1617 |
"/ "/ color at point on diagonal |
|
1618 |
"/ "/ cDiag := image colorAtX:xD rounded y:yD rounded. |
|
1619 |
"/ "/ the distance of the diagonal point from the origin |
|
1620 |
"/ dd := ((x-x0) squared + (yD-y0) squared) sqrt. |
|
1621 |
"/ "/ desired color at point on diagonal |
|
1622 |
"/ cDiag := Color red:(color1 red + (dd*dR)) green:(color1 green + (dd*dG)) blue:(color1 blue + (dd*dB)). |
|
1623 |
"/"/ image colorAtX:xD rounded y:yD rounded put:cDiag. |
|
1624 |
"/ |
|
1625 |
"/ n1 := yD-y0+1. "/ num points between top at x and diagonalPoint at x |
|
1626 |
"/ n2 := y1-yD+1. "/ num points between diagonalPoint at x and bottom at x |
|
1627 |
"/ y0 to:y1 do:[:y | |
|
1628 |
"/ |clr d dR2 dG2 dB2| |
|
1629 |
"/ |
|
1630 |
"/ y < yD ifTrue:[ |
|
1631 |
"/ "/ gradient from top-color at x to diagonal point at x |
|
1632 |
"/ d := y-y0. |
|
1633 |
"/ dR2 := (cDiag red - cTop red) / n1. |
|
1634 |
"/ dG2 := (cDiag green - cTop green) / n1. |
|
1635 |
"/ dB2 := (cDiag blue - cTop blue) / n1. |
|
1636 |
"/ clr := Color red:(cTop red + (d*dR2)) green:(cTop green + (d*dG2)) blue:(cTop blue + (d*dB2)). |
|
1637 |
"/ image colorAtX:x y:y put:clr. |
|
1638 |
"/ ] ifFalse:[ |
|
1639 |
"/ "/ gradient from diagonal point at x to bottom point at x |
|
1640 |
"/ d := y-yD. |
|
1641 |
"/ dR2 := (cBot red - cDiag red) / n2. |
|
1642 |
"/ dG2 := (cBot green - cDiag green) / n2. |
|
1643 |
"/ dB2 := (cBot blue - cDiag blue) / n2. |
|
1644 |
"/ clr := Color red:(cDiag red + (d*dR2)) green:(cDiag green + (d*dG2)) blue:(cDiag blue + (d*dB2)). |
|
1645 |
"/ "/ clr := image colorAtX:x y:y. |
|
1646 |
"/ image colorAtX:x y:y put:clr. |
|
1647 |
"/ ]. |
|
1648 |
"/ ] |
|
1649 |
"/ ]. |
|
5497 | 1650 |
^ self. |
1651 |
]. |
|
1652 |
||
1653 |
"Created: / 22-02-2017 / 21:00:01 / cg" |
|
5499 | 1654 |
"Modified: / 23-02-2017 / 15:41:23 / cg" |
5497 | 1655 |
! |
1656 |
||
4723 | 1657 |
magnifyAntiAliasedImageTo:newSize |
4730 | 1658 |
self newImageWithUndo: (image hardAntiAliasedMagnifiedBy: newSize/image extent). |
4723 | 1659 |
! |
1660 |
||
1706 | 1661 |
magnifyImageTo:newSize |
4730 | 1662 |
self newImageWithUndo: (image magnifiedBy: newSize/image extent). |
636 | 1663 |
! |
1664 |
||
5586 | 1665 |
magnifySmoothingBy:scale |
1666 |
self newImageWithUndo: (image hardSmoothingMagnifiedBy:scale). |
|
1667 |
||
1668 |
"Created: / 30-08-2017 / 15:35:15 / cg" |
|
1669 |
! |
|
1670 |
||
5587 | 1671 |
magnifySmoothingTo:newSize |
1672 |
self newImageWithUndo: (image hardSmoothingMagnifiedBy: newSize/image extent). |
|
1673 |
||
1674 |
"Created: / 30-08-2017 / 15:46:46 / cg" |
|
1675 |
! |
|
1676 |
||
2168 | 1677 |
makeNewColorMapByMapping:functionOfColor |
5589 | 1678 |
"wrong name: no longer needs a colormap - can also process the pixels |
1679 |
||
1680 |
undoable make a new image by processing colors with a function. |
|
1681 |
If the image is a true-color image (rgb), the function is applied |
|
1682 |
to every pixel's color and a new pixel-array is created (this is slow). |
|
1683 |
Currently not done (why?): |
|
1684 |
If the image is a palette image, |
|
1685 |
the function is applied to the colormap only and a new colormap is |
|
1686 |
created (i.e. this is very fast). |
|
1687 |
||
1688 |
This is the internal low level function to brighten, darken |
|
1689 |
or hue-shift the image. |
|
1690 |
Returns true, if there was any change." |
|
1691 |
||
2566
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1692 |
|xMax yMax map revMap anyChange |
5589 | 1693 |
newColors newColorArray newImage pixelAction |
1694 |
prevRGBIn prevRGBOut| |
|
2168 | 1695 |
|
1886 | 1696 |
anyChange := false. |
1697 |
||
1698 |
xMax := image width - 1. |
|
1699 |
yMax := image height - 1. |
|
1700 |
||
1701 |
newImage := image class width:image width height:image height depth:image depth. |
|
5589 | 1702 |
|
1886 | 1703 |
newImage photometric:image photometric. |
1704 |
newImage bits:(ByteArray new:(image bits size)). |
|
1705 |
newImage mask:(image mask copy). |
|
1706 |
||
2566
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1707 |
image colorMap notNil ifTrue:[ |
5589 | 1708 |
"/ huh - what is going on here??? |
1709 |
"/ whx not just collect over the colormap??? |
|
1710 |
||
2566
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1711 |
newColors := Set new. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1712 |
newColorArray := OrderedCollection new. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1713 |
map := Array new:256. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1714 |
revMap := OrderedCollection new. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1715 |
|
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1716 |
pixelAction := |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1717 |
[:x :y | |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1718 |
|pix n_pix clr n_clr| |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1719 |
|
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1720 |
pix := image pixelAtX:x y:y. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1721 |
(n_pix := map at:pix+1) isNil ifTrue:[ |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1722 |
clr := image colorAtX:x y:y. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1723 |
n_clr := functionOfColor value:clr. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1724 |
(newColors includes:n_clr) ifFalse:[ |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1725 |
newColors add:n_clr. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1726 |
newColorArray add:n_clr. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1727 |
revMap add:pix. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1728 |
map at:pix+1 put:(n_pix := revMap size - 1). |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1729 |
] ifTrue:[ |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1730 |
"/ mhmh - multiple pixels mapped to the same color |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1731 |
n_pix := (newColorArray indexOf:n_clr) - 1. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1732 |
map at:pix+1 put:n_pix. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1733 |
] |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1734 |
]. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1735 |
newImage pixelAtX:x y:y put:n_pix. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1736 |
]. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1737 |
] ifFalse:[ |
5589 | 1738 |
((image depth == 24) and:[image photometric == #rgb]) ifTrue:[ |
1739 |
pixelAction := |
|
1740 |
[:x :y | |
|
1741 |
|rgb clr n_rgb| |
|
1742 |
||
1743 |
rgb := image pixelAtX:x y:y. |
|
1744 |
rgb == prevRGBIn ifTrue:[ |
|
1745 |
n_rgb := prevRGBOut |
|
1746 |
] ifFalse:[ |
|
1747 |
clr := Color rgbValue:rgb. |
|
1748 |
n_rgb := (functionOfColor value:clr) rgbValue. |
|
1749 |
prevRGBIn := rgb. |
|
1750 |
prevRGBOut := n_rgb. |
|
1751 |
]. |
|
1752 |
newImage pixelAtX:x y:y put:n_rgb. |
|
1753 |
]. |
|
1754 |
] ifFalse:[ |
|
1755 |
pixelAction := |
|
1756 |
[:x :y | |
|
1757 |
|clr n_clr| |
|
1758 |
||
1759 |
||
1760 |
clr := image colorAtX:x y:y. |
|
1761 |
n_clr := functionOfColor value:clr. |
|
1762 |
newImage colorAtX:x y:y put:n_clr. |
|
1763 |
]. |
|
1764 |
]. |
|
2566
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1765 |
]. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1766 |
|
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1767 |
0 to:yMax do:[:y | |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1768 |
0 to:xMax do:[:x | |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1769 |
pixelAction value:x value:y |
1886 | 1770 |
] |
1771 |
]. |
|
1772 |
||
2566
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1773 |
image colorMap notNil ifTrue:[ |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1774 |
newImage colorMap:(MappedPalette withColors:newColorArray). |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1775 |
]. |
4730 | 1776 |
self newImageWithUndo:newImage. |
5589 | 1777 |
|
1778 |
"/ for now, always return true |
|
1779 |
"/ (do not check if functionOfColor returns somthing different) |
|
1886 | 1780 |
^ true |
5589 | 1781 |
|
1782 |
"Modified (comment): / 31-08-2017 / 12:11:25 / cg" |
|
1886 | 1783 |
! |
1784 |
||
1121 | 1785 |
makeSubImageX:oldX y:oldY width:newWidth height:newHeight |
3706 | 1786 |
|oldWidth oldHeight newImage newMaskImage needRedraw redrawRect1 redrawRect2 | |
1787 |
||
1788 |
oldWidth := image width. |
|
1789 |
oldHeight := image height. |
|
1790 |
self assert:(newWidth <= oldWidth). |
|
1791 |
self assert:(newHeight <= oldHeight). |
|
1121 | 1792 |
|
1793 |
newImage := image class width:newWidth height:newHeight depth:image depth. |
|
1794 |
newImage photometric:image photometric. |
|
5468 | 1795 |
image photometric == #palette ifTrue:[ |
1796 |
newImage colorMap:image colorMap copy. |
|
1797 |
]. |
|
1121 | 1798 |
newImage bits:(ByteArray new:(newImage bytesPerRow * newHeight)). |
1799 |
||
3706 | 1800 |
image mask notNil ifTrue:[ |
1121 | 1801 |
newMaskImage := Depth1Image width:newWidth height:newHeight. |
1802 |
newMaskImage photometric: image mask photometric. |
|
1803 |
newMaskImage colorMap: image mask colorMap copy. |
|
1804 |
newMaskImage bits:(ByteArray new: newMaskImage bytesPerRow * newHeight). |
|
1805 |
newImage mask: newMaskImage |
|
1806 |
]. |
|
1807 |
||
1808 |
newImage copyFrom:image x:oldX y:oldY toX:0 y:0 width:newWidth height:newHeight. |
|
3706 | 1809 |
|
1810 |
needRedraw := true. |
|
1811 |
(oldX == 0 and:[oldY == 0]) ifTrue:[ |
|
1812 |
needRedraw := false. |
|
5332 | 1813 |
redrawRect1 := ((newWidth@0) * magnification) corner:(((oldWidth@oldHeight)+1) * magnification). |
1814 |
redrawRect2 := ((0@newHeight) * magnification) corner:(((oldWidth@oldHeight)+1) * magnification). |
|
3706 | 1815 |
]. |
1816 |
self image:newImage scroll:false invalidate:needRedraw. |
|
1817 |
redrawRect1 notNil ifTrue:[ |
|
1818 |
self invalidateRectangle:redrawRect1 repairNow:false. |
|
1819 |
]. |
|
1820 |
redrawRect2 notNil ifTrue:[ |
|
1821 |
self invalidateRectangle:redrawRect2 repairNow:false. |
|
1822 |
]. |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1823 |
self setModified. |
1121 | 1824 |
|
5332 | 1825 |
"Created: / 07-09-1998 / 13:00:16 / cg" |
5468 | 1826 |
"Modified: / 13-02-2017 / 14:48:46 / cg" |
1121 | 1827 |
! |
1828 |
||
2915 | 1829 |
makeUndo |
5499 | 1830 |
|theCopy| |
1831 |
||
1832 |
image notNil ifTrue:[ |
|
3278 | 1833 |
[undoImages size >= MaxUndos] whileTrue:[ |
2915 | 1834 |
undoImages removeFirst. |
1835 |
]. |
|
5499 | 1836 |
theCopy := image copy. |
1837 |
undoImages add:theCopy. |
|
1838 |
originalImage isNil ifTrue:[ originalImage := theCopy ]. |
|
2915 | 1839 |
] |
3278 | 1840 |
|
5499 | 1841 |
"Modified: / 23-02-2017 / 15:43:55 / cg" |
2915 | 1842 |
! |
1843 |
||
2135 | 1844 |
pasteAt: aPoint mode:modeSymbol |
5480 | 1845 |
"called from button-press/button motion while in paste mode: |
1846 |
paste the image in the clipboard at aPoint" |
|
636 | 1847 |
|
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1848 |
|answer anyColorMissing choosenBox imagePoint imgX imgY copiedImage imageBox newColorMap |
2764 | 1849 |
existingColors newColors allColors currentColorMap newColormap anyColorAdded oldColorMap| |
1888 | 1850 |
|
4203 | 1851 |
Error handle:[:ex| |
1852 |
ex creator == Image unrepresentableColorSignal ifFalse:[ |
|
1246 | 1853 |
ex reject |
1854 |
]. |
|
1855 |
self undo. |
|
5061 | 1856 |
self warn:(resources stringWithCRs:'Paste failed !!\Increasing the images depth might help.'). |
1823 | 1857 |
] do: [ |
1246 | 1858 |
windowGroup withExecuteCursorDo:[ |
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1859 |
choosenBox := self dragRectangleStartingAt: aPoint emphasis: #inverseFilledBox. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1860 |
choosenBox isNil ifTrue:[ ^ self ]. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1861 |
|
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1862 |
imagePoint := choosenBox origin//magnification. |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1863 |
|
5618 | 1864 |
copiedImage := ClipboardImage copy. |
5417 | 1865 |
copiedImage isNil ifTrue:[^ self]. |
1866 |
||
2440 | 1867 |
true "/ image photometric == #palette |
1888 | 1868 |
ifTrue:[ |
1246 | 1869 |
"/ for all colors in the pasted image, |
5472 | 1870 |
"/ check, if it's in the colormap of the |
1246 | 1871 |
"/ target image. |
995 | 1872 |
|
2764 | 1873 |
anyColorMissing := anyColorAdded := false. |
1874 |
oldColorMap := image colorMap. |
|
5434 | 1875 |
(oldColorMap notNil and:[image photometric == #palette]) ifTrue:[ |
2764 | 1876 |
newColorMap := oldColorMap asOrderedCollection. |
1957
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1877 |
copiedImage usedValues do:[:pixel | |
2764 | 1878 |
|pastedColor | |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1879 |
|
1957
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1880 |
pastedColor := copiedImage colorFromValue:pixel. |
2764 | 1881 |
|
3762 | 1882 |
(newColorMap includes:pastedColor) ifFalse:[ |
2764 | 1883 |
newColorMap size < (1 bitShift:image depth) ifTrue:[ |
1957
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1884 |
"/ add to colormap |
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1885 |
newColorMap add:pastedColor. |
2764 | 1886 |
anyColorAdded := true. |
1957
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1887 |
"/ Transcript showCR:'adding color:' , pastedColor displayString , ' to targets colorMap'. |
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1888 |
] ifFalse:[ |
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1889 |
"/ Transcript showCR:'color:' , pastedColor displayString , ' not found in targets colorMap'. |
1987 | 1890 |
"/ copiedImage colorMap notNil ifTrue:[ |
1891 |
"/ copiedImage colorMap at: pixel+1 put: Color black. |
|
1892 |
"/ ]. |
|
1957
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1893 |
anyColorMissing := true. |
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1894 |
] |
1246 | 1895 |
] |
1957
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1896 |
]. |
1246 | 1897 |
]. |
2764 | 1898 |
|
1888 | 1899 |
anyColorMissing ifTrue:[ |
1900 |
answer := Dialog |
|
5061 | 1901 |
confirmWithCancel:(resources stringWithCRs:'Some color(s) cannot be represented (colorMap full).\Use nearest or compute colorMap ?') |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1902 |
labels:#( 'Cancel' 'New ColorMap' 'Use Nearest' ) |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1903 |
values:#( nil new nearest) |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1904 |
default:3. |
1888 | 1905 |
|
1906 |
answer isNil ifTrue:[^ self]. |
|
1986
630db3277f10
support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents:
1980
diff
changeset
|
1907 |
|
630db3277f10
support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents:
1980
diff
changeset
|
1908 |
currentColorMap := image colorMap. |
1987 | 1909 |
imgX := imagePoint x. |
1910 |
imgY := imagePoint y. |
|
1986
630db3277f10
support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents:
1980
diff
changeset
|
1911 |
|
1888 | 1912 |
answer == #nearest ifTrue:[ |
1913 |
0 to:copiedImage height-1 do:[:y | |
|
1914 |
0 to:copiedImage width-1 do:[:x | |
|
1915 |
|clr n_clr| |
|
1916 |
||
1987 | 1917 |
(copiedImage maskAtX:x y:y) == 0 ifTrue:[ |
1918 |
image mask isNil ifTrue:[ |
|
1919 |
image createMask. |
|
1920 |
]. |
|
1921 |
image maskAtX:imgX+x y:imgY+y put:0. |
|
1922 |
] ifFalse:[ |
|
2582 | 1923 |
clr := copiedImage colorAtX:x y:y. |
1987 | 1924 |
n_clr := clr nearestIn:currentColorMap. |
2582 | 1925 |
image colorAtX:imgX+x y:imgY+y put:n_clr |
1987 | 1926 |
] |
1888 | 1927 |
] |
1928 |
]. |
|
1987 | 1929 |
image restored. |
5618 | 1930 |
self redraw: (imageBox := (imagePoint * magnification extent: (ClipboardImage extent * magnification)) expandedBy: 1@1). |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1931 |
self setModified. |
6081 | 1932 |
self changed:#imageColors. |
1987 | 1933 |
^ self. |
2135 | 1934 |
]. |
1935 |
answer == #new ifTrue:[ |
|
5926 | 1936 |
existingColors := image usedColors asSet. |
1937 |
newColors := copiedImage usedColors. |
|
1938 |
allColors := (Set withAll:existingColors) addAll:newColors; yourself. |
|
2135 | 1939 |
allColors size > (1 bitShift:image depth) ifTrue:[ |
5926 | 1940 |
self warn:(resources string:'Sorry: too many colors - please change the depth, then paste again'). |
2135 | 1941 |
self undo. |
1986
630db3277f10
support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents:
1980
diff
changeset
|
1942 |
^ self. |
630db3277f10
support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents:
1980
diff
changeset
|
1943 |
]. |
2135 | 1944 |
|
1945 |
newColormap := OrderedCollection new. |
|
1946 |
newColormap addAll:image usedColors. |
|
1947 |
newColormap addAll:copiedImage usedColors. |
|
1948 |
"/ translate image to use new colorMap... |
|
1949 |
||
1950 |
"/ translate image to use new colors ... |
|
1951 |
0 to:image height-1 do:[:y | |
|
1952 |
0 to:image width-1 do:[:x | |
|
1953 |
|clr n_idx| |
|
1954 |
||
1955 |
(image maskAtX:x y:y) == 1 ifTrue:[ |
|
2582 | 1956 |
clr := image colorAtX:x y:y. |
2135 | 1957 |
n_idx := newColormap indexOf:clr. |
1958 |
image pixelAtX:x y:y put:n_idx-1. |
|
1959 |
] |
|
1960 |
] |
|
1961 |
]. |
|
1962 |
image colorMap:newColormap. |
|
1963 |
currentColorMap := newColormap. |
|
1964 |
||
1965 |
"/ paste new image... |
|
1966 |
0 to:copiedImage height-1 do:[:y | |
|
1967 |
0 to:copiedImage width-1 do:[:x | |
|
1968 |
|clr idx| |
|
1969 |
||
1970 |
(copiedImage maskAtX:x y:y) == 1 |
|
1971 |
ifTrue:[ |
|
2582 | 1972 |
clr := copiedImage colorAtX:x y:y. |
2135 | 1973 |
idx := currentColorMap indexOf:clr. |
1974 |
idx == 0 ifTrue:[ |
|
1975 |
currentColorMap add:clr. |
|
1976 |
idx := currentColorMap size. |
|
1977 |
idx > (1 bitShift:image depth) ifTrue:[ |
|
5061 | 1978 |
self warn:(resources string:'Sorry: too many colors'). |
2135 | 1979 |
self undo. |
1980 |
^ self. |
|
1981 |
]. |
|
1982 |
]. |
|
1983 |
image pixelAtX:imgX+x y:imgY+y put:idx-1. |
|
1984 |
image maskAtX:imgX+x y:imgY+y put:1. |
|
1985 |
] |
|
1986 |
] |
|
1987 |
]. |
|
1988 |
image restored. |
|
5618 | 1989 |
self redraw: (imageBox := (imagePoint * magnification extent: (ClipboardImage extent * magnification)) expandedBy: 1@1). |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1990 |
self setModified. |
6081 | 1991 |
self changed:#imageColors. |
1888 | 1992 |
^ self. |
1993 |
]. |
|
5061 | 1994 |
self warn:(resources string:'Sorry: unimplemented function'). |
2135 | 1995 |
self undo. |
1996 |
^ self. |
|
1888 | 1997 |
]. |
2764 | 1998 |
anyColorAdded ifTrue:[ |
2490
62230519175a
slowly getting rid of the Colormap class
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1999 |
image colorMap:(MappedPalette withColors:newColorMap). |
1246 | 2000 |
]. |
2001 |
]. |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2002 |
|
1246 | 2003 |
copiedImage := image class fromImage: copiedImage. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2004 |
(newColorMap isNil |
2135 | 2005 |
and:[modeSymbol isNil |
1987 | 2006 |
and:[copiedImage mask isNil] ]) ifTrue:[ |
5654 | 2007 |
"/ use image's copy functionality |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2008 |
"/ however, this copies the mask as well, |
5772 | 2009 |
"/ which is only useful for paste-mode nil (paste pixel+mask) |
1246 | 2010 |
image copyFrom: copiedImage x:0 y:0 toX: imagePoint x y: imagePoint y width: copiedImage width height: copiedImage height. |
2011 |
] ifFalse:[ |
|
2012 |
imgX := imagePoint x. |
|
2013 |
imgY := imagePoint y. |
|
1028
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
2014 |
|
1246 | 2015 |
0 to:copiedImage height-1 do:[:y | |
2016 |
0 to:copiedImage width-1 do:[:x | |
|
2017 |
|wasMasked newMasked dstX dstY oldColor| |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2018 |
|
1246 | 2019 |
dstX := imgX + x. |
2020 |
dstY := imgY + y. |
|
2021 |
wasMasked := (image maskAtX:dstX y:dstY) == 0. |
|
2022 |
newMasked := (copiedImage maskAtX:x y:y) == 0. |
|
994
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
2023 |
|
1246 | 2024 |
"/ with modeUnder, |
5654 | 2025 |
"/ only replace, if its masked, |
5772 | 2026 |
(modeSymbol isNil |
2027 |
or:[modeSymbol == #withMask |
|
2028 |
or:[modeSymbol == #masked |
|
2029 |
or:[wasMasked]]] |
|
5654 | 2030 |
) ifTrue:[ |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2031 |
newMasked ifFalse:[ |
2764 | 2032 |
image colorAtX:dstX y:dstY put:(copiedImage colorAtX:x y:y). |
1823 | 2033 |
wasMasked ifTrue:[ |
5654 | 2034 |
"/ wasMasked before; no longer masked now |
5772 | 2035 |
(modeSymbol == #withMask |
2036 |
or:[modeSymbol == #under |
|
2037 |
or:[modeSymbol == #masked]]) ifTrue:[ |
|
5654 | 2038 |
image maskAtX:dstX y:dstY put:1 |
2039 |
]. |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2040 |
]. |
1823 | 2041 |
] ifTrue:[ |
2042 |
wasMasked ifFalse:[ |
|
5654 | 2043 |
"/ masked now; was not masked before |
2135 | 2044 |
modeSymbol == #withMask ifTrue:[ |
2045 |
image maskAtX:dstX y:dstY put:0 |
|
2046 |
] |
|
1823 | 2047 |
] |
2048 |
]. |
|
1987 | 2049 |
]. |
2050 |
||
1246 | 2051 |
] |
2052 |
]. |
|
2053 |
]. |
|
2054 |
image restored. |
|
5618 | 2055 |
self redraw: (imageBox := (imagePoint * magnification extent: (ClipboardImage extent * magnification)) expandedBy: 1@1). |
1028
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
2056 |
"/ masterApplication imagePreView redraw: (imageBox expandedBy: 1). |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
2057 |
self setModified. |
6081 | 2058 |
self changed:#imageColors. |
1246 | 2059 |
] |
1028
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
2060 |
] |
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
2061 |
|
5654 | 2062 |
"Modified: / 07-12-2017 / 15:56:42 / cg" |
6081 | 2063 |
"Modified: / 29-06-2019 / 23:21:19 / Claus Gittinger" |
636 | 2064 |
! |
2065 |
||
2086 | 2066 |
shiftImageHorizontal:shiftH vertical:shiftV |
2489 | 2067 |
self shiftImageHorizontal:shiftH vertical:shiftV wrap:false |
2068 |
! |
|
2069 |
||
2070 |
shiftImageHorizontal:shiftH vertical:shiftV wrap:doWrap |
|
2071 |
"shift the pixels; |
|
2072 |
shift<0 is left-shift/up-shift; shift>0 is right-shift/down-shift; |
|
2073 |
doWrap controls if shifted-out pixels are to be shifted in at the opposite side. |
|
2074 |
i.e.: |
|
2075 |
0123456789 -> 3456789789 (shift: -3) 0123456789 -> 0120123456 (shift:3) |
|
2076 |
or, with wrap: |
|
2077 |
0123456789 -> 3456789012 (shift: -3) 0123456789 -> 7890123456 (shift:3) |
|
2078 |
" |
|
2079 |
||
2080 |
|newImage| |
|
2081 |
||
2082 |
newImage := self shifted:image horizontal:shiftH vertical:shiftV wrap:doWrap. |
|
2083 |
self image:newImage. |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
2084 |
self setModified. |
2489 | 2085 |
! |
2086 |
||
2087 |
shifted:image horizontal:shiftH vertical:shiftV wrap:doWrap |
|
2088 |
"shift the pixels; |
|
2089 |
shift<0 is left-shift/up-shift; shift>0 is right-shift/down-shift; |
|
2090 |
doWrap controls if shifted-out pixels are to be shifted in at the opposite side. |
|
2091 |
i.e.: |
|
2092 |
0123456789 -> 3456789789 (shift: -3) 0123456789 -> 0120123456 (shift:3) |
|
2093 |
or, with wrap: |
|
2094 |
0123456789 -> 3456789012 (shift: -3) 0123456789 -> 7890123456 (shift:3) |
|
2095 |
" |
|
2096 |
||
2086 | 2097 |
|w h srcX srcY dstX dstY newImage| |
2098 |
||
2489 | 2099 |
doWrap ifTrue:[ |
2100 |
"/ if wrapping, split into two operations to make wrap-code below simpler. |
|
2101 |
||
2102 |
shiftH ~~ 0 ifTrue:[ |
|
2103 |
shiftV ~~ 0 ifTrue:[ |
|
2104 |
newImage := self shifted:image horizontal:shiftH vertical:0 wrap:doWrap. |
|
2105 |
newImage := self shifted:newImage horizontal:0 vertical:shiftV wrap:doWrap. |
|
2106 |
^ newImage |
|
2107 |
]. |
|
2108 |
]. |
|
2109 |
]. |
|
2110 |
(shiftV == 0 and:[shiftH == 0]) ifTrue:[ |
|
2111 |
^ image |
|
2112 |
]. |
|
2113 |
||
2086 | 2114 |
w := image width. |
2115 |
h := image height. |
|
2116 |
||
2117 |
newImage := image copy. |
|
2118 |
||
2119 |
srcX := srcY := dstX := dstY := 0. |
|
2120 |
shiftH < 0 ifTrue:[ |
|
2121 |
srcX := shiftH negated |
|
2122 |
] ifFalse:[ |
|
2123 |
dstX := shiftH |
|
2124 |
]. |
|
2125 |
shiftV < 0 ifTrue:[ |
|
2126 |
srcY := shiftV negated |
|
2127 |
] ifFalse:[ |
|
2128 |
dstY := shiftV |
|
2129 |
]. |
|
2130 |
||
2131 |
newImage copyFrom:image x:srcX y:srcY toX:dstX y:dstY width:w-shiftH abs height:h-shiftV abs. |
|
2132 |
||
2489 | 2133 |
doWrap ifTrue:[ |
2134 |
srcX := srcY := dstX := dstY := 0. |
|
2135 |
||
2136 |
"/ already simplified - see above |
|
2137 |
shiftH ~~ 0 ifTrue:[ |
|
2138 |
"/ shiftV known to be 0 |
|
2139 |
shiftH < 0 ifTrue:[ |
|
2140 |
dstX := w-1-shiftH negated |
|
2141 |
] ifFalse:[ |
|
2142 |
srcX := w-1-shiftH |
|
2143 |
]. |
|
2144 |
w := shiftH abs. |
|
2145 |
] ifFalse:[ |
|
2146 |
"/ shiftH known to be 0 |
|
2147 |
shiftV < 0 ifTrue:[ |
|
2148 |
dstY := h-1-shiftV negated |
|
2149 |
] ifFalse:[ |
|
2150 |
srcY := h-1-shiftV |
|
2151 |
]. |
|
2152 |
h := shiftV abs. |
|
2153 |
]. |
|
2154 |
newImage copyFrom:image x:srcX y:srcY toX:dstX y:dstY width:w height:h. |
|
2155 |
^ newImage |
|
2156 |
]. |
|
2157 |
||
2158 |
^ newImage. |
|
2086 | 2159 |
|
2160 |
"Created: / 7.9.1998 / 13:00:16 / cg" |
|
2161 |
"Modified: / 7.9.1998 / 14:15:32 / cg" |
|
2162 |
! |
|
2163 |
||
5491 | 2164 |
specialOperation:operation on:imageBox withColor:clr |
5497 | 2165 |
"ask for and perform one of the special operations on the previously selected imageBox; |
5491 | 2166 |
then redraw as required" |
2167 |
||
2168 |
self invalidate. |
|
2169 |
self windowGroup processExposeEvents. |
|
2170 |
||
2171 |
operation isNil ifTrue:[^ false]. |
|
2172 |
||
2173 |
(self performSpecialOperation:operation on:imageBox withColor:self selectedColor) ifFalse:[ |
|
2174 |
^ false |
|
2175 |
]. |
|
2176 |
||
2177 |
image restored. |
|
2178 |
self invalidate. "/ : (choosedBox expandedBy: 1). |
|
2179 |
||
2180 |
"/ self redraw: (choosedBox expandedBy: 1). |
|
2181 |
||
2182 |
"/ "/ cg: what a kludge - please change to use a valueHolder, |
|
2183 |
"/ "/ which gets the information ... |
|
2184 |
"/ masterApplication imagePreView redraw: (imageBox expandedBy: 1). |
|
2185 |
||
2186 |
"/ cg: still a kludge - but less ugly |
|
2187 |
self changed:#subImageIn with:(imageBox expandedBy: 1). |
|
2188 |
self setModified. |
|
2189 |
^ true |
|
2190 |
||
2191 |
"Created: / 20-02-2017 / 17:35:33 / cg" |
|
5497 | 2192 |
"Modified (comment): / 22-02-2017 / 19:56:47 / cg" |
5491 | 2193 |
! |
2194 |
||
5485 | 2195 |
text:aString at:aPoint |
2196 |
"draw a character" |
|
2197 |
||
2198 |
|tempForm| |
|
2199 |
||
2200 |
tempForm := Form extent:(image extent) depth:1 onDevice:device. |
|
2201 |
tempForm clear. |
|
2202 |
tempForm paint:(Color colorId:1). |
|
2203 |
tempForm displayString:aString at:aPoint. |
|
2204 |
0 to:image extent x - 1 do:[:x | |
|
2205 |
0 to:image extent y - 1 do:[:y | |
|
2206 |
(tempForm valueAt:(x@y)) == 1 ifTrue:[ |
|
2207 |
self pointAt:(x@y) width:1 |
|
2208 |
]. |
|
2209 |
] |
|
2210 |
]. |
|
2211 |
||
2212 |
"Modified: / 15-02-2012 / 22:47:44 / cg" |
|
2213 |
! |
|
2214 |
||
2215 |
undo |
|
5499 | 2216 |
|newImage| |
2217 |
||
2218 |
undoImages notEmpty ifTrue:[ |
|
2219 |
newImage := undoImages removeLast. |
|
2220 |
] ifFalse:[ |
|
2221 |
(Dialog confirm:(resources string:'No more undo images remembered. Back to the initial image?')) |
|
2222 |
ifFalse:[^ self]. |
|
2223 |
newImage := originalImage copy |
|
2224 |
]. |
|
2225 |
||
2226 |
windowGroup withExecuteCursorDo:[ |
|
2227 |
|oldImage| |
|
2228 |
||
2229 |
oldImage := self image. |
|
2230 |
self clearModified. |
|
2231 |
self image:newImage scroll:(newImage extent ~= oldImage extent). |
|
5485 | 2232 |
] |
2233 |
||
5499 | 2234 |
"Modified: / 23-02-2017 / 15:47:15 / cg" |
5485 | 2235 |
! ! |
2236 |
||
2237 |
!ImageEditView methodsFor:'image editing-editmode button actions'! |
|
2238 |
||
2239 |
boxAt: aPoint |
|
2240 |
"called from button-press/button motion while in box-drawing mode: |
|
2241 |
drag a rectangular outline, |
|
2242 |
when released, draw a rectangle with the currently selected color" |
|
2243 |
||
2244 |
self |
|
2245 |
commonBoxOperation:[:box :colorOrPixel | |
|
5653 | 2246 |
colorOrPixel isColor ifTrue:[ |
5485 | 2247 |
image drawRectangle:box withColor:colorOrPixel. |
2248 |
] ifFalse:[ |
|
2249 |
image drawRectangle:box withValue:colorOrPixel. |
|
2250 |
]. |
|
2251 |
] |
|
2252 |
at:aPoint |
|
2253 |
||
5653 | 2254 |
"Modified: / 07-12-2017 / 14:52:17 / cg" |
5485 | 2255 |
! |
2256 |
||
2257 |
circleAt: aPoint |
|
2258 |
"called from button-press/button motion while in circle-drawing mode: |
|
2259 |
drag an ellipse, |
|
2260 |
when released, draw an ellipse with the currently selected color" |
|
2261 |
||
2262 |
self |
|
2263 |
commonBoxOperation:[:box :colorOrPixel | |
|
5653 | 2264 |
colorOrPixel isColor ifTrue:[ |
5506 | 2265 |
image drawEllipse:box withColor:colorOrPixel lineWidth:penWidth. |
5485 | 2266 |
] ifFalse:[ |
5506 | 2267 |
image drawEllipse:box withValue:colorOrPixel lineWidth:penWidth. |
5485 | 2268 |
]. |
2269 |
] |
|
2270 |
at:aPoint |
|
2271 |
||
5653 | 2272 |
"Modified: / 07-12-2017 / 14:53:34 / cg" |
5485 | 2273 |
! |
2274 |
||
2275 |
commonBoxOperation:action at:aPoint |
|
2276 |
"common code for filling/drawing." |
|
2277 |
||
2278 |
|choosenBox imageBox clr pix| |
|
2279 |
||
2280 |
(clr := self selectedColor) notNil ifTrue:[ |
|
2281 |
choosenBox := self dragRectangleStartingAt: aPoint emphasis: #box. |
|
2282 |
choosenBox notNil ifTrue:[ |
|
2283 |
imageBox := choosenBox origin//magnification extent: (choosenBox extent//magnification). |
|
2284 |
(clr := self drawingColorOrNil) notNil ifTrue:[ |
|
2285 |
action value:imageBox value:clr. |
|
2286 |
] ifFalse:[ |
|
5653 | 2287 |
pix := self drawingPixelOrNil. |
2288 |
true "pix notNil" ifTrue:[ "/ nil is valid here, and means: masked |
|
5485 | 2289 |
action value:imageBox value:pix. |
2290 |
]. |
|
2291 |
]. |
|
2292 |
image restored. |
|
2293 |
self redraw: (choosenBox expandedBy: 1). |
|
2294 |
||
2295 |
"/ cg: still a kludge - but less ugly |
|
2296 |
self changed:#subImageIn with:(imageBox expandedBy: 1). |
|
2297 |
||
2298 |
self setModified. |
|
2299 |
]. |
|
2300 |
]. |
|
2301 |
||
2302 |
"Created: / 16-02-2017 / 11:20:49 / cg" |
|
5653 | 2303 |
"Modified: / 07-12-2017 / 14:51:37 / cg" |
5485 | 2304 |
! |
2305 |
||
2306 |
copyAt: aPoint |
|
2307 |
"called from button-press/button motion while in copy-drawing mode: |
|
2308 |
drag a filled box, |
|
2309 |
when released, copy the selected rectangle to the clipboard" |
|
2310 |
||
2311 |
|choosenBox box copiedImage| |
|
2312 |
||
2313 |
choosenBox := self dragRectangleStartingAt: aPoint emphasis: #inverseFilledBox. |
|
2314 |
choosenBox notNil ifTrue:[ |
|
2315 |
box := choosenBox origin // magnification extent: (choosenBox extent // magnification). |
|
2316 |
copiedImage := image subImageIn: box. |
|
2317 |
||
2318 |
self class copyImageToClipboard:copiedImage. |
|
2319 |
||
2320 |
self redraw:(choosenBox expandedBy:1) |
|
2321 |
] |
|
2322 |
||
2323 |
"Modified: / 21-08-1998 / 20:16:41 / cg" |
|
2324 |
"Modified (comment): / 16-02-2017 / 11:15:09 / cg" |
|
2325 |
! |
|
2326 |
||
5491 | 2327 |
cropSubImageAt: aPoint |
2328 |
"called from button-press/button motion while in crop-subImage mode: |
|
2329 |
drag a filled box, |
|
2330 |
when released, change the image to the new bounds" |
|
2331 |
||
2332 |
|choosenBox imageBox| |
|
2333 |
||
2334 |
choosenBox := self dragRectangleStartingAt: aPoint emphasis: #inverseFilledBox. |
|
2335 |
choosenBox notNil ifTrue:[ |
|
2336 |
imageBox := choosenBox origin//magnification extent: (choosenBox extent//magnification). |
|
2337 |
self specialOperation:#editSubImage on:imageBox withColor:nil. |
|
2338 |
] |
|
2339 |
||
2340 |
"Created: / 20-02-2017 / 17:27:50 / cg" |
|
2341 |
! |
|
2342 |
||
5485 | 2343 |
fillAt: aPoint |
2344 |
"called from button-press motion while in floo-fill drawing mode: |
|
2345 |
perform a flood-fill with the currently selected color" |
|
2346 |
||
2347 |
windowGroup withExecuteCursorDo:[ |
|
2348 |
|filledPoints clr| |
|
2349 |
||
2350 |
(clr := self selectedColor) notNil ifTrue:[ |
|
2351 |
self updateActivity:'Flood filling - press CTRL-y to abort ...'. |
|
2352 |
[ |
|
2353 |
|pix| |
|
2354 |
||
6160 | 2355 |
((clr := self drawingColorOrNil) notNil and:[clr redByte notNil]) ifTrue:[ |
5485 | 2356 |
pix := image valueFromColor:clr. |
2357 |
] ifFalse:[ |
|
2358 |
pix := self drawingPixelOrNil. |
|
2359 |
]. |
|
2360 |
image floodFillAt:aPoint//magnification withValue:pix |
|
2361 |
maxDeviationInLight:floodFillMaxLightError |
|
2362 |
maxDeviationInHue:floodFillMaxHueError. |
|
2363 |
||
2364 |
image restored. |
|
2365 |
||
2366 |
self invalidate. |
|
2367 |
self changed:#subImageIn with:(image bounds). |
|
2368 |
||
2369 |
self setModified. |
|
2370 |
] ifCurtailed:[ |
|
2371 |
self updateActivity:'Flood fill aborted.' |
|
2372 |
]. |
|
2373 |
]. |
|
2374 |
self updateActivity:'' |
|
2375 |
] |
|
2376 |
||
2377 |
"Modified: / 17-02-2017 / 15:30:38 / cg" |
|
2378 |
! |
|
2379 |
||
2380 |
filledBoxAt: aPoint |
|
2381 |
"called from button-press/button motion while in filled rectangle-drawing mode: |
|
2382 |
drag a filled box, |
|
2383 |
when released, fill a rectangular area with the currently selected color" |
|
2384 |
||
2385 |
self |
|
2386 |
commonBoxOperation:[:box :colorOrPixel | |
|
5594 | 2387 |
image fillRectangle:box with:colorOrPixel. |
5485 | 2388 |
] |
2389 |
at:aPoint |
|
2390 |
||
5594 | 2391 |
"Modified: / 05-09-2017 / 14:50:51 / cg" |
5485 | 2392 |
! |
2393 |
||
2394 |
filledCircleAt: aPoint |
|
2395 |
"called from button-press/button motion while in filled circle-drawing mode: |
|
2396 |
drag a filled ellipse, |
|
2397 |
when released, fill an ellipse with the currently selected color" |
|
2398 |
||
2399 |
self |
|
2400 |
commonBoxOperation:[:box :colorOrPixel | |
|
5653 | 2401 |
colorOrPixel isColor ifTrue:[ |
5485 | 2402 |
image fillEllipse:box withColor:colorOrPixel. |
2403 |
] ifFalse:[ |
|
2404 |
image fillEllipse:box withValue:colorOrPixel. |
|
2405 |
]. |
|
2406 |
] |
|
2407 |
at:aPoint |
|
2408 |
||
2409 |
"Created: / 16-02-2017 / 11:10:17 / cg" |
|
5653 | 2410 |
"Modified: / 07-12-2017 / 14:53:59 / cg" |
5485 | 2411 |
! |
2412 |
||
2413 |
maskOutsideCircleAt: aPoint |
|
2414 |
"called from button-press/button motion while in filled rectangle-drawing mode: |
|
2415 |
drag a box, |
|
2416 |
when released, mask everything outside the rectangular area" |
|
2417 |
||
2418 |
self |
|
2419 |
commonBoxOperation:[:box :colorOrPixel | |
|
2420 |
|newForm oldForm| |
|
2421 |
||
2422 |
newForm := Form extent:image extent depth:1 onDevice:Screen current. |
|
2423 |
newForm paint:(Color colorId:0). |
|
2424 |
newForm fillRectangle:(newForm bounds). |
|
2425 |
newForm paint:(Color colorId:1). |
|
2426 |
newForm fillCircleIn:box. |
|
2427 |
oldForm := image mask asFormOn:Screen current. |
|
2428 |
newForm function:#and. |
|
2429 |
newForm paint:(Color colorId:1) on:(Color colorId:0). |
|
2430 |
newForm copyFrom:oldForm x:0 y:0 toX:0 y:0 width:image width height:image height. |
|
2431 |
image mask:(ImageMask fromForm:newForm). |
|
2432 |
||
2433 |
"/ wrong: does not preserve already masked pixels... |
|
2434 |
"/ image mask fillRectangle:(image bounds) withValue:0. |
|
2435 |
"/ image mask fillEllipse:box withValue:1. |
|
2436 |
] |
|
2437 |
at:aPoint. |
|
2438 |
||
2439 |
image restored. |
|
2440 |
self invalidate. |
|
2441 |
||
2442 |
"Created: / 16-02-2017 / 12:33:25 / cg" |
|
2443 |
"Modified: / 17-02-2017 / 16:47:47 / cg" |
|
2444 |
! |
|
2445 |
||
2446 |
maskOutsideRectAt: aPoint |
|
2447 |
"called from button-press/button motion while in filled rectangle-drawing mode: |
|
2448 |
drag a box, |
|
2449 |
when released, mask everything outside the rectangular area" |
|
2450 |
||
2451 |
self |
|
2452 |
commonBoxOperation:[:box :colorOrPixel | |
|
2453 |
|newForm oldForm| |
|
2454 |
||
2455 |
newForm := Form extent:image extent depth:1 onDevice:Screen current. |
|
2456 |
newForm paint:(Color colorId:0). |
|
2457 |
newForm fillRectangle:(newForm bounds). |
|
2458 |
newForm paint:(Color colorId:1). |
|
2459 |
newForm fillRectangle:box. |
|
2460 |
oldForm := image mask asFormOn:Screen current. |
|
2461 |
newForm function:#and. |
|
2462 |
newForm paint:(Color colorId:1) on:(Color colorId:0). |
|
2463 |
newForm copyFrom:oldForm x:0 y:0 toX:0 y:0 width:image width height:image height. |
|
2464 |
image mask:(ImageMask fromForm:newForm). |
|
2465 |
||
2466 |
"/ wrong: does not preserve already masked pixels... |
|
2467 |
"/image mask fillRectangle:(image bounds) withValue:0. |
|
2468 |
"/image mask fillRectangle:box withValue:1. |
|
2469 |
] |
|
2470 |
at:aPoint. |
|
2471 |
||
2472 |
image restored. |
|
2473 |
self invalidate. |
|
2474 |
||
2475 |
"Created: / 16-02-2017 / 12:33:06 / cg" |
|
2476 |
"Modified: / 17-02-2017 / 17:23:57 / cg" |
|
2477 |
! |
|
2478 |
||
2479 |
pasteAt: aPoint |
|
2480 |
"called from button-press/button motion while in paste mode: |
|
2481 |
paste the image in the clipboard at aPoint" |
|
2482 |
||
2483 |
self pasteAt:aPoint mode:nil. |
|
2484 |
||
2485 |
"Modified (comment): / 16-02-2017 / 11:13:54 / cg" |
|
2486 |
! |
|
2487 |
||
5772 | 2488 |
pasteMaskedAt: aPoint |
2489 |
"called from button-press/button motion while in paste mode: |
|
2490 |
paste the image in the clipboard at aPoint. |
|
2491 |
In this mode, only pixels which are not masked in the source image |
|
2492 |
are pasted." |
|
2493 |
||
2494 |
self pasteAt:aPoint mode:#masked. |
|
2495 |
||
2496 |
"Created: / 27-05-2018 / 10:43:11 / Claus Gittinger" |
|
2497 |
! |
|
2498 |
||
5485 | 2499 |
pasteUnderAt: aPoint |
2500 |
"called from button-press/button motion while in paste mode: |
|
2501 |
pasteUnder the image in the clipboard at aPoint. |
|
2502 |
In this mode, only pixels which are not equal to |
|
2503 |
the current color or masked are pasted." |
|
2504 |
||
2505 |
self pasteAt:aPoint mode:#under. |
|
2506 |
||
2507 |
"Modified (comment): / 16-02-2017 / 11:14:04 / cg" |
|
2508 |
! |
|
2509 |
||
2510 |
pasteWithMaskAt: aPoint |
|
2511 |
"called from button-press/button motion while in paste mode: |
|
2512 |
paste the image in the clipboard at aPoint. |
|
2513 |
In this mode, both the mask and the image pixel are pasted" |
|
2514 |
||
2515 |
||
2516 |
self pasteAt:aPoint mode:#withMask. |
|
2517 |
||
2518 |
"Modified (comment): / 16-02-2017 / 11:14:08 / cg" |
|
2519 |
! |
|
2520 |
||
2521 |
pointAt:aPoint |
|
2522 |
"called from button-press/button motion while in point-drawing mode: |
|
2523 |
draw a single pixel with the currently selected color" |
|
2524 |
||
5652 | 2525 |
self pointAt:aPoint width:(self penWidth). |
5485 | 2526 |
|
2527 |
"Modified: / 15-02-2012 / 22:47:30 / cg" |
|
5652 | 2528 |
"Modified (format): / 07-12-2017 / 14:46:17 / cg" |
5485 | 2529 |
! |
2530 |
||
5604 | 2531 |
pointAt:aPoint width:pw |
2532 |
"called from button-press/button motion while in point-drawing mode: |
|
2533 |
draw a single pixel (or dot of width pw) with the currently selected color" |
|
2534 |
||
5921 | 2535 |
|draw imagePoint clr pix newColor| |
5604 | 2536 |
|
2537 |
imagePoint := aPoint // magnification. |
|
2538 |
(imagePoint x between:0 and:image width-1) ifFalse:[^ self]. |
|
2539 |
(imagePoint y between:0 and:image height-1) ifFalse:[^ self]. |
|
2540 |
||
2541 |
draw := |
|
2542 |
[:point | |
|
6150 | 2543 |
editMode == EditModePointBlend ifTrue:[ |
2544 |
(clr := self drawingColorOrNil) notNil ifTrue:[ |
|
2545 |
newColor := (image colorAt:point) blendWith:clr. |
|
2546 |
image colorAt:point put:newColor |
|
2547 |
] |
|
5604 | 2548 |
] ifFalse:[ |
6150 | 2549 |
(clr := self drawingColorOrNil) notNil ifTrue:[ |
2550 |
(clr isPseudoColor and:[image hasAlphaChannel]) ifTrue:[ |
|
2551 |
"/ only set the alpha value |
|
2552 |
newColor := (image colorAt:point) alpha:clr alpha. |
|
2553 |
] ifFalse:[ |
|
2554 |
newColor := clr. |
|
2555 |
"/ newColor alpha:clr alpha. |
|
2556 |
"/ clr alpha = 1 ifTrue:[ |
|
2557 |
"/ newColor := clr. |
|
2558 |
"/ ] ifFalse:[ |
|
2559 |
"/ clr alpha = 0 ifTrue:[ |
|
2560 |
"/ newColor := clr. |
|
2561 |
"/ ] ifFalse:[ |
|
2562 |
"/ oldColor := image colorAt:point. |
|
2563 |
"/ newColor := clr alphaMixed:clr alpha with:oldColor. |
|
2564 |
"/ ]. |
|
2565 |
"/ ]. |
|
2566 |
]. |
|
2567 |
image atImageAndMask:point put:newColor |
|
2568 |
] ifFalse:[ |
|
2569 |
"/ drawing with no color |
|
2570 |
pix := self drawingPixelOrNil. "/ nil is valid here, and means: masked |
|
2571 |
image atImageAndMask:point putValue:pix. |
|
2572 |
]. |
|
5604 | 2573 |
]. |
2574 |
self invalidate:((point * magnification extent: magnification) expandedBy:1). |
|
2575 |
]. |
|
2576 |
||
2577 |
draw value:imagePoint. |
|
2578 |
||
2579 |
pw > 1 ifTrue:[ |
|
2580 |
"/ draw with a wide pen |
|
2581 |
(pw//2) negated to:(pw-(pw//2)-1) do:[:xOffs | |
|
2582 |
(pw//2) negated to:(pw-(pw//2)-1) do:[:yOffs | |
|
2583 |
imagePoint x + xOffs >= 0 ifTrue:[ |
|
2584 |
imagePoint y + yOffs >= 0 ifTrue:[ |
|
2585 |
draw value:(imagePoint + (xOffs@yOffs)). |
|
2586 |
]. |
|
2587 |
]. |
|
2588 |
]. |
|
2589 |
]. |
|
2590 |
]. |
|
2591 |
self setModified. |
|
2592 |
||
2593 |
"Created: / 15-02-2012 / 22:47:08 / cg" |
|
5652 | 2594 |
"Modified: / 07-12-2017 / 14:49:48 / cg" |
5604 | 2595 |
! |
2596 |
||
6150 | 2597 |
pointBlendAt:aPoint |
2598 |
"called from button-press/button motion while in point-drawing mode: |
|
2599 |
blend a single pixel with the currently selected color" |
|
2600 |
||
2601 |
self pointAt:aPoint width:(self penWidth). |
|
2602 |
||
2603 |
"Modified: / 15-02-2012 / 22:47:30 / cg" |
|
2604 |
"Modified (format): / 07-12-2017 / 14:46:17 / cg" |
|
2605 |
! |
|
2606 |
||
4715 | 2607 |
smoothAt:aPoint |
5480 | 2608 |
"called from button-press/button motion while in smoothing mode: |
2609 |
smoth (average) a single pixel with pixels around" |
|
4715 | 2610 |
|
2611 |
|draw imagePoint x y w h| |
|
2612 |
||
2613 |
imagePoint := aPoint // magnification. |
|
2614 |
w := image width. |
|
2615 |
h := image height. |
|
2616 |
((x := imagePoint x) between:0 and:w-1) ifFalse:[^ self]. |
|
2617 |
((y := imagePoint y) between:0 and:h-1) ifFalse:[^ self]. |
|
2618 |
||
2619 |
draw := |
|
2620 |
[:point | |
|
2621 |
|sumRed sumGreen sumBlue newClr| |
|
2622 |
||
2623 |
sumRed := sumGreen := sumBlue := 0. |
|
2624 |
-1 to:1 do:[:dx | |
|
2625 |
-1 to:1 do:[:dy | |
|
2626 |
|clr| |
|
2627 |
||
2628 |
((x + dx) between:0 and:w-1) ifTrue:[ |
|
2629 |
((y + dy) between:0 and:h-1) ifTrue:[ |
|
2630 |
clr := image colorAtX:(x + dx) y:(y + dy). |
|
2631 |
sumRed := sumRed + clr redByte. |
|
2632 |
sumGreen := sumGreen + clr greenByte. |
|
2633 |
sumBlue := sumBlue + clr blueByte. |
|
2634 |
] |
|
2635 |
]. |
|
2636 |
] |
|
2637 |
]. |
|
2638 |
newClr := Color |
|
2639 |
redByte:(sumRed / 9) rounded |
|
2640 |
greenByte:(sumGreen / 9) rounded |
|
2641 |
blueByte:(sumBlue / 9) rounded. |
|
5480 | 2642 |
|
4715 | 2643 |
image colorMap isNil ifTrue:[ |
5480 | 2644 |
"/ Transcript |
2645 |
"/ show:(image colorAt:point); |
|
2646 |
"/ show:' -> '; |
|
2647 |
"/ showCR:newClr. |
|
4715 | 2648 |
image atImageAndMask:point put:newClr. |
2649 |
] ifFalse:[ |
|
2650 |
image atImageAndMask:point put:(image colorMap colorNearestTo:newClr). |
|
2651 |
]. |
|
2652 |
self invalidate:((point * magnification extent: magnification) expandedBy:1). |
|
2653 |
]. |
|
2654 |
||
2655 |
draw value:imagePoint. |
|
2656 |
self setModified. |
|
5480 | 2657 |
|
2658 |
"Modified: / 16-02-2017 / 12:34:41 / cg" |
|
4715 | 2659 |
! |
2660 |
||
1858 | 2661 |
specialOperationAt: aPoint |
2662 |
"special operation on a rectangular area" |
|
2663 |
||
5491 | 2664 |
|choosenBox operation imageBox| |
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
2665 |
|
5413 | 2666 |
choosenBox := self dragRectangleStartingAt: aPoint emphasis:#inverseFilledBox. |
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
2667 |
choosenBox isNil ifTrue:[ ^ self ]. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
2668 |
|
5491 | 2669 |
operation := self askForSpecialOperation. |
2670 |
operation isNil ifTrue:[^ self]. |
|
2671 |
||
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
2672 |
imageBox := choosenBox origin//magnification extent: (choosenBox extent//magnification). |
5491 | 2673 |
self specialOperation:operation on:imageBox withColor:self selectedColor. |
2674 |
||
2675 |
"Modified: / 20-02-2017 / 17:38:32 / cg" |
|
1858 | 2676 |
! |
2677 |
||
3476 | 2678 |
sprayAt: aPoint |
5480 | 2679 |
"called from button-press/button motion while in spray mode: |
2680 |
start spraying with the currently selected color" |
|
3476 | 2681 |
|
2682 |
|clr| |
|
2683 |
||
2684 |
(clr := self selectedColor) notNil ifTrue:[ |
|
2685 |
sprayPosition := aPoint. |
|
2686 |
self startSpray. |
|
2687 |
]. |
|
5480 | 2688 |
|
2689 |
"Modified (comment): / 16-02-2017 / 11:12:28 / cg" |
|
627 | 2690 |
! ! |
2691 |
||
2839 | 2692 |
!ImageEditView methodsFor:'image manipulation'! |
2693 |
||
2694 |
brightenImage |
|
5589 | 2695 |
"make the image brighter" |
2696 |
||
2697 |
image photometric == #palette ifTrue:[ |
|
2698 |
self makeNewColorMapByMapping:[:clr | clr lightened]. |
|
2699 |
] ifFalse:[ |
|
2700 |
self newImageWithUndo: (image copy lightened). |
|
2701 |
]. |
|
2702 |
||
2703 |
"Modified: / 31-08-2017 / 12:09:39 / cg" |
|
2839 | 2704 |
! |
2705 |
||
2706 |
darkenImage |
|
5589 | 2707 |
"make the image darker" |
2708 |
||
2709 |
image photometric == #palette ifTrue:[ |
|
2710 |
self makeNewColorMapByMapping:[:clr | clr darkened]. |
|
2711 |
] ifFalse:[ |
|
2712 |
self newImageWithUndo: (image copy darkened). |
|
2713 |
]. |
|
2714 |
||
2715 |
"Modified: / 31-08-2017 / 12:09:23 / cg" |
|
2839 | 2716 |
! |
2717 |
||
5920 | 2718 |
exchangeGreenBlueChannels |
2719 |
"exchange red and blue channels" |
|
2720 |
||
2721 |
|newImage w h| |
|
2722 |
||
2723 |
image colorMap notNil ifTrue:[ |
|
2724 |
Dialog information:'This operation cannot be applied to palette images.'. |
|
2725 |
^ self. |
|
2726 |
]. |
|
2727 |
||
2728 |
newImage := image copy. |
|
2729 |
||
2730 |
w := image width - 1. |
|
2731 |
h := image height - 1. |
|
2732 |
||
2733 |
0 to:h do:[:y | |
|
2734 |
0 to:w do:[:x | |
|
2735 |
|oldColor newColor| |
|
2736 |
||
2737 |
oldColor := (image colorAtX:x y:y). |
|
2738 |
newColor := Color redByte:(oldColor redByte) |
|
2739 |
greenByte:(oldColor blueByte) |
|
2740 |
blueByte:(oldColor greenByte) |
|
2741 |
alphaByte:(oldColor alphaByte). |
|
2742 |
newImage colorAtX:x y:y put:newColor |
|
2743 |
] |
|
2744 |
]. |
|
2745 |
self newImageWithUndo:newImage. |
|
2746 |
! |
|
2747 |
||
2748 |
exchangeRedBlueChannels |
|
2749 |
"exchange red and blue channels" |
|
2750 |
||
2751 |
|newImage w h| |
|
2752 |
||
2753 |
image colorMap notNil ifTrue:[ |
|
2754 |
Dialog information:'This operation cannot be applied to palette images.'. |
|
2755 |
^ self. |
|
2756 |
]. |
|
2757 |
||
2758 |
newImage := image copy. |
|
2759 |
||
2760 |
w := image width - 1. |
|
2761 |
h := image height - 1. |
|
2762 |
||
2763 |
0 to:h do:[:y | |
|
2764 |
0 to:w do:[:x | |
|
2765 |
|oldColor newColor| |
|
2766 |
||
2767 |
oldColor := (image colorAtX:x y:y). |
|
2768 |
newColor := Color redByte:(oldColor blueByte) |
|
2769 |
greenByte:(oldColor greenByte) |
|
2770 |
blueByte:(oldColor redByte) |
|
2771 |
alphaByte:(oldColor alphaByte). |
|
2772 |
newImage colorAtX:x y:y put:newColor |
|
2773 |
] |
|
2774 |
]. |
|
2775 |
self newImageWithUndo:newImage. |
|
2776 |
! |
|
2777 |
||
2778 |
exchangeRedGreenChannels |
|
2779 |
"exchange red and green channels" |
|
2780 |
||
2781 |
|newImage w h| |
|
2782 |
||
2783 |
image colorMap notNil ifTrue:[ |
|
2784 |
Dialog information:'This operation cannot be applied to palette images.'. |
|
2785 |
^ self. |
|
2786 |
]. |
|
2787 |
||
2788 |
newImage := image copy. |
|
2789 |
||
2790 |
w := image width - 1. |
|
2791 |
h := image height - 1. |
|
2792 |
||
2793 |
0 to:h do:[:y | |
|
2794 |
0 to:w do:[:x | |
|
2795 |
|oldColor newColor| |
|
2796 |
||
2797 |
oldColor := (image colorAtX:x y:y). |
|
2798 |
newColor := Color redByte:(oldColor greenByte) |
|
2799 |
greenByte:(oldColor redByte) |
|
2800 |
blueByte:(oldColor blueByte) |
|
2801 |
alphaByte:(oldColor alphaByte). |
|
2802 |
newImage colorAtX:x y:y put:newColor |
|
2803 |
] |
|
2804 |
]. |
|
2805 |
self newImageWithUndo:newImage. |
|
2806 |
! |
|
2807 |
||
2839 | 2808 |
flipHorizontal |
2809 |
||
5589 | 2810 |
self newImageWithUndo:(image copy flipHorizontal). |
2811 |
||
2812 |
"Modified (format): / 31-08-2017 / 12:13:03 / cg" |
|
2839 | 2813 |
! |
2814 |
||
2815 |
flipVertical |
|
5589 | 2816 |
self newImageWithUndo:(image copy flipVertical). |
2817 |
||
2818 |
"Modified: / 31-08-2017 / 12:13:11 / cg" |
|
2839 | 2819 |
! |
2820 |
||
2821 |
makeBorderedImageX:newX y:newY width:newWidth height:newHeight |
|
2822 |
|newImage oldWidth oldHeight| |
|
2823 |
||
2824 |
oldWidth := image width. |
|
2825 |
oldHeight := image height. |
|
2826 |
||
2827 |
newImage := image class width:newWidth height:newHeight depth:image depth. |
|
2828 |
newImage photometric:image photometric. |
|
2829 |
newImage colorMap:image colorMap copy. |
|
2830 |
newImage bits:(ByteArray new:(newImage bytesPerRow * newHeight)). |
|
2831 |
||
2842 | 2832 |
image mask notNil ifTrue:[ |
2839 | 2833 |
|newMaskImage| |
2834 |
||
2835 |
newMaskImage := Depth1Image width:newWidth height:newHeight. |
|
2836 |
newMaskImage photometric: image mask photometric. |
|
2837 |
newMaskImage colorMap: image mask colorMap copy. |
|
2838 |
newMaskImage bits:(ByteArray new: newMaskImage bytesPerRow * newHeight). |
|
2839 |
newImage mask: newMaskImage |
|
2840 |
]. |
|
2841 |
||
2842 |
newImage copyFrom:image x:0 y:0 toX:newX y:newY width:oldWidth height:oldHeight. |
|
4730 | 2843 |
self newImageWithUndo:newImage. |
2839 | 2844 |
|
2845 |
"Created: / 7.9.1998 / 13:00:16 / cg" |
|
2846 |
"Modified: / 7.9.1998 / 14:15:32 / cg" |
|
2847 |
! |
|
2848 |
||
2849 |
makeBrighter |
|
5589 | 2850 |
"make the image brighter (obsolete, backward compatible entry)" |
2851 |
||
2852 |
self brightenImage |
|
2853 |
||
2854 |
"Modified: / 31-08-2017 / 12:12:38 / cg" |
|
2839 | 2855 |
! |
2856 |
||
2857 |
makeDarker |
|
5589 | 2858 |
"make the image darker (obsolete, backward compatible entry)" |
2859 |
||
2860 |
self darkenImage |
|
2861 |
||
2862 |
"Modified: / 31-08-2017 / 12:12:41 / cg" |
|
2839 | 2863 |
! |
2864 |
||
2841 | 2865 |
makeGrayScaleImage |
5589 | 2866 |
self makeNewColorMapByMapping: |
4730 | 2867 |
[:clr | Color brightness:(clr brightness)]. |
5589 | 2868 |
|
2869 |
"Modified: / 31-08-2017 / 12:12:30 / cg" |
|
2839 | 2870 |
! |
2871 |
||
2872 |
makeInverse |
|
5589 | 2873 |
self makeNewColorMapByMapping: |
4730 | 2874 |
[:clr | |
5589 | 2875 |
Color |
2876 |
redByte:(255-clr redByte) |
|
2877 |
greenByte:(255-clr greenByte) |
|
2878 |
blueByte:(255-clr blueByte) |
|
4730 | 2879 |
]. |
5589 | 2880 |
|
2881 |
"Modified: / 31-08-2017 / 12:47:20 / cg" |
|
2882 |
! |
|
2883 |
||
2884 |
makeInvertedBits |
|
2885 |
"invert the pixels |
|
2886 |
for palette images, this will lead to funny results; |
|
2887 |
for all others, this makes it a negative" |
|
2888 |
||
2889 |
|newImage| |
|
2890 |
||
2891 |
newImage := image copy. |
|
2892 |
newImage bits invert. |
|
2893 |
self newImageWithUndo:newImage. |
|
2894 |
||
2895 |
"Created: / 31-08-2017 / 12:48:33 / cg" |
|
2896 |
"Modified (comment): / 31-08-2017 / 14:02:28 / cg" |
|
2897 |
! |
|
2898 |
||
2899 |
makeNegative |
|
2900 |
"make a real negative. |
|
2901 |
For non-palette images, this is done by inverting the pixels; |
|
2902 |
for palette images, we need new colors." |
|
2903 |
||
2904 |
image photometric ~~ #palette ifTrue:[ |
|
2905 |
self makeInvertedBits. |
|
2906 |
^ self. |
|
2907 |
]. |
|
2908 |
||
2909 |
self makeNewColorMapByMapping: |
|
2910 |
[:clr | |
|
2911 |
Color |
|
2912 |
redByte:(255-clr redByte) |
|
2913 |
greenByte:(255-clr greenByte) |
|
2914 |
blueByte:(255-clr blueByte) |
|
2915 |
]. |
|
2916 |
||
2917 |
"Created: / 31-08-2017 / 13:50:39 / cg" |
|
2839 | 2918 |
! |
2919 |
||
3971 | 2920 |
makeSlightlyBrighter |
5589 | 2921 |
self makeNewColorMapByMapping: |
4730 | 2922 |
[:clr | |
2923 |
clr brightness > Color lightGray brightness |
|
5163 | 2924 |
ifTrue:[ clr blendWith:self whiteColor ] |
4730 | 2925 |
ifFalse:[ clr blendWith:Color lightGray ] |
2926 |
]. |
|
3971 | 2927 |
|
2928 |
"Created: / 24-11-2010 / 11:08:18 / cg" |
|
5589 | 2929 |
"Modified: / 31-08-2017 / 12:11:34 / cg" |
3971 | 2930 |
! |
2931 |
||
2932 |
makeSlightlyDarker |
|
5589 | 2933 |
self makeNewColorMapByMapping: |
4730 | 2934 |
[:clr | |
2935 |
clr brightness < Color darkGray brightness |
|
2936 |
ifTrue:[ clr blendWith:Color black ] |
|
2937 |
ifFalse:[ clr blendWith:Color darkGray ] |
|
2938 |
]. |
|
3971 | 2939 |
|
2940 |
"Created: / 24-11-2010 / 11:08:08 / cg" |
|
5589 | 2941 |
"Modified: / 31-08-2017 / 12:11:39 / cg" |
3971 | 2942 |
! |
2943 |
||
4730 | 2944 |
newImageWithUndo:newImage |
5589 | 2945 |
"undoable set a new image (after processing)" |
2946 |
||
2839 | 2947 |
self makeUndo. |
4730 | 2948 |
self image: newImage. |
2839 | 2949 |
self setModified. |
5589 | 2950 |
|
2951 |
"Modified (comment): / 31-08-2017 / 12:09:11 / cg" |
|
2839 | 2952 |
! |
2953 |
||
5491 | 2954 |
performSpecialOperation:operation on:imageBox withColor:clr |
2955 |
"actually perform one of the special operations on the previously selected imageBox" |
|
2956 |
||
2957 |
|x0 y0 x1 y1 pixelAction requiredColors missingColors answer hue| |
|
2958 |
||
2959 |
x0 := imageBox left. |
|
2960 |
y0 := imageBox top. |
|
2961 |
x1 := imageBox right - 1. |
|
2962 |
y1 := imageBox bottom -1 . |
|
2963 |
||
2964 |
operation == #edit ifTrue:[ |
|
2965 |
(self image subImageIn:imageBox) edit. |
|
2966 |
^ false. |
|
2967 |
]. |
|
2968 |
operation == #editSubImage ifTrue:[ |
|
2969 |
self makeUndo. |
|
2970 |
self image:(self image subImageIn:imageBox). |
|
2971 |
^ false. |
|
2972 |
]. |
|
2973 |
operation == #flipVertical ifTrue:[ |
|
2974 |
self flipSubImage:#vertical in:imageBox. |
|
2975 |
^ true. |
|
2976 |
]. |
|
2977 |
operation == #flipHorizontal ifTrue:[ |
|
2978 |
self flipSubImage:#horizontal in:imageBox. |
|
2979 |
^ true. |
|
2980 |
]. |
|
5497 | 2981 |
operation == #autoGradientFillVertical ifTrue:[ |
2982 |
self gradientFillIn:imageBox orientation:#vertical auto:true. |
|
2983 |
^ true. |
|
2984 |
]. |
|
2985 |
operation == #autoGradientFillHorizontal ifTrue:[ |
|
2986 |
self gradientFillIn:imageBox orientation:#horizontal auto:true. |
|
2987 |
^ true. |
|
2988 |
]. |
|
2989 |
operation == #autoGradientFillDiagonal ifTrue:[ |
|
2990 |
self gradientFillIn:imageBox orientation:#diagonal auto:true. |
|
2991 |
^ true. |
|
2992 |
]. |
|
2993 |
operation == #gradientFillVertical ifTrue:[ |
|
2994 |
self gradientFillIn:imageBox orientation:#vertical auto:false. |
|
2995 |
^ true. |
|
2996 |
]. |
|
2997 |
operation == #gradientFillHorizontal ifTrue:[ |
|
2998 |
self gradientFillIn:imageBox orientation:#horizontal auto:false. |
|
2999 |
^ true. |
|
3000 |
]. |
|
3001 |
operation == #gradientFillDiagonal ifTrue:[ |
|
3002 |
self gradientFillIn:imageBox orientation:#diagonal auto:false. |
|
3003 |
^ true. |
|
3004 |
]. |
|
5491 | 3005 |
|
3006 |
operation == #slightlyBrightened ifTrue:[ |
|
3007 |
pixelAction := [:x :y :clr | clr slightlyLightened]. |
|
3008 |
]. |
|
3009 |
operation == #slightlyDarkened ifTrue:[ |
|
3010 |
pixelAction := [:x :y :clr | clr slightlyDarkened]. |
|
3011 |
]. |
|
3012 |
operation == #brightened ifTrue:[ |
|
3013 |
pixelAction := [:x :y :clr | clr lightened]. |
|
3014 |
]. |
|
3015 |
operation == #darkened ifTrue:[ |
|
3016 |
pixelAction := [:x :y :clr | clr darkened]. |
|
3017 |
]. |
|
3018 |
operation == #reversed ifTrue:[ |
|
3019 |
pixelAction := [:x :y :clr | Color red:(100-clr red) green:(100-clr green) blue:(100-clr blue) ]. |
|
3020 |
]. |
|
3021 |
operation == #makeGrey ifTrue:[ |
|
3022 |
pixelAction := [:x :y :clr | Color grey:(clr greyIntensity)]. |
|
3023 |
]. |
|
3024 |
operation == #greyed ifTrue:[ |
|
3025 |
pixelAction := [:x :y :clr | clr blendWith:Color gray]. |
|
3026 |
]. |
|
3027 |
operation == #greyPattern ifTrue:[ |
|
3028 |
pixelAction := [:x :y :clr | x odd == y even |
|
3029 |
ifTrue:[Color gray] |
|
3030 |
ifFalse:[clr]]. |
|
3031 |
]. |
|
3032 |
operation == #unmaskedGreyPattern ifTrue:[ |
|
3033 |
pixelAction := [:x :y :clr | x odd == y even |
|
3034 |
ifTrue:[self image maskAtX:x y:y put:1. Color gray] |
|
3035 |
ifFalse:[clr]]. |
|
3036 |
]. |
|
3037 |
||
3038 |
operation == #changeHue ifTrue:[ |
|
3039 |
hue := Dialog request:'Hue (0..360)\red->yellow->green->blue->red' withCRs. |
|
3040 |
hue := Number readFrom:hue onError:nil. |
|
3041 |
hue isNil ifTrue:[^ false]. |
|
3042 |
pixelAction := [:x :y :clr | Color hue:(hue+(clr hue?0)) light:clr light saturation:clr saturation]. |
|
3043 |
]. |
|
3044 |
operation == #colorize ifTrue:[ |
|
3045 |
hue := Dialog request:'Hue (0..360)\red->yellow->green->blue->red' withCRs. |
|
3046 |
hue := Number readFrom:hue onError:nil. |
|
3047 |
hue isNil ifTrue:[^ false]. |
|
3048 |
pixelAction := [:x :y :clr | Color hue:hue light:clr light saturation:100] |
|
3049 |
]. |
|
3050 |
||
3051 |
pixelAction isNil ifTrue:[ |
|
5497 | 3052 |
Dialog warn:(resources string:'Sorry - unimplemented pixelAction: ',operation asString). |
5491 | 3053 |
^ false |
3054 |
]. |
|
3055 |
||
3056 |
image colorMap notNil ifTrue:[ |
|
3057 |
"/ compute required colors ... |
|
3058 |
requiredColors := Set new. |
|
3059 |
self image |
|
3060 |
colorsFromX:x0 y:y0 toX:x1 y:y1 |
|
3061 |
do:[:x :y :clr | |
|
3062 |
requiredColors add:(pixelAction value:x value:y value:clr) |
|
3063 |
]. |
|
3064 |
||
3065 |
missingColors := requiredColors reject:[:clr | (image colorMap includes:clr)]. |
|
3066 |
||
3067 |
missingColors notEmpty ifTrue:[ |
|
3068 |
answer := Dialog |
|
3069 |
confirmWithCancel:(resources stringWithCRs:'Some color(s) cannot be represented in the images colorMap.\Use nearest or compute colorMap ?') |
|
3070 |
labels:#( 'Cancel' 'Add to ColorMap' 'Use Nearest') |
|
3071 |
values:#( nil add nearest) |
|
3072 |
default:3. |
|
3073 |
answer isNil ifTrue:[^ false]. |
|
3074 |
answer == #add ifTrue:[ |
|
3075 |
missingColors size + image colorMap size > (2 raisedTo:image depth) ifTrue:[ |
|
3076 |
self warn:(resources string:'Missing colors cannot be added to images colormap.'). |
|
3077 |
^ false |
|
3078 |
]. |
|
3079 |
missingColors do:[:eachColor | |
|
3080 |
image colorMap add:eachColor |
|
3081 |
]. |
|
3082 |
answer := #nearest. |
|
3083 |
]. |
|
3084 |
]. |
|
3085 |
]. |
|
3086 |
||
3087 |
"/ now, do it |
|
3088 |
self image |
|
3089 |
colorsFromX:x0 y:y0 toX:x1 y:y1 |
|
3090 |
do:[:x :y :clr | |
|
3091 |
|newClr| |
|
3092 |
||
3093 |
newClr := pixelAction value:x value:y value:clr. |
|
3094 |
answer == #nearest ifTrue:[ |
|
3095 |
newClr := newClr nearestIn:image colorMap |
|
3096 |
]. |
|
3097 |
self image colorAtX:x y:y put:newClr |
|
3098 |
]. |
|
3099 |
||
3100 |
self setModified. |
|
3101 |
^ true. |
|
3102 |
||
3103 |
"Created: / 20-02-2017 / 17:30:00 / cg" |
|
5497 | 3104 |
"Modified: / 22-02-2017 / 20:56:51 / cg" |
5491 | 3105 |
! |
3106 |
||
2839 | 3107 |
reduceColorResolutionBy:numBits |
5871 | 3108 |
"reduce by masking off numBits r/g/b bits" |
3109 |
||
2839 | 3110 |
|newImage| |
3111 |
||
3112 |
numBits > 7 ifTrue:[ |
|
5061 | 3113 |
self warn:(resources string:'Max. number of bits to strip off is 7.'). |
2839 | 3114 |
^ false |
3115 |
]. |
|
3116 |
newImage := image withColorResolutionReducedBy:numBits. |
|
3117 |
newImage isNil ifTrue:[ |
|
5061 | 3118 |
self warn:(resources string:'Could not reduce color resolution.'). |
2839 | 3119 |
^ false. |
3120 |
]. |
|
3121 |
||
4730 | 3122 |
self newImageWithUndo:newImage. |
2839 | 3123 |
^ true |
5871 | 3124 |
|
3125 |
"Modified (comment): / 06-08-2018 / 00:45:42 / Claus Gittinger" |
|
2839 | 3126 |
! |
3127 |
||
3128 |
resizeImageTo:newSize |
|
4730 | 3129 |
self newImageWithUndo: (self resizedImage:image to:newSize). |
3130 |
! |
|
3131 |
||
3132 |
resizedImage:image to:newSize |
|
3133 |
"helper for image resize and mask resize. |
|
3134 |
return a resized version of image" |
|
2839 | 3135 |
|
3136 |
|newImage newMaskImage| |
|
3137 |
||
3138 |
newImage := image class width: newSize x height: newSize y depth: image depth. |
|
3139 |
newImage photometric:image photometric. |
|
3140 |
newImage colorMap:image colorMap copy. |
|
3141 |
newImage bits: (ByteArray new: newImage bytesPerRow * newSize y). |
|
3142 |
||
3143 |
image mask notNil ifTrue:[ |
|
3144 |
newMaskImage := Depth1Image width: newSize x height: newSize y. |
|
3145 |
newMaskImage photometric: image mask photometric. |
|
3146 |
newMaskImage colorMap: image mask colorMap copy. |
|
3147 |
newMaskImage bits:(ByteArray new: newMaskImage bytesPerRow * newSize y). |
|
3148 |
newImage mask: newMaskImage |
|
3149 |
]. |
|
3150 |
||
3151 |
newImage copyFrom:image x:0 y:0 toX:0 y:0 width: (image width min:newSize x) height: (image height min:newSize y). |
|
4730 | 3152 |
^ newImage. |
2839 | 3153 |
! |
3154 |
||
3155 |
rotateImageBy:rotation |
|
3156 |
"rotate by (degrees)" |
|
3157 |
||
4212 | 3158 |
Error handle:[:ex| |
3435
400079196849
3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents:
3319
diff
changeset
|
3159 |
self warn: 'Image rotation failed!!\' withCRs, 'Increasing the image depth could help.' |
2839 | 3160 |
] do:[ |
4730 | 3161 |
self newImageWithUndo: (image hardRotated: rotation). |
2839 | 3162 |
] |
3163 |
||
3164 |
"Modified: / 29.7.1998 / 18:21:14 / cg" |
|
3435
400079196849
3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents:
3319
diff
changeset
|
3165 |
! |
400079196849
3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents:
3319
diff
changeset
|
3166 |
|
400079196849
3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents:
3319
diff
changeset
|
3167 |
threeDProjection:dx1 and:dx2 |
400079196849
3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents:
3319
diff
changeset
|
3168 |
"3D projection" |
400079196849
3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents:
3319
diff
changeset
|
3169 |
|
4212 | 3170 |
Error handle:[:ex| |
3435
400079196849
3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents:
3319
diff
changeset
|
3171 |
self warn: 'Image projection failed!!\' withCRs, 'Increasing the image depth could help.' |
400079196849
3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents:
3319
diff
changeset
|
3172 |
] do:[ |
4730 | 3173 |
self newImageWithUndo:(image threeDProjected:dx1 and:dx2) |
3435
400079196849
3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents:
3319
diff
changeset
|
3174 |
] |
400079196849
3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents:
3319
diff
changeset
|
3175 |
|
400079196849
3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents:
3319
diff
changeset
|
3176 |
"Modified: / 29.7.1998 / 18:21:14 / cg" |
2839 | 3177 |
! ! |
3178 |
||
2511 | 3179 |
!ImageEditView methodsFor:'image-dragging & info'! |
3180 |
||
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
3181 |
dragRectangleStartingAt:aPointIn emphasis:emphasis |
5413 | 3182 |
"draw a drag rectangle (filled or unfilled, depending on the emphasis arg). |
3183 |
This is called by operation like |
|
3184 |
rectangle, filledRectangle, copy etc. |
|
3185 |
(i.e. any operation which operates on a box). |
|
5695 | 3186 |
The cpu stays in this method dragging the mouse pointer, |
3187 |
until the button is released. |
|
3188 |
||
3189 |
Emphasis is one of: |
|
5413 | 3190 |
box - a frame is drawn |
3191 |
inverseFilledBox - the dragged box is filled by the inverse color |
|
3192 |
filledBox - the dragged box is filled with black |
|
3193 |
grayedBox - the dragged box is drawn with a gray shadow |
|
3194 |
" |
|
2511 | 3195 |
|
3196 |
|currentPoint currentExtent firstPoint lastCurrentPoint gridCorrection |
|
5413 | 3197 |
mp lastMp p whichQuarter scrollX scrollY aPoint sensor| |
2511 | 3198 |
|
3199 |
aPoint := aPointIn. |
|
3200 |
firstPoint := currentPoint := lastCurrentPoint := aPoint//magnification*magnification. |
|
3201 |
magnification >= GridMagnificationLimit ifFalse: [gridCorrection := 0] ifTrue: [gridCorrection := 1]. |
|
3202 |
||
5695 | 3203 |
"/ polling loop here... |
5413 | 3204 |
sensor := self sensor. |
3205 |
[sensor anyButtonPressed] whileTrue: [ |
|
3206 |
(sensor hasKeyEventFor:nil) ifTrue:[ |
|
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
3207 |
self invalidate. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
3208 |
^ nil. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
3209 |
]. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
3210 |
|
5413 | 3211 |
mp := sensor mousePoint. |
2511 | 3212 |
mp = lastMp ifTrue:[ |
3213 |
Delay waitForSeconds:0.05 |
|
3214 |
] ifFalse:[ |
|
3215 |
lastMp := mp. |
|
4999 | 3216 |
mp := device translatePoint:mp fromView:nil toView:self. |
2511 | 3217 |
"/ mp is a device coordinate here ... |
3218 |
scrollX := 0. |
|
3219 |
mp x > width ifTrue:[ |
|
3220 |
scrollX := mp x - width. |
|
3221 |
] ifFalse:[ |
|
3222 |
mp x < 0 ifTrue:[ |
|
3223 |
scrollX := mp x. |
|
3224 |
] |
|
3225 |
]. |
|
3226 |
scrollY := 0. |
|
3227 |
mp y > height ifTrue:[ |
|
3228 |
scrollY := mp y - height. |
|
3229 |
] ifFalse:[ |
|
3230 |
mp y < 0 ifTrue:[ |
|
3231 |
scrollY := mp y. |
|
3232 |
] |
|
3233 |
]. |
|
3234 |
(scrollX + scrollY) ~~ 0 ifTrue:[ |
|
3235 |
self scrollTo:(self viewOrigin + (scrollX @ scrollY)). |
|
3236 |
lastMp := nil. |
|
3237 |
]. |
|
3238 |
||
3239 |
mp := mp + self viewOrigin. |
|
3240 |
"/ mp is now a logical coordinate. |
|
3241 |
||
3242 |
currentPoint := (0@0) max: (image extent * magnification min: (p := mp)). |
|
3243 |
currentPoint := currentPoint//magnification*magnification. |
|
5593 | 3244 |
|
2511 | 3245 |
currentExtent := (firstPoint - currentPoint) abs. |
3246 |
whichQuarter := (firstPoint x - currentPoint x) > 0 |
|
3247 |
ifTrue: [(firstPoint y - currentPoint y) > 0 ifTrue: ["4"1@1] ifFalse: ["3"1@0]] |
|
3248 |
ifFalse: [(firstPoint y - currentPoint y) > 0 ifTrue: ["1"0@1] ifFalse: ["2"0@0]]. |
|
3249 |
||
5413 | 3250 |
self showCursorAt: p andInformation: |
2511 | 3251 |
((firstPoint//magnification - whichQuarter + 1) printString, |
3252 |
' to: ', |
|
3253 |
(currentPoint//magnification + whichQuarter) printString), |
|
3254 |
' (extent: ', |
|
3255 |
(currentExtent//magnification) printString, ')'. |
|
3256 |
||
5413 | 3257 |
currentPoint ~= lastCurrentPoint ifTrue:[ |
3258 |
||
3259 |
emphasis == #grayedBox ifTrue:[ |
|
3260 |
"/ does not yet work |
|
3261 |
|org ext| |
|
3262 |
||
3263 |
"/ org := (firstPoint min: lastCurrentPoint) - 1. |
|
3264 |
"/ ext := (firstPoint - lastCurrentPoint) abs + 2. |
|
3265 |
||
3266 |
(lastCurrentPoint x > currentPoint x |
|
3267 |
or:[ (lastCurrentPoint y > currentPoint y) ] |
|
3268 |
) ifTrue:[ |
|
3269 |
self |
|
3270 |
redrawImageX:firstPoint x"-1" y:firstPoint y"-1" |
|
3271 |
width:(lastCurrentPoint x-firstPoint x"+2") height:(lastCurrentPoint y-firstPoint y"+2") |
|
3272 |
unmaskedOnly:false processColorsWith:[:clr | clr ]. |
|
3273 |
"/ self drawFramesIn:(firstPoint corner:lastCurrentPoint). |
|
3274 |
]. |
|
3275 |
||
3276 |
self |
|
3277 |
redrawImageX:firstPoint x"-1" y:firstPoint y"-1 " |
|
3278 |
width:(currentPoint x-firstPoint x"+2") height:(currentPoint y-firstPoint y"+2") |
|
3279 |
unmaskedOnly:true processColorsWith:[:clr | Color gray: clr grayIntensity / 2 ]. |
|
3280 |
]. |
|
3281 |
||
3282 |
emphasis == #inverseFilledBox ifTrue: [ |
|
5414 | 3283 |
|union invertOutside| |
3284 |
||
3285 |
invertOutside := false. |
|
3286 |
"/ union := (firstPoint corner:currentPoint) merge:(firstPoint corner:lastCurrentPoint). |
|
3287 |
"/ ((lastCurrentPoint x > currentPoint x) |
|
3288 |
"/ and:[ lastCurrentPoint y > currentPoint y ]) ifTrue:[ |
|
3289 |
"/ "/ a real shrink |
|
3290 |
"/ invertOutside := true. |
|
3291 |
"/ self xoring: [ |
|
3292 |
"/ union areasOutside:(firstPoint corner:lastCurrentPoint) do:[:r | |
|
3293 |
"/ self fillRectangle: ((firstPoint min: currentPoint) + margin extent: currentExtent - gridCorrection) |
|
3294 |
"/ ] |
|
3295 |
"/ ] |
|
3296 |
"/ ] ifFalse:[ |
|
3297 |
"/ ((currentPoint x > lastCurrentPoint x) |
|
3298 |
"/ and:[ currentPoint y > lastCurrentPoint y ]) ifTrue:[ |
|
3299 |
"/ "/ a real grow |
|
3300 |
"/ invertOutside := true. |
|
3301 |
"/ self xoring: [ |
|
3302 |
"/ union areasOutside:(firstPoint corner:currentPoint) do:[:r | |
|
3303 |
"/ self fillRectangle: ((firstPoint min: currentPoint) + margin extent: currentExtent - gridCorrection) |
|
3304 |
"/ ] |
|
3305 |
"/ ] |
|
3306 |
"/ ]. |
|
3307 |
"/ ]. |
|
3308 |
invertOutside ifFalse:[ |
|
3309 |
self redraw: ((firstPoint min: lastCurrentPoint) - 1 extent: (firstPoint - lastCurrentPoint) abs + 2). |
|
5432 | 3310 |
gc xoring: [ |
3311 |
gc fillRectangle: ((firstPoint min: currentPoint) + margin extent: currentExtent - gridCorrection) |
|
5414 | 3312 |
] |
3313 |
]. |
|
2511 | 3314 |
]. |
5413 | 3315 |
|
3316 |
emphasis == #box ifTrue:[ |
|
2511 | 3317 |
|origin extent lineWidthY lineWidthX| |
5413 | 3318 |
|
2511 | 3319 |
origin := (firstPoint min: lastCurrentPoint) - 1. |
3320 |
extent := (firstPoint - lastCurrentPoint) abs + 2. |
|
3321 |
lineWidthY := extent y min: (magnification y + 2). |
|
3322 |
lineWidthX := extent x min: (magnification x + 2). |
|
3323 |
self redraw: (origin extent: (extent x@lineWidthY)). |
|
3324 |
self redraw: ((origin x@(origin y + extent y - lineWidthY)) extent: (extent x@lineWidthY)). |
|
3325 |
self redraw: ((origin x@(origin y + lineWidthY)) extent: (lineWidthX@(0 max: (extent y - (lineWidthY * 2))))). |
|
3326 |
self redraw: (((origin x + extent x - lineWidthX)@(origin y + lineWidthY)) extent: (lineWidthX@(extent y - (lineWidthY * 2)))). |
|
5413 | 3327 |
(self selectedColor ~= Color noColor) |
5432 | 3328 |
ifTrue: [gc paint: self selectedColor] |
3329 |
ifFalse: [gc paint: self viewBackground]. |
|
2511 | 3330 |
origin := (firstPoint min: currentPoint) + margin. |
3331 |
extent := currentExtent - gridCorrection. |
|
3332 |
lineWidthY := extent y min: magnification y. |
|
3333 |
lineWidthX := extent x min: magnification x. |
|
5413 | 3334 |
(lineWidthY > 0 and: [lineWidthX > 0]) ifTrue:[ |
5432 | 3335 |
gc fillRectangle: (origin extent: (extent x@lineWidthY)). |
3336 |
gc fillRectangle: ((origin x@(origin y + extent y - lineWidthY)) extent: (extent x@lineWidthY)). |
|
3337 |
gc fillRectangle: ((origin x@(origin y + lineWidthY)) extent: (lineWidthX@(0 max: (extent y - (lineWidthY * 2))))). |
|
3338 |
gc fillRectangle: (((origin x + extent x - lineWidthX)@(origin y + lineWidthY)) extent: (lineWidthX@(extent y - (lineWidthY * 2)))). |
|
2511 | 3339 |
] |
3340 |
]. |
|
5413 | 3341 |
|
3342 |
emphasis == #filledBox ifTrue:[ |
|
2511 | 3343 |
self redraw: ((firstPoint min: lastCurrentPoint) - 1 extent: (firstPoint - lastCurrentPoint) abs + 2). |
5413 | 3344 |
(self selectedColor ~= Color noColor) |
5432 | 3345 |
ifTrue: [gc paint: self selectedColor] |
3346 |
ifFalse: [gc paint: self viewBackground]. |
|
3347 |
gc fillRectangle: ((firstPoint min: currentPoint) + margin extent: currentExtent - gridCorrection). |
|
2511 | 3348 |
]. |
3349 |
]. |
|
3350 |
lastCurrentPoint := currentPoint. |
|
3351 |
]. |
|
3352 |
]. |
|
3353 |
||
3354 |
^((0@0) max: (firstPoint min: currentPoint)) extent: (firstPoint - currentPoint) abs |
|
3355 |
||
5593 | 3356 |
"Created: / 21-08-1998 / 20:17:07 / cg" |
3357 |
"Modified: / 10-10-2001 / 14:13:08 / cg" |
|
3358 |
"Modified (format): / 04-09-2017 / 18:26:06 / cg" |
|
2511 | 3359 |
! |
3360 |
||
3361 |
drawCursorAt:aPoint |
|
5481 | 3362 |
"the mouse was moved to aPoint (in the image). |
3363 |
Update the info (showing rgb + other info) in the lower info bar. |
|
3364 |
Also changes the cursor to a stop-cursor, if outside the image" |
|
3365 |
||
5413 | 3366 |
|imgPoint shownCursor| |
2511 | 3367 |
|
4041 | 3368 |
readOnly ifTrue:[^ self]. |
2511 | 3369 |
image isNil ifTrue: [ |
5481 | 3370 |
self updateImageInfo:(self imageInfoString). |
2511 | 3371 |
self cursor:Cursor stop. |
3372 |
^ self |
|
3373 |
]. |
|
3374 |
||
3375 |
imgPoint := aPoint // magnification. |
|
3376 |
((imgPoint x between:0 and:(image width-1)) |
|
5413 | 3377 |
and:[imgPoint y between:0 and: (image height-1)] |
3378 |
) ifFalse:[ |
|
5481 | 3379 |
self updateImageInfo:(self imageInfoString). |
5413 | 3380 |
shownCursor := Cursor stop. |
2511 | 3381 |
] ifTrue: [ |
3729 | 3382 |
self updateImageInfoFor:imgPoint. |
5413 | 3383 |
shownCursor := Cursor crossHair |
2511 | 3384 |
]. |
5413 | 3385 |
self cursor:shownCursor. |
2511 | 3386 |
|
4041 | 3387 |
"Modified: / 03-05-2011 / 12:27:52 / cg" |
5481 | 3388 |
"Modified (format): / 16-02-2017 / 17:09:13 / cg" |
3389 |
! |
|
3390 |
||
3391 |
imageInfoString |
|
3392 |
image isNil ifTrue: [^ 'No image loaded.']. |
|
3393 |
||
3394 |
^ String streamContents:[:s | |
|
3395 |
|d| |
|
3396 |
||
5585 | 3397 |
s print:('%1x%2 | %3bit%4' |
3398 |
bindWith:image width |
|
3399 |
with:image height |
|
3400 |
with:image depth |
|
3401 |
with:(image mask notNil ifTrue: ['+mask'] ifFalse:[''])). |
|
3402 |
||
5588 | 3403 |
image depth ~~ image bitsPerSample sum ifTrue:[ |
3404 |
s print:' ('. |
|
6160 | 3405 |
image bitsPerSample do:[:each | s print:each] separatedBy:[s print:'·']. |
5588 | 3406 |
s print:')'. |
3407 |
]. |
|
3408 |
||
5481 | 3409 |
d := image depth min:24. |
3410 |
' [%1/%2 colors]' expandPlaceholdersWith:{image nColorsUsed. (2 raisedTo:d)} on:s. |
|
3411 |
]. |
|
3412 |
||
5588 | 3413 |
"Modified: / 31-08-2017 / 18:15:40 / cg" |
2511 | 3414 |
! |
3415 |
||
5413 | 3416 |
showCursorAt: aPoint andInformation: aLabel |
3417 |
|shownCursor| |
|
3418 |
||
4041 | 3419 |
readOnly ifTrue:[^ self]. |
2511 | 3420 |
|
3421 |
((0@0 extent: image extent * magnification) containsPoint: aPoint) |
|
5413 | 3422 |
ifTrue: [ shownCursor := Cursor crossHair ] |
5414 | 3423 |
ifFalse:[ shownCursor := Cursor stop ]. |
5413 | 3424 |
self cursor:shownCursor. |
3425 |
self updateImageInfo: aLabel. |
|
2511 | 3426 |
|
4041 | 3427 |
"Modified: / 03-05-2011 / 12:28:15 / cg" |
2511 | 3428 |
! |
3429 |
||
3430 |
updateActivity: something |
|
3431 |
|msg| |
|
3432 |
||
3433 |
msg := something printString. |
|
3434 |
||
3435 |
activityInfoHolder notNil ifTrue:[ |
|
3847
c09d45071125
comment/format in: #updateImageInfo:
Claus Gittinger <cg@exept.de>
parents:
3840
diff
changeset
|
3436 |
activityInfoHolder value:msg. |
2511 | 3437 |
]. |
3438 |
||
3439 |
"Modified: / 29.7.1998 / 18:41:47 / cg" |
|
3440 |
! |
|
3441 |
||
5583 | 3442 |
updateImageInfo:someTextOrObject |
5581 | 3443 |
"show someText in the lower info area" |
5481 | 3444 |
|
3847
c09d45071125
comment/format in: #updateImageInfo:
Claus Gittinger <cg@exept.de>
parents:
3840
diff
changeset
|
3445 |
|msg| |
2511 | 3446 |
|
3447 |
imageInfoHolder notNil ifTrue:[ |
|
5583 | 3448 |
someTextOrObject isString ifTrue:[ |
3449 |
msg := someTextOrObject |
|
3450 |
] ifFalse:[ |
|
3451 |
msg := someTextOrObject printString. |
|
3452 |
]. |
|
3847
c09d45071125
comment/format in: #updateImageInfo:
Claus Gittinger <cg@exept.de>
parents:
3840
diff
changeset
|
3453 |
msg ~= imageInfoHolder value ifTrue:[ |
c09d45071125
comment/format in: #updateImageInfo:
Claus Gittinger <cg@exept.de>
parents:
3840
diff
changeset
|
3454 |
imageInfoHolder value:msg. |
c09d45071125
comment/format in: #updateImageInfo:
Claus Gittinger <cg@exept.de>
parents:
3840
diff
changeset
|
3455 |
]. |
c09d45071125
comment/format in: #updateImageInfo:
Claus Gittinger <cg@exept.de>
parents:
3840
diff
changeset
|
3456 |
^ self |
2511 | 3457 |
]. |
3458 |
||
5583 | 3459 |
"Modified: / 29-08-2017 / 20:35:57 / cg" |
3729 | 3460 |
! |
3461 |
||
3462 |
updateImageInfoFor:aPoint |
|
5481 | 3463 |
"show info about the pixel at aPoint in the lower info area" |
3464 |
||
3465 |
|clr pixel r g b a m| |
|
3729 | 3466 |
|
3467 |
clr := image colorAt:aPoint. |
|
3468 |
pixel := image pixelAt:aPoint. |
|
3469 |
||
3470 |
r := clr redByte. |
|
3471 |
g := clr greenByte. |
|
3472 |
b := clr blueByte. |
|
5481 | 3473 |
image hasAlphaChannel ifTrue:[ |
5493 | 3474 |
"/ sigh - must return a TranslucentColor from colorAt: |
3475 |
"/ until that is fixed, compute it here... |
|
5481 | 3476 |
"/ a := clr alphaByte. |
5493 | 3477 |
a := (pixel rightShift:(image alphaShiftForPixelValue)) bitAnd:(image alphaMaskForPixelValue). |
5481 | 3478 |
] ifFalse:[ |
3479 |
image mask notNil ifTrue:[ |
|
3480 |
m := image mask pixelAt:aPoint. |
|
3481 |
]. |
|
3482 |
]. |
|
3483 |
||
3729 | 3484 |
self updateImageInfo: |
5583 | 3485 |
(' ' asText backgroundColorizeAllWith:clr) |
3486 |
, ' ' |
|
3487 |
, (String streamContents:[:s | |
|
5582 | 3488 |
|redString greenString blueString greyString |
3489 |
photometric bitsPerSample| |
|
5581 | 3490 |
|
5582 | 3491 |
photometric := image photometric. |
3492 |
bitsPerSample := image bitsPerSample. |
|
3493 |
||
3729 | 3494 |
s print:aPoint. |
5582 | 3495 |
|
3496 |
((photometric == #blackIs0) or:[(photometric == #whiteIs0)]) ifTrue:[ |
|
3497 |
s print:' (g:'; print:pixel. |
|
3498 |
greyString := (pixel hexPrintString:2). |
|
3499 |
] ifFalse:[ |
|
3500 |
s print:' (r:'; print:r. |
|
3501 |
s print:' g:'; print:g. |
|
3502 |
s print:' b:'; print:b. |
|
3503 |
||
3504 |
redString := (r hexPrintString:2). |
|
3505 |
greenString := (g hexPrintString:2). |
|
3506 |
blueString := (b hexPrintString:2). |
|
3507 |
]. |
|
5481 | 3508 |
a notNil ifTrue:[ |
3729 | 3509 |
s print:' a:'; print:a. |
5481 | 3510 |
] ifFalse:[ |
3511 |
m notNil ifTrue:[ |
|
3512 |
s print:' m:'; print:m. |
|
3513 |
]. |
|
5581 | 3514 |
]. |
3515 |
||
5582 | 3516 |
((photometric == #blackIs0) or:[(photometric == #whiteIs0)]) ifTrue:[ |
3517 |
(bitsPerSample at:1) == 16 ifTrue:[ |
|
3518 |
greyString := (pixel hexPrintString:4) |
|
5581 | 3519 |
]. |
5582 | 3520 |
s print:(' #%1' bindWith:greyString). |
3521 |
] ifFalse:[ |
|
3522 |
((photometric == #rgb) or:[(photometric == #rgba)]) ifTrue:[ |
|
3523 |
(bitsPerSample at:1) == 16 ifTrue:[ |
|
3524 |
redString := (r hexPrintString:4) |
|
3525 |
]. |
|
3526 |
(bitsPerSample at:2) == 16 ifTrue:[ |
|
3527 |
greenString := (g hexPrintString:4) |
|
3528 |
]. |
|
3529 |
(bitsPerSample at:2) == 16 ifTrue:[ |
|
3530 |
blueString := (b hexPrintString:4) |
|
3531 |
]. |
|
3532 |
]. |
|
3533 |
s print:(' #%1.%2.%3' bindWith:redString with:greenString with:blueString). |
|
3534 |
]. |
|
5481 | 3535 |
a notNil ifTrue:[ |
3536 |
s print:'.'; print:(a hexPrintString:2) |
|
3537 |
]. |
|
5582 | 3538 |
|
3539 |
photometric == #palette ifTrue:[ |
|
5581 | 3540 |
s print:' pixel index:'; print:pixel. |
3729 | 3541 |
]. |
3542 |
s print:')'. |
|
3543 |
]) |
|
5481 | 3544 |
|
5583 | 3545 |
"Modified: / 29-08-2017 / 20:39:26 / cg" |
2511 | 3546 |
! ! |
3547 |
||
2818 | 3548 |
!ImageEditView methodsFor:'initialization & release'! |
1327 | 3549 |
|
3550 |
destroy |
|
5618 | 3551 |
ClipboardImageMagnified := ClipboardImage := nil. |
1327 | 3552 |
LastMagnification := magnification. |
3553 |
||
3554 |
super destroy |
|
5618 | 3555 |
|
3556 |
"Modified: / 08-10-2017 / 08:54:36 / cg" |
|
1327 | 3557 |
! |
1 | 3558 |
|
161 | 3559 |
initialize |
3560 |
super initialize. |
|
627 | 3561 |
|
4041 | 3562 |
readOnly := false. |
3563 |
||
686 | 3564 |
self enableMotionEvents. |
995 | 3565 |
|
1374 | 3566 |
undoImages := List new: MaxUndos. |
2915 | 3567 |
|
1706 | 3568 |
magnification := LastMagnification ? (8@8). |
2747 | 3569 |
modifiedHolder := false asValue. |
627 | 3570 |
mouseKeyColorMode := 1. |
2908
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
3571 |
resourceClass := resourceSelector := nil. |
5499 | 3572 |
drawingColorHolders isNil ifTrue:[ |
3573 |
drawingColorHolders := Array with:(nil asValue) with:(nil asValue). "/ left/right mouse colors |
|
3574 |
]. |
|
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
3575 |
drawingPixelHolders := Array with:(nil asValue) with:(nil asValue). "/ left/right mouse colors |
4111 | 3576 |
|
5593 | 3577 |
drawingAlpha isNil ifTrue:[ drawingAlpha := 100 ]. |
4111 | 3578 |
spraySpot := 8. |
3579 |
penWidth := 1. |
|
5483 | 3580 |
floodFillMaxHueError := floodFillMaxLightError := 0. |
5484 | 3581 |
userAllowedToChangeDrawingColor := true. |
5483 | 3582 |
|
2889 | 3583 |
self editMode:EditModePoint. |
4041 | 3584 |
|
5594 | 3585 |
"Modified: / 05-09-2017 / 10:47:11 / cg" |
1 | 3586 |
! ! |
3587 |
||
2915 | 3588 |
!ImageEditView methodsFor:'loading & saving'! |
1 | 3589 |
|
1994 | 3590 |
askForFileNameToSave:msg |
3591 |
"ask for a fileName" |
|
3592 |
||
3593 |
|lastFn fn filters| |
|
3594 |
||
3595 |
filters := FileSelectionBrowser saveImageFileNameFilters. |
|
3596 |
lastFn := self image fileName. |
|
3597 |
lastFn isNil ifTrue:[ |
|
3598 |
fn := FileSelectionBrowser |
|
3599 |
request: msg |
|
3600 |
inDirectory: LastSaveDirectory |
|
3601 |
withFileFilters: filters |
|
3602 |
] ifFalse:[ |
|
3603 |
fn := FileSelectionBrowser |
|
3604 |
request: msg |
|
3605 |
fileName: lastFn |
|
3606 |
withFileFilters: filters |
|
3607 |
]. |
|
3608 |
||
3609 |
^ fn |
|
3610 |
! |
|
3611 |
||
724 | 3612 |
loadFromClass |
5701 | 3613 |
|brwsr classAndSelector| |
3614 |
||
3615 |
brwsr := ResourceSelectionBrowser |
|
3616 |
title: 'Load Image From Class' |
|
1184 | 3617 |
onSuperclass: nil |
5701 | 3618 |
andClass:(self resourceClass) andSelector:(self resourceSelector) |
2915 | 3619 |
withResourceTypes: #(image fileImage programImage). |
5701 | 3620 |
brwsr existingOnly:true. |
3621 |
classAndSelector := brwsr openAndLetUserChoose. |
|
2915 | 3622 |
classAndSelector notNil ifTrue:[ |
3623 |
self loadFromClass:(classAndSelector methodClass) andSelector:(classAndSelector methodSelector) |
|
3624 |
]. |
|
161 | 3625 |
! |
3626 |
||
2915 | 3627 |
loadFromClass:aClassOrClassName andSelector: aStringOrSymbol |
3628 |
"support for names will vanish - obsolete left over from tz" |
|
3629 |
||
3630 |
imageReaderClass := nil. |
|
3631 |
self resourceClass: aClassOrClassName. |
|
3632 |
self resourceSelector: aStringOrSymbol. |
|
3633 |
||
3634 |
resourceClass isBehavior ifFalse:[^ nil]. |
|
3635 |
||
3636 |
(resourceClass respondsTo:resourceSelector) ifTrue:[ |
|
3637 |
image := resourceClass perform:resourceSelector. |
|
3638 |
]. |
|
3639 |
||
3640 |
image isNil ifTrue:[^ nil]. |
|
3641 |
||
3642 |
image := image copy. |
|
3643 |
self releaseUndos. |
|
3644 |
self image:image. |
|
3645 |
self clearModified. |
|
3646 |
^ image |
|
2556 | 3647 |
! |
3648 |
||
2915 | 3649 |
loadFromFile: aFileName |
5510 | 3650 |
^ self loadFromFile:aFileName readerClass:nil |
3651 |
||
3652 |
"Modified: / 07-03-2017 / 17:43:07 / cg" |
|
3653 |
! |
|
3654 |
||
3655 |
loadFromFile:aFileName readerClass:imageReaderClassOrNil |
|
2915 | 3656 |
|imageFromFile| |
3657 |
||
3658 |
aFileName isNil ifTrue: [^nil]. |
|
3659 |
||
5029 | 3660 |
Error handle:[:exception| |
3661 |
self warn: exception errorString. |
|
4351 | 3662 |
^ nil |
2915 | 3663 |
] do:[ |
4351 | 3664 |
(imageFromFile := Image fromFile: aFileName) isNil ifTrue:[ |
5510 | 3665 |
imageFromFile := (imageReaderClassOrNil ? JPEGReader) fromFile:aFileName |
4351 | 3666 |
]. |
3667 |
imageFromFile notNil ifTrue:[ |
|
2915 | 3668 |
self releaseUndos. |
3669 |
self image: imageFromFile. |
|
3670 |
self clearModified. |
|
3671 |
"/ imageReaderClass := ImageReader allSubclasses |
|
3672 |
"/ detect: [:cls| cls isValidImageFile: aFileName asFilename pathName] |
|
3673 |
"/ ifNone: [self error: 'Unknown image file format!!'] |
|
3674 |
] ifFalse:[ |
|
4965 | 3675 |
aFileName asFilename isReadable ifTrue:[ |
3676 |
self error: 'Not an image file (or unrecognized format)' |
|
3677 |
] ifFalse:[ |
|
3678 |
self error: 'File does not exist or is unreadable' |
|
3679 |
] |
|
2915 | 3680 |
] |
2555 | 3681 |
]. |
2915 | 3682 |
^ imageFromFile |
3683 |
||
5510 | 3684 |
"Created: / 07-03-2017 / 17:42:37 / cg" |
2915 | 3685 |
! |
3686 |
||
3687 |
loadFromMessage:classAndSelector |
|
3688 |
"switch to the class and selector specified by classAndSelector." |
|
3689 |
||
3690 |
^ self loadFromClass:(classAndSelector methodClass) andSelector:(classAndSelector methodSelector) |
|
3691 |
! |
|
3692 |
||
3693 |
loadfromClass:aClassOrSymbol andSelector: aStringOrSymbol |
|
3643 | 3694 |
<resource: #obsolete> |
2915 | 3695 |
self obsoleteMethodWarning. |
3696 |
^ self loadFromClass:aClassOrSymbol andSelector: aStringOrSymbol |
|
624 | 3697 |
! |
3698 |
||
3699 |
save |
|
632 | 3700 |
self saveImageOrMask: #image. |
624 | 3701 |
! |
3702 |
||
2239 | 3703 |
save:image imageOrMask:what |
3704 |
"save the image or the mask only (if what == #mask)" |
|
297 | 3705 |
|
2239 | 3706 |
image isNil ifTrue:[ |
4249 | 3707 |
Dialog warn:(resources string:'No image to save!!'). |
2239 | 3708 |
^ self. |
3709 |
]. |
|
3710 |
self save:image imageOrMask:what as:image fileName. |
|
627 | 3711 |
! |
297 | 3712 |
|
2239 | 3713 |
save:image imageOrMask:what as:fileNameArg |
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
3714 |
"save the image or the mask only (if what == #mask)" |
628 | 3715 |
|
2240 | 3716 |
|fileName fileNameString| |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
3717 |
|
2239 | 3718 |
fileName := fileNameArg asFilename. |
2783 | 3719 |
LastSaveDirectory := fileName directoryName. |
2239 | 3720 |
|
4203 | 3721 |
Error handle:[:ex| |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
3722 |
|msg| |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
3723 |
|
4203 | 3724 |
ex creator == Image fileCreationErrorSignal ifTrue:[ |
1896 | 3725 |
msg := resources string:'Cannot create file: ''%1''' with:fileName asFilename pathName allBold |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
3726 |
] ifFalse:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
3727 |
msg := ex errorString. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
3728 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
3729 |
Dialog warn:msg. |
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
3730 |
] do:[ |
5600 | 3731 |
Image informationLostQuerySignal handle:[:ex | |
3732 |
|question| |
|
3733 |
||
3734 |
question := '\\Save anyway ?'. |
|
3735 |
ex creator == Image noMaskButAlphaSupportedQuerySignal ifTrue:[ |
|
3736 |
question := '\\Convert and save with alpha channel ?'. |
|
3737 |
]. |
|
3738 |
(self confirm:(ex errorString , question) withCRs) ifTrue:[ |
|
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
3739 |
ex proceed. |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
3740 |
] |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
3741 |
] do:[ |
4137 | 3742 |
windowGroup withWriteCursorDo:[ |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
3743 |
|suff fn| |
1027
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
3744 |
|
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
3745 |
image isNil ifTrue:[ |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
3746 |
^ self error: 'No image to save!!' |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
3747 |
]. |
632 | 3748 |
|
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
3749 |
what = #mask ifTrue:[ |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
3750 |
image mask isNil ifTrue: [^self error: 'No image mask to save!!']. |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
3751 |
]. |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
3752 |
|
6135 | 3753 |
fileName name size == 0 ifTrue: [^self error: 'No file name detected!!']. |
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
3754 |
suff := fileName suffix asLowercase. |
1373
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
3755 |
imageReaderClass := nil. |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
3756 |
imageReaderClass := MIMETypes imageReaderForSuffix:suff. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
3757 |
|
1373
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
3758 |
imageReaderClass isNil ifTrue: [ |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
3759 |
imageReaderClass := XPMReader. |
2589
10827ba87692
obsolete method calls cleaned up
Claus Gittinger <cg@exept.de>
parents:
2582
diff
changeset
|
3760 |
fileNameString := fileName name , '.xpm'. |
2240 | 3761 |
fileName := fileNameString asFilename. |
3762 |
image fileName:fileNameString. |
|
6084 | 3763 |
Dialog warn:'Don''t know how to write ".%1"-files\\Saving in xpm format as "%2".' withCRs |
3764 |
with:suff |
|
3765 |
with:fileNameString allBold. |
|
1373
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
3766 |
]. |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
3767 |
(imageReaderClass canRepresent:image) ifFalse:[ |
1991 | 3768 |
imageReaderClass == XPMReader ifTrue:[ |
6084 | 3769 |
Dialog warn:'Saving in ".%1"-format is not supported (or image cannot be represented in this format).\\Please try another format.' withCRs |
3770 |
with:suff. |
|
1991 | 3771 |
^ self. |
3772 |
]. |
|
1373
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
3773 |
imageReaderClass := XPMReader. |
2589
10827ba87692
obsolete method calls cleaned up
Claus Gittinger <cg@exept.de>
parents:
2582
diff
changeset
|
3774 |
fileNameString := fileName name , '.xpm'. |
2240 | 3775 |
fileName := fileNameString asFilename. |
3776 |
image fileName:fileNameString. |
|
2690
53bc9dc52ce4
allow cancel when saving in wrong format
Claus Gittinger <cg@exept.de>
parents:
2680
diff
changeset
|
3777 |
(Dialog confirm:(('Saving in ''.' , suff , '''-format is not supported (or image cannot be represented in this format).\\Saving in xpm format as ''%1''.') |
53bc9dc52ce4
allow cancel when saving in wrong format
Claus Gittinger <cg@exept.de>
parents:
2680
diff
changeset
|
3778 |
withCRs bindWith:fileNameString allBold)) ifFalse:[ |
53bc9dc52ce4
allow cancel when saving in wrong format
Claus Gittinger <cg@exept.de>
parents:
2680
diff
changeset
|
3779 |
^ self. |
53bc9dc52ce4
allow cancel when saving in wrong format
Claus Gittinger <cg@exept.de>
parents:
2680
diff
changeset
|
3780 |
]. |
1373
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
3781 |
]. |
2240 | 3782 |
Transcript showCR:('saving as:' , fileName pathName). |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
3783 |
|
2824 | 3784 |
what = #image ifTrue: [ |
3785 |
image saveOn:fileName using: imageReaderClass. self clearModified. |
|
3786 |
image fileName:fileNameString. |
|
3787 |
]. |
|
3788 |
what = #mask ifTrue: [ |
|
3789 |
image mask saveOn:fileName using: imageReaderClass |
|
3790 |
]. |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
3791 |
|
2240 | 3792 |
fileName exists ifFalse:[ |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
3793 |
Dialog warn:'Oops image save failed.' |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
3794 |
] |
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
3795 |
] |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
3796 |
] |
1027
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
3797 |
] |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
3798 |
|
5600 | 3799 |
"Modified: / 13-09-2017 / 09:49:46 / cg" |
6084 | 3800 |
"Modified: / 10-07-2019 / 18:30:12 / Claus Gittinger" |
633 | 3801 |
! |
3802 |
||
2239 | 3803 |
saveAs |
3804 |
self saveImageFileAs |
|
3805 |
! |
|
3806 |
||
3807 |
saveButtonImageToFileAs |
|
3808 |
|fn| |
|
3809 |
||
3810 |
fn := self askForFileNameToSave:'Save Button Image to File'. |
|
3811 |
self saveButtonImageToFileAs:fn |
|
3812 |
||
3813 |
"Modified: / 30.9.1998 / 23:04:11 / cg" |
|
3814 |
! |
|
3815 |
||
3816 |
saveButtonImageToFileAs: aFileName |
|
3817 |
"save the image as if in a button in aFileName" |
|
3818 |
||
3819 |
|button grabbedImage| |
|
3820 |
||
3821 |
aFileName isNil ifTrue: [^nil]. |
|
3822 |
||
3823 |
image isNil ifTrue:[ |
|
4249 | 3824 |
self warn:(resources string:'No image or image mask to save!!'). |
2239 | 3825 |
^ self. |
3826 |
]. |
|
3827 |
||
3828 |
button := Button label:image. |
|
3829 |
button openAt:5@5. |
|
3830 |
button waitUntilVisible. |
|
3831 |
||
3832 |
grabbedImage := Image fromView:button. |
|
3833 |
button destroy. |
|
3834 |
||
3835 |
self save:grabbedImage imageOrMask:#image as:aFileName |
|
3836 |
||
3837 |
"/ self saveImageOrMask: #mask |
|
3838 |
! |
|
3839 |
||
3840 |
saveImageFileAs |
|
3841 |
"ask for a fileName and save the image" |
|
3842 |
||
3843 |
|fn| |
|
3844 |
||
3845 |
fn := self askForFileNameToSave:'Save Image To File'. |
|
3846 |
self saveImageFileAs:fn |
|
3847 |
! |
|
3848 |
||
3849 |
saveImageFileAs: aFileName |
|
3850 |
"save the image in aFileName" |
|
3851 |
||
3852 |
aFileName isNil ifTrue: [^nil]. |
|
3853 |
image notNil ifTrue:[ |
|
3854 |
self save:image imageOrMask:#image as:aFileName. |
|
3855 |
] ifFalse:[ |
|
4249 | 3856 |
self warn:(resources string:'No image for saving!!') |
2239 | 3857 |
] |
3858 |
||
3859 |
"Modified: / 30.9.1998 / 23:04:55 / cg" |
|
3860 |
! |
|
3861 |
||
3862 |
saveImageMaskFileAs |
|
3863 |
"ask for a fileName and save the mask only" |
|
3864 |
||
3865 |
|fn| |
|
3866 |
||
3867 |
fn := self askForFileNameToSave:'Save Image Mask To File'. |
|
3868 |
self saveImageMaskFileAs:fn |
|
3869 |
||
3870 |
"Modified: / 30.9.1998 / 23:04:11 / cg" |
|
3871 |
! |
|
3872 |
||
3873 |
saveImageMaskFileAs: aFileName |
|
3874 |
"save the mask only in aFileName" |
|
3875 |
||
3876 |
aFileName isNil ifTrue: [^nil]. |
|
3877 |
(image notNil and:[image mask notNil]) ifTrue:[ |
|
3878 |
self save:image imageOrMask:#mask as:aFileName. |
|
3879 |
] ifFalse:[ |
|
4249 | 3880 |
self warn:(resources string:'No image or image mask to save!!') |
2239 | 3881 |
] |
3882 |
||
3883 |
"Modified: / 30.9.1998 / 23:06:24 / cg" |
|
3884 |
! |
|
3885 |
||
3886 |
saveImageOrMask:what |
|
3887 |
"save the image or the mask only (if what == #mask)" |
|
3888 |
||
3889 |
self save:image imageOrMask: what |
|
3890 |
! |
|
3891 |
||
633 | 3892 |
saveMethod |
5364 | 3893 |
"save the image as a resource method. |
3894 |
Return true if ok; false if not" |
|
3895 |
||
4149 | 3896 |
(resourceSelector trimBlanks notEmptyOrNil and:[ resourceClass isBehavior ]) ifFalse: [ |
2915 | 3897 |
^ self saveMethodAs. |
2914 | 3898 |
]. |
3899 |
||
3900 |
windowGroup withExecuteCursorDo:[ |
|
3859 | 3901 |
Error handle:[:ex| |
3902 |
(self confirm:(ex errorString,'\\Debug?' withCRs)) ifTrue:[ ex reject ]. |
|
2915 | 3903 |
^ false |
2914 | 3904 |
] do: [ |
5286 | 3905 |
|img imageSaved depth bestDepth colorsUsed numColorsUsed category imageStoreStream sel mthd imageKey| |
4149 | 3906 |
|
3907 |
img := self image. |
|
4714 | 3908 |
depth := bestDepth := img depth. |
3909 |
colorsUsed := (img usedColorsMax:256). |
|
3910 |
colorsUsed notNil ifTrue:[ |
|
3911 |
numColorsUsed := colorsUsed size. |
|
3912 |
#(8 4 2 1) do:[:d | |
|
3913 |
depth > d ifTrue:[ |
|
3914 |
numColorsUsed <= (1 << d) ifTrue:[ |
|
3915 |
bestDepth := d |
|
3916 |
] |
|
4149 | 3917 |
] |
4714 | 3918 |
]. |
4149 | 3919 |
]. |
5286 | 3920 |
imageSaved := img. |
5656 | 3921 |
(image hasAlphaChannel not and:[ bestDepth < depth ]) ifTrue:[ |
5286 | 3922 |
|answer| |
3923 |
||
3924 |
answer := Dialog |
|
3925 |
confirmWithCancel:(resources stringWithCRs:'Hint:\\You can save some code space, by converting the image from a depth-%1 to a depth-%2 image first.\(only %3 colors used)\\Convert before saving?' |
|
3926 |
with:depth with:bestDepth with:numColorsUsed). |
|
3927 |
answer isNil ifTrue:[ |
|
5579 | 3928 |
"/ canceled |
4149 | 3929 |
^ false |
5286 | 3930 |
]. |
3931 |
answer == true ifTrue:[ |
|
3932 |
imageSaved := (Image implementorForDepth:bestDepth) fromImage:imageSaved |
|
3933 |
]. |
|
4149 | 3934 |
]. |
822
cace81f0a86b
do not overwrite method categories + toggle between mouse button colors
tz
parents:
796
diff
changeset
|
3935 |
|
4000
21106540ffb5
CodeGeneratorTool->SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents:
3980
diff
changeset
|
3936 |
SmalltalkCodeGeneratorTool |
5286 | 3937 |
createImageSpecMethodFor:imageSaved |
1882
fbb4a3a869f1
made image-method generator a class method (for reusability)
martin
parents:
1875
diff
changeset
|
3938 |
comment:(ResourceSpecEditor codeGenerationCommentForClass: ImageEditor) |
2915 | 3939 |
in:resourceClass class |
3940 |
selector:resourceSelector. |
|
822
cace81f0a86b
do not overwrite method categories + toggle between mouse button colors
tz
parents:
796
diff
changeset
|
3941 |
|
5364 | 3942 |
"/ flush cached images in the Icon class (kludge) |
1901
b4b286ec221f
flush cached icons, when defining a new image-method
Claus Gittinger <cg@exept.de>
parents:
1896
diff
changeset
|
3943 |
Icon flushCachedIcons. |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
3944 |
self clearModified. |
1901
b4b286ec221f
flush cached icons, when defining a new image-method
Claus Gittinger <cg@exept.de>
parents:
1896
diff
changeset
|
3945 |
|
2915 | 3946 |
LastSaveClass := resourceClass. |
1882
fbb4a3a869f1
made image-method generator a class method (for reusability)
martin
parents:
1875
diff
changeset
|
3947 |
] |
2915 | 3948 |
]. |
3949 |
^ true |
|
1027
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
3950 |
|
4000
21106540ffb5
CodeGeneratorTool->SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents:
3980
diff
changeset
|
3951 |
"Modified: / 31-01-2011 / 18:28:06 / cg" |
5579 | 3952 |
"Modified (format): / 24-08-2017 / 15:02:51 / cg" |
633 | 3953 |
! |
3954 |
||
3955 |
saveMethodAs |
|
2915 | 3956 |
"ask for method/selector; save the image there. |
3957 |
Return true if saved, false if not" |
|
3958 |
||
5364 | 3959 |
|className classAndSelector |
3960 |
previousClass previousCategory previousSelector |
|
3961 |
previousMethod newMethod ok| |
|
3962 |
||
3963 |
previousSelector := self resourceSelector. |
|
2908
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
3964 |
className := self resourceClassName. |
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
3965 |
className isEmptyOrNil ifTrue:[ |
2177 | 3966 |
className := LastSaveClass |
1994 | 3967 |
]. |
5364 | 3968 |
(className notEmptyOrNil and:[previousSelector notNil]) ifTrue:[ |
3969 |
previousClass := Smalltalk classNamed:className. |
|
3970 |
previousClass notNil ifTrue:[ |
|
3971 |
previousMethod := previousClass class compiledMethodAt:previousSelector. |
|
3972 |
previousMethod notNil ifTrue:[ |
|
3973 |
previousCategory := previousMethod category. |
|
3974 |
] |
|
3975 |
] |
|
3976 |
]. |
|
633 | 3977 |
|
3840 | 3978 |
self withWaitCursorDo:[ |
3979 |
classAndSelector := ResourceSelectionBrowser |
|
3980 |
request: 'Save Image In Class' |
|
3981 |
onSuperclass: #Object |
|
3982 |
andClass: className |
|
3983 |
andSelector: self resourceSelector |
|
3984 |
withResourceTypes: #(image fileImage programImage). |
|
3985 |
]. |
|
2915 | 3986 |
classAndSelector isNil ifTrue:[^ false]. |
3987 |
||
3988 |
resourceClass := classAndSelector methodClass. |
|
3989 |
resourceSelector := classAndSelector methodSelector. |
|
3990 |
||
5364 | 3991 |
ok := self saveMethod. |
3992 |
ok ifTrue:[ |
|
3993 |
previousCategory notNil ifTrue:[ |
|
3994 |
newMethod := resourceClass class compiledMethodAt:resourceSelector asSymbol. |
|
3995 |
newMethod notNil ifTrue:[ |
|
3996 |
newMethod category:previousCategory. |
|
3997 |
] |
|
3998 |
] |
|
3999 |
]. |
|
4000 |
^ ok |
|
4001 |
||
4002 |
"Modified: / 25-11-2016 / 09:17:22 / cg" |
|
2915 | 4003 |
! ! |
4004 |
||
4005 |
!ImageEditView methodsFor:'printing'! |
|
4006 |
||
4007 |
||
4008 |
self printWithMagnification:1 |
|
4009 |
! |
|
4010 |
||
4011 |
printMagnified |
|
4012 |
self printWithMagnification:magnification |
|
4013 |
! |
|
4014 |
||
4015 |
printWithMagnification:magnification |
|
4016 |
|stream| |
|
4017 |
||
4018 |
image isNil ifTrue:[^ self]. |
|
4019 |
||
4020 |
Printer supportsPostscript ifFalse:[ |
|
4249 | 4021 |
^ self warn:(resources string:'No postscript printer configured !!') |
2915 | 4022 |
]. |
4023 |
||
4024 |
stream := Printer newNative. |
|
4025 |
stream isNil ifTrue:[ |
|
4249 | 4026 |
^ self warn:(resources string:'Cannot open printer stream !!') |
2915 | 4027 |
]. |
4028 |
||
4029 |
self withWaitCursorDo:[ |
|
4030 |
|psgc| |
|
4031 |
||
4032 |
psgc := PSGraphicsContext on:stream. |
|
4033 |
psgc displayForm: (image magnifiedBy: magnification) x:0 y:0. |
|
4034 |
psgc close |
|
4035 |
] |
|
1 | 4036 |
! ! |
4037 |
||
161 | 4038 |
!ImageEditView methodsFor:'queries'! |
5 | 4039 |
|
161 | 4040 |
heightOfContents |
4041 |
||
686 | 4042 |
image isNil ifTrue:[^0]. |
4043 |
^(image height * magnification y) rounded |
|
5 | 4044 |
! |
4045 |
||
995 | 4046 |
imageContainsPastePoint: aPoint |
5618 | 4047 |
^image notNil |
4048 |
and: [ ClipboardImage notNil |
|
4049 |
and: [ (0@0 corner:(image extent) "- 1" - ClipboardImage extent) |
|
4050 |
containsPoint: (((aPoint - margin + 1) / magnification) floor) |
|
4051 |
]] |
|
4052 |
||
4053 |
"Modified (format): / 08-10-2017 / 08:53:18 / cg" |
|
995 | 4054 |
! |
4055 |
||
627 | 4056 |
imageContainsPoint: aPoint |
632 | 4057 |
|
4058 |
^image notNil and: |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
4059 |
[((0@0 corner:(image extent) - 1) containsPoint: (((aPoint - margin + 1) / magnification) floor))] |
627 | 4060 |
! |
4061 |
||
5752 | 4062 |
selfIsNotImageEditor |
4063 |
^ false |
|
4064 |
! |
|
4065 |
||
161 | 4066 |
widthOfContents |
5 | 4067 |
|
686 | 4068 |
image isNil ifTrue:[^0]. |
4069 |
^(image width * magnification x) rounded |
|
5 | 4070 |
! ! |
4071 |
||
627 | 4072 |
!ImageEditView methodsFor:'release'! |
4073 |
||
995 | 4074 |
releasePasteDrawing |
2085 | 4075 |
self repairDamage. |
5618 | 4076 |
(lastPastePoint notNil and: [ClipboardImageMagnified notNil]) |
2747 | 4077 |
ifTrue: [ |
5618 | 4078 |
self redraw: ((lastPastePoint"-self viewOrigin") extent: (ClipboardImageMagnified extent)). |
2085 | 4079 |
"/ self repairDamage. |
995 | 4080 |
]. |
5618 | 4081 |
lastPastePoint := ClipboardImageMagnified := nil |
4082 |
||
4083 |
"Modified: / 08-10-2017 / 08:55:06 / cg" |
|
995 | 4084 |
! |
4085 |
||
4086 |
releaseUndos |
|
4087 |
undoImages removeAll. |
|
627 | 4088 |
! ! |
4089 |
||
632 | 4090 |
!ImageEditView methodsFor:'testing'! |
4091 |
||
4092 |
checkModified |
|
2747 | 4093 |
modifiedHolder value ifTrue:[ |
2634 | 4094 |
((YesNoBox title:(resources string:'Image was not saved. Exit anyway ?')) |
2591
87cab7199c7e
Use 'Discard Changes and Exit' instead of 'Forget it...'
Stefan Vogel <sv@exept.de>
parents:
2590
diff
changeset
|
4095 |
noText:(resources string:'Cancel'); |
2634 | 4096 |
yesText:(resources string:'Exit without Saving'); |
2591
87cab7199c7e
Use 'Discard Changes and Exit' instead of 'Forget it...'
Stefan Vogel <sv@exept.de>
parents:
2590
diff
changeset
|
4097 |
showAtPointer; |
2747 | 4098 |
accepted |
4099 |
) ifFalse: [^false]. |
|
4100 |
||
4101 |
self modified:false. |
|
632 | 4102 |
]. |
2591
87cab7199c7e
Use 'Discard Changes and Exit' instead of 'Forget it...'
Stefan Vogel <sv@exept.de>
parents:
2590
diff
changeset
|
4103 |
^ true |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4104 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4105 |
"Modified: / 29.7.1998 / 18:55:24 / cg" |
632 | 4106 |
! ! |
4107 |
||
255 | 4108 |
!ImageEditView class methodsFor:'documentation'! |
161 | 4109 |
|
4110 |
version |
|
4853 | 4111 |
^ '$Header$' |
3762 | 4112 |
! |
4113 |
||
4114 |
version_CVS |
|
4853 | 4115 |
^ '$Header$' |
161 | 4116 |
! ! |
2239 | 4117 |
|
4203 | 4118 |
|
1245 | 4119 |
ImageEditView initialize! |