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