author | Jan Vrany <jan.vrany@labware.com> |
Fri, 02 Sep 2022 11:25:39 +0100 | |
branch | jv |
changeset 6261 | 9b7eb7159d29 |
parent 5432 | 6f103b797668 |
child 5434 | 29822bceb67d |
permissions | -rw-r--r-- |
636 | 1 |
" |
704 | 2 |
COPYRIGHT (c) 1997 by eXept Software AG |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
3 |
All Rights Reserved |
636 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
1763
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
12 |
"{ Package: 'stx:libwidg2' }" |
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
13 |
|
4714 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
1 | 16 |
ImageView subclass:#ImageEditView |
4041 | 17 |
instanceVariableNames:'readOnly magnification imageReaderClass resourceClass |
18 |
resourceSelector mouseKeyColorMode undoImages modifiedHolder |
|
19 |
editMode lastPastePoint imageInfoHolder activityInfoHolder |
|
2747 | 20 |
pickedColorHolder drawingColors drawingPixels drawingColorHolders |
3476 | 21 |
drawingPixelHolders clickInfoCallBack penWidth sprayProcess |
3730 | 22 |
sprayPosition spraySpot drawingAlpha' |
2440 | 23 |
classVariableNames:'Clipboard ClipboardMagnified LastMagnification |
2889 | 24 |
GridMagnificationLimit MaxUndos LastSaveDirectory LastSaveClass |
25 |
EditModePoint EditModeBox EditModeFilledBox EditModeFill |
|
26 |
EditModeCopy EditModePasteUnder EditModePaste |
|
3476 | 27 |
EditModePasteWithMask EditModeSpecialOperation EditModeSpray |
4715 | 28 |
EditModeCircle EditModeSmooth' |
1035 | 29 |
poolDictionaries:'' |
1706 | 30 |
category:'Views-Misc' |
1 | 31 |
! |
32 |
||
636 | 33 |
!ImageEditView class methodsFor:'documentation'! |
34 |
||
35 |
copyright |
|
36 |
" |
|
704 | 37 |
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
|
38 |
All Rights Reserved |
636 | 39 |
|
40 |
This software is furnished under a license and may be used |
|
41 |
only in accordance with the terms of that license and with the |
|
42 |
inclusion of the above copyright notice. This software may not |
|
43 |
be provided or otherwise made available to, or used by, any |
|
44 |
other person. No title to or ownership of the software is |
|
45 |
hereby transferred. |
|
46 |
" |
|
47 |
! |
|
48 |
||
49 |
documentation |
|
50 |
" |
|
2747 | 51 |
An ImageEditView is a view which can be used by applications |
52 |
like the Image Editor for editing or inspecting (bitmap-) images. |
|
636 | 53 |
|
54 |
[see also:] |
|
2747 | 55 |
ImageEditor Image |
636 | 56 |
|
57 |
[author:] |
|
2747 | 58 |
Thomas Zwick |
636 | 59 |
" |
60 |
! ! |
|
353 | 61 |
|
1245 | 62 |
!ImageEditView class methodsFor:'initialization'! |
63 |
||
64 |
initialize |
|
2915 | 65 |
MaxUndos := 10. |
5413 | 66 |
GridMagnificationLimit := 6 @ 6. |
1245 | 67 |
|
2889 | 68 |
EditModePoint := #point. |
69 |
EditModeBox := #box. |
|
3476 | 70 |
EditModeCircle := #circle. |
2889 | 71 |
EditModePaste := #paste. |
72 |
EditModePasteUnder := #pasteUnder. |
|
73 |
EditModePasteWithMask := #pasteWithMask. |
|
74 |
EditModeFilledBox := #filledBox. |
|
75 |
EditModeFill := #fill. |
|
76 |
EditModeCopy := #copy. |
|
77 |
EditModeSpecialOperation := #specialOperation. |
|
3476 | 78 |
EditModeSpray := #spray. |
4715 | 79 |
EditModeSmooth := #smooth. |
2889 | 80 |
|
1245 | 81 |
" |
82 |
self initialize |
|
83 |
" |
|
84 |
! ! |
|
85 |
||
1706 | 86 |
!ImageEditView class methodsFor:'accessing'! |
87 |
||
2889 | 88 |
editModeBox |
89 |
^ EditModeBox |
|
90 |
! |
|
91 |
||
92 |
editModeCopy |
|
93 |
^ EditModeCopy |
|
94 |
! |
|
95 |
||
96 |
editModeFill |
|
97 |
^ EditModeFill |
|
98 |
! |
|
99 |
||
100 |
editModeFilledBox |
|
101 |
^ EditModeFilledBox |
|
102 |
! |
|
103 |
||
104 |
editModePaste |
|
105 |
^ EditModePaste |
|
106 |
! |
|
107 |
||
108 |
editModePasteUnder |
|
109 |
^ EditModePasteUnder |
|
110 |
! |
|
111 |
||
112 |
editModePasteWithMask |
|
113 |
^ EditModePasteWithMask |
|
114 |
! |
|
115 |
||
116 |
editModePoint |
|
117 |
^ EditModePoint |
|
118 |
! |
|
119 |
||
4715 | 120 |
editModeSmooth |
121 |
^ EditModeSmooth |
|
122 |
! |
|
123 |
||
2889 | 124 |
editModeSpecialOperation |
125 |
^ EditModeSpecialOperation |
|
126 |
! |
|
127 |
||
1706 | 128 |
gridMagnificationLimit |
129 |
^ GridMagnificationLimit |
|
130 |
! |
|
131 |
||
132 |
gridMagnificationLimit:anInteger |
|
133 |
GridMagnificationLimit := anInteger |
|
3980 | 134 |
! |
135 |
||
136 |
lastSaveDirectory |
|
137 |
^ LastSaveDirectory |
|
138 |
||
139 |
"Created: / 14-12-2010 / 14:49:01 / cg" |
|
140 |
! |
|
141 |
||
142 |
lastSaveDirectory:aStringOrFilename |
|
143 |
LastSaveDirectory := aStringOrFilename |
|
144 |
||
145 |
"Created: / 14-12-2010 / 14:49:18 / cg" |
|
1706 | 146 |
! ! |
147 |
||
2480 | 148 |
!ImageEditView class methodsFor:'helpers'! |
149 |
||
150 |
copyImageToClipboard:copiedImage |
|
151 |
ClipboardMagnified := nil. |
|
152 |
Clipboard := copiedImage. |
|
153 |
! ! |
|
154 |
||
2634 | 155 |
!ImageEditView class methodsFor:'resources'! |
156 |
||
157 |
classResources |
|
158 |
^ ImageEditor classResources |
|
159 |
! ! |
|
160 |
||
7 | 161 |
!ImageEditView methodsFor:'accessing'! |
162 |
||
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
163 |
activityInfoHolder |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
164 |
"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
|
165 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
166 |
^ activityInfoHolder |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
167 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
168 |
"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
|
169 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
170 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
171 |
activityInfoHolder:something |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
172 |
"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
|
173 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
174 |
activityInfoHolder := something. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
175 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
176 |
"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
|
177 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
178 |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
179 |
clearModified |
2915 | 180 |
self modified:false |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
181 |
! |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
182 |
|
1693 | 183 |
clickInfoCallBack:aTwoArgBlock |
184 |
clickInfoCallBack := aTwoArgBlock |
|
185 |
||
186 |
"Created: / 10.2.2000 / 23:07:14 / cg" |
|
187 |
! |
|
188 |
||
2440 | 189 |
clipBoard |
5413 | 190 |
|clipboardObject| |
191 |
||
192 |
clipboardObject := self getClipboardObject. |
|
193 |
clipboardObject isImage ifTrue:[ |
|
194 |
^ clipboardObject |
|
195 |
]. |
|
196 |
^ Clipboard. |
|
2440 | 197 |
! |
198 |
||
3610
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
199 |
drawingColorHolders |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
200 |
^ drawingColorHolders |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
201 |
! |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
202 |
|
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
203 |
drawingColors |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
204 |
^ drawingColorHolders collect:[:each | each value]. |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
205 |
! |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
206 |
|
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
207 |
drawingColors:anArrayTwoColors |
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
208 |
(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
|
209 |
(drawingColorHolders at:2) value:(anArrayTwoColors at:2). |
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
210 |
! |
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
211 |
|
2915 | 212 |
image:anImage scroll:doScroll |
3706 | 213 |
self image:anImage scroll:doScroll invalidate:true |
214 |
! |
|
215 |
||
216 |
image:anImage scroll:doScroll invalidate:doInvalidate |
|
2915 | 217 |
|retVal fileName| |
218 |
||
219 |
anImage isImage ifTrue:[ |
|
220 |
true "(image isNil or: [self checkModified])" ifTrue: [ |
|
221 |
image notNil ifTrue: [ |
|
222 |
fileName := image fileName. |
|
223 |
anImage fileName isNil ifTrue: [anImage fileName: fileName]. |
|
224 |
]. |
|
3706 | 225 |
super image:anImage scroll:doScroll invalidate:doInvalidate. |
2915 | 226 |
retVal := self. |
227 |
]. |
|
228 |
] ifFalse: [ |
|
3706 | 229 |
super image:nil scroll:true invalidate:doInvalidate. |
2915 | 230 |
]. |
3706 | 231 |
|
2915 | 232 |
"/ self changed:#image. |
233 |
image isNil ifTrue:[ |
|
234 |
self clearModified. |
|
235 |
] ifFalse:[ |
|
236 |
self setModified. |
|
237 |
]. |
|
238 |
self updateImageInfo: self imageInfoString. |
|
239 |
^ retVal |
|
240 |
||
241 |
"Modified: / 10.2.2000 / 23:33:12 / cg" |
|
242 |
! |
|
243 |
||
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
244 |
imageInfoHolder |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
245 |
^ imageInfoHolder |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
246 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
247 |
"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
|
248 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
249 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
250 |
imageInfoHolder:something |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
251 |
imageInfoHolder := something. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
252 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
253 |
"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
|
254 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
255 |
|
624 | 256 |
magnification |
257 |
||
258 |
^magnification |
|
259 |
||
255 | 260 |
! |
261 |
||
636 | 262 |
magnification: aPoint |
1037 | 263 |
|oldOrg| |
255 | 264 |
|
627 | 265 |
magnification ~= aPoint |
624 | 266 |
ifTrue: |
267 |
[ |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
268 |
oldOrg := self viewOrigin / magnification. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
269 |
magnification := aPoint asPoint. |
1037 | 270 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
271 |
self scrollTo:(oldOrg * magnification) rounded redraw:false. |
1037 | 272 |
"/ self scrollToTopLeft. |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
273 |
self contentsChanged. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
274 |
self invalidate. |
2440 | 275 |
ClipboardMagnified := nil. |
686 | 276 |
] |
1037 | 277 |
|
278 |
"Modified: / 31.7.1998 / 02:38:47 / cg" |
|
624 | 279 |
! |
255 | 280 |
|
2913 | 281 |
modified |
282 |
^ modifiedHolder value |
|
283 |
! |
|
284 |
||
2747 | 285 |
modified:aBoolean |
286 |
modifiedHolder value:aBoolean |
|
287 |
! |
|
288 |
||
289 |
modifiedHolder |
|
290 |
^ modifiedHolder |
|
291 |
! |
|
292 |
||
3265 | 293 |
penWidth |
294 |
^ penWidth ? 1 |
|
295 |
||
296 |
"Created: / 01-11-2007 / 23:34:49 / cg" |
|
297 |
! |
|
298 |
||
5405 | 299 |
penWidth:anInteger |
300 |
penWidth := anInteger |
|
3265 | 301 |
|
302 |
"Created: / 01-11-2007 / 23:34:56 / cg" |
|
303 |
! |
|
304 |
||
4041 | 305 |
readOnly |
306 |
^ readOnly |
|
307 |
! |
|
308 |
||
5405 | 309 |
readOnly:aBoolean |
310 |
readOnly := aBoolean. |
|
4041 | 311 |
! |
312 |
||
2915 | 313 |
removelastUndo |
314 |
undoImages removeLast |
|
315 |
! |
|
316 |
||
627 | 317 |
resourceClass |
2915 | 318 |
^ resourceClass |
627 | 319 |
! |
320 |
||
2915 | 321 |
resourceClass: aClassOrClassNameString |
322 |
"support for names will vanish - obsolete left over from tz" |
|
323 |
||
324 |
resourceClass := aClassOrClassNameString. |
|
325 |
resourceClass notNil ifTrue:[ |
|
326 |
resourceClass isBehavior ifFalse: [ |
|
327 |
resourceClass := Smalltalk classNamed:aClassOrClassNameString |
|
328 |
] |
|
329 |
] |
|
2908
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
330 |
! |
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
331 |
|
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
332 |
resourceClassName |
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
333 |
resourceClass isNil ifTrue:[^ '']. |
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
334 |
^ resourceClass name |
627 | 335 |
! |
336 |
||
337 |
resourceMessage |
|
2909 | 338 |
(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
|
339 |
^ resourceClass name, ' ', resourceSelector |
627 | 340 |
! |
341 |
||
342 |
resourceSelector |
|
2915 | 343 |
^ resourceSelector |
627 | 344 |
! |
345 |
||
346 |
resourceSelector: aStringOrSymbol |
|
2909 | 347 |
aStringOrSymbol isNil ifTrue:[ |
348 |
resourceSelector := nil |
|
349 |
] ifFalse:[ |
|
350 |
resourceSelector := aStringOrSymbol asSymbol |
|
351 |
] |
|
627 | 352 |
! |
353 |
||
354 |
selectedColor |
|
3730 | 355 |
|clr| |
356 |
||
357 |
clr := (drawingColorHolders at:mouseKeyColorMode) value. |
|
3931 | 358 |
clr isNil ifTrue:[ clr := Color black ]. |
3730 | 359 |
image hasAlphaChannel ifTrue:[ |
360 |
^ (TranslucentColor |
|
361 |
scaledRed:clr scaledRed |
|
362 |
scaledGreen:clr scaledGreen |
|
363 |
scaledBlue:clr scaledBlue) |
|
364 |
alpha:(drawingAlpha ? 1.0) |
|
365 |
]. |
|
366 |
^ clr |
|
3931 | 367 |
|
368 |
"Modified: / 20-09-2010 / 11:34:07 / cg" |
|
1246 | 369 |
! |
370 |
||
371 |
selectedColor: aColor |
|
4853 | 372 |
(drawingColorHolders at:(mouseKeyColorMode min:drawingColorHolders size)) value:aColor |
627 | 373 |
! |
374 |
||
1246 | 375 |
selectedColorIndex |
2915 | 376 |
^ (drawingPixelHolders at:mouseKeyColorMode) value |
1246 | 377 |
! |
378 |
||
379 |
selectedColorIndex: aPixelIndex |
|
4853 | 380 |
(drawingPixelHolders at:(mouseKeyColorMode min:drawingPixelHolders size)) value: aPixelIndex |
995 | 381 |
! |
382 |
||
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
383 |
setModified |
2915 | 384 |
self modified:true |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
385 |
! |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
386 |
|
4111 | 387 |
spraySpot |
388 |
^ spraySpot |
|
389 |
||
390 |
"Created: / 15-02-2012 / 22:38:04 / cg" |
|
391 |
! |
|
392 |
||
3476 | 393 |
spraySpot:something |
394 |
spraySpot := something. |
|
395 |
! |
|
396 |
||
995 | 397 |
undoImages |
2915 | 398 |
^ undoImages |
627 | 399 |
! ! |
400 |
||
401 |
!ImageEditView methodsFor:'drawing'! |
|
402 |
||
1036 | 403 |
drawFrame |
5413 | 404 |
"draws a black frame around the image's bounds" |
405 |
||
5432 | 406 |
gc paint:self blackColor. |
407 |
gc lineWidth: (magnification x//3 min: 3). |
|
408 |
gc displayRectangle: ((0@0) extent:(image extent * magnification) + margin). |
|
409 |
gc lineWidth:1. |
|
1036 | 410 |
! |
411 |
||
412 |
drawFramesIn: aRectangle |
|
5413 | 413 |
"draws the pixel frame grid" |
414 |
||
415 |
|origin lineStartingPoint lineEndingPoint oldColor mX mY| |
|
416 |
||
417 |
magnification >= GridMagnificationLimit ifTrue: [ |
|
418 |
mX := magnification x. |
|
419 |
mY := magnification y. |
|
420 |
||
1706 | 421 |
origin := aRectangle origin - 1. |
5413 | 422 |
lineStartingPoint := origin + (0 @ mY). |
1706 | 423 |
lineEndingPoint := lineStartingPoint + (aRectangle width@0). |
5413 | 424 |
|
5432 | 425 |
oldColor := gc paint. |
426 |
gc xoring:[ |
|
427 |
gc displayLineFrom: lineStartingPoint to: lineEndingPoint. |
|
5413 | 428 |
lineStartingPoint x to: lineStartingPoint x + aRectangle width - mX by: mX |
429 |
do:[:x| |
|
5432 | 430 |
gc displayLineFrom: x@(origin y) to: x@(origin y + mY) |
1706 | 431 |
]. |
432 |
]. |
|
5432 | 433 |
gc paint: oldColor. |
1036 | 434 |
] |
435 |
! |
|
436 |
||
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
437 |
drawPasteRectangleAt: aPoint |
2889 | 438 |
|currentPoint gridCorrection extent| |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
439 |
|
1706 | 440 |
magnification >= GridMagnificationLimit ifFalse: [gridCorrection := 0] ifTrue: [gridCorrection := 1]. |
1449 | 441 |
currentPoint := aPoint // magnification*magnification + margin. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
442 |
|
2085 | 443 |
self repairDamage. |
444 |
||
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
445 |
currentPoint ~= lastPastePoint ifTrue:[ |
2440 | 446 |
ClipboardMagnified isNil ifTrue:[ |
4999 | 447 |
ClipboardMagnified := (Clipboard magnifiedBy: magnification) onDevice:device |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
448 |
]. |
3278 | 449 |
extent := ClipboardMagnified extent. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
450 |
|
1967 | 451 |
"/ currentPoint := currentPoint - self viewOrigin. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
452 |
|
2085 | 453 |
self redraw: (((lastPastePoint ? currentPoint)"-self viewOrigin") extent: extent). |
3267 | 454 |
"/ self repairDamage. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
455 |
|
2085 | 456 |
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
|
457 |
self xoring: [ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
458 |
self fillRectangle: (currentPoint extent: extent) |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
459 |
] |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
460 |
] ifFalse:[ |
2440 | 461 |
ClipboardMagnified notNil ifTrue:[ |
462 |
self displayDeviceForm: ClipboardMagnified |
|
2089 | 463 |
x: currentPoint x - self viewOrigin x |
464 |
y: currentPoint y - self viewOrigin y. |
|
465 |
]. |
|
2889 | 466 |
editMode == EditModePastUnder ifTrue:[ |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
467 |
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
|
468 |
] |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
469 |
] |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
470 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
471 |
lastPastePoint := currentPoint. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
472 |
|
3278 | 473 |
"Modified: / 20-11-2007 / 17:17:14 / cg" |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
474 |
! |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
475 |
|
662 | 476 |
fillFramedRectangle: aRectangle |
477 |
||
478 |
self fillRectangle: aRectangle. |
|
479 |
self drawFramesIn: aRectangle |
|
480 |
! |
|
481 |
||
1449 | 482 |
redraw:aRectangle |
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
483 |
self |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
484 |
invalidate:(aRectangle origin "+ self viewOrigin" extent:aRectangle extent) |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
485 |
repairNow:true. |
1449 | 486 |
|
2053
5c19fe5b2db3
invalidate rather than redraw
Claus Gittinger <cg@exept.de>
parents:
2034
diff
changeset
|
487 |
"Modified: / 15.11.2001 / 16:43:53 / cg" |
1449 | 488 |
! |
489 |
||
627 | 490 |
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
|
491 |
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
|
492 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
493 |
"Modified: / 18.5.1999 / 20:14:03 / cg" |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
494 |
! |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
495 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
496 |
redrawImageX:x y:y width:w height:h unmaskedOnly:unmaskedOnly |
3319 | 497 |
"redraw the magnified (editing) view of the image" |
636 | 498 |
|
5413 | 499 |
self |
500 |
redrawImageX:x y:y width:w height:h |
|
501 |
unmaskedOnly:unmaskedOnly processColorsWith:[:colorIn | colorIn]. |
|
502 |
||
503 |
"Created: / 18.5.1999 / 20:13:39 / cg" |
|
504 |
"Modified: / 18.5.1999 / 20:36:20 / cg" |
|
505 |
! |
|
506 |
||
507 |
redrawImageX:x y:y width:w height:h unmaskedOnly:unmaskedOnly processColorsWith:aColorBlock |
|
508 |
"redraw the magnified (editing) view of the image" |
|
509 |
||
4233 | 510 |
|ih iw magX magY minX maxX minY maxY lastColor lastY runW x0 maskColor mask |
3476 | 511 |
sizeOfMaskPoint useNearestColor origin| |
1180 | 512 |
|
4999 | 513 |
useNearestColor := device visualType == #PseudoColor. |
627 | 514 |
|
1037 | 515 |
mask := image mask. |
627 | 516 |
ih := image height. |
517 |
iw := image width. |
|
662 | 518 |
magX := magnification x. |
519 |
magY := magnification y. |
|
627 | 520 |
|
662 | 521 |
minX := (x // magX - 1) max: 0. |
725 | 522 |
minX >= iw ifTrue:[minX := (iw - 1) max: 0]. |
662 | 523 |
minY := (y // magY - 1) max: 0. |
725 | 524 |
minY >= ih ifTrue:[minY := (ih - 1) max: 0]. |
662 | 525 |
maxX := (x + w) // magX + 1. |
627 | 526 |
maxX > iw ifTrue:[maxX := iw]. |
662 | 527 |
maxY := (y + h) // magY + 1. |
627 | 528 |
maxY > ih ifTrue:[maxY := ih]. |
529 |
||
530 |
lastY := -1. |
|
531 |
||
532 |
x0 := minX. |
|
533 |
runW := 0. |
|
534 |
maskColor := false. |
|
662 | 535 |
sizeOfMaskPoint := magnification//3. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
536 |
image |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
537 |
colorsFromX:minX y:minY toX:maxX-1 y:maxY-1 |
5413 | 538 |
do:[:xx :yy :colorIn| |
539 |
|color| |
|
540 |
||
541 |
color := aColorBlock value:colorIn. |
|
542 |
||
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
543 |
shown ifFalse:[^ self]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
544 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
545 |
yy ~~ lastY ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
546 |
runW ~~ 0 ifTrue:[ |
3476 | 547 |
origin := (x0 * magX + margin) @ (lastY * magY + margin). |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
548 |
(unmaskedOnly not or:[maskColor not]) ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
549 |
self fillFramedRectangle: (origin extent: (runW@magY)). |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
550 |
maskColor ifTrue:[ |
5432 | 551 |
gc xoring: [gc fillRectangle: (origin + sizeOfMaskPoint extent: sizeOfMaskPoint)] |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
552 |
] |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
553 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
554 |
runW := 0. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
555 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
556 |
x0 := xx. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
557 |
lastY := yy. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
558 |
]. |
1160 | 559 |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
560 |
color ~= lastColor ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
561 |
runW ~~ 0 ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
562 |
origin := (x0 * magX + margin)@(yy * magY + margin). |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
563 |
(unmaskedOnly not or:[maskColor not]) ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
564 |
self fillFramedRectangle: (origin extent: (runW@magY)). |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
565 |
maskColor ifTrue:[ |
5432 | 566 |
gc xoring: [gc fillRectangle: (origin + sizeOfMaskPoint extent: sizeOfMaskPoint)] |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
567 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
568 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
569 |
runW := 0. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
570 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
571 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
572 |
lastColor := color. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
573 |
useNearestColor ifTrue:[ |
4999 | 574 |
lastColor := lastColor nearestOn:device |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
575 |
]. |
5432 | 576 |
gc paint:lastColor. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
577 |
mask notNil ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
578 |
maskColor := false. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
579 |
(mask pixelAtX:xx y:yy) == 0 ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
580 |
unmaskedOnly ifFalse:[ |
5432 | 581 |
gc paint: (lastColor := self viewBackground). |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
582 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
583 |
maskColor := true. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
584 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
585 |
lastColor := nil. |
1160 | 586 |
]. |
587 |
runW := 0. |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
588 |
x0 := xx. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
589 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
590 |
runW := runW + magX |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
591 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
592 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
593 |
runW ~~ 0 ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
594 |
origin := (x0 * magX + margin)@(lastY * magY + margin). |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
595 |
(unmaskedOnly not or:[maskColor not]) ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
596 |
self fillFramedRectangle: (origin extent: runW@magY). |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
597 |
maskColor ifTrue:[ |
5432 | 598 |
gc xoring:[ |
599 |
gc fillRectangle: (origin + sizeOfMaskPoint extent: sizeOfMaskPoint) |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
600 |
] |
1180 | 601 |
]. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
602 |
] |
627 | 603 |
]. |
1037 | 604 |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
605 |
"Created: / 18.5.1999 / 20:13:39 / cg" |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
606 |
"Modified: / 18.5.1999 / 20:36:20 / cg" |
627 | 607 |
! |
608 |
||
609 |
redrawX:x y:y width:w height:h |
|
636 | 610 |
|
5413 | 611 |
|xI yI devImage imgWidth imgHeight mX mY magnifiedWidth magnifiedHeight| |
627 | 612 |
|
1037 | 613 |
image isNil ifTrue:[^self]. |
662 | 614 |
|
1037 | 615 |
magnification = (1@1) ifTrue: [ |
4212 | 616 |
Error handle:[:ex | |
2092 | 617 |
Transcript showCR:'cannot convert image: ', ex description. |
1510
fd0cd6065dc6
catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
618 |
] do:[ |
4999 | 619 |
devImage := image onDevice:device. |
1763
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
620 |
devImage ~~ image ifTrue:[ |
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
621 |
image := devImage. |
1764 | 622 |
self changed:#image. |
1763
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
623 |
]. |
1510
fd0cd6065dc6
catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
624 |
]. |
4999 | 625 |
image device == device ifTrue:[ |
5413 | 626 |
super redrawX:x y:y width:w height:h. |
627 |
self drawFrame. |
|
628 |
^ self. |
|
1510
fd0cd6065dc6
catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
629 |
]. |
1037 | 630 |
]. |
627 | 631 |
|
3476 | 632 |
"/ self clippingRectangle: (x@y extent:w@h). |
5413 | 633 |
"/ draw the image itself |
627 | 634 |
self redrawImageX:x y:y width:w height:h. |
635 |
||
4233 | 636 |
imgWidth := image width. |
637 |
imgHeight := image height. |
|
638 |
||
3476 | 639 |
"/ beyond of image ? |
5413 | 640 |
adjust == #center ifTrue:[ |
4233 | 641 |
xI := (width - imgWidth) // 2 - margin. |
642 |
yI := (height - imgHeight) // 2 - margin. |
|
5413 | 643 |
] ifFalse:[ |
1449 | 644 |
xI := yI := margin |
627 | 645 |
]. |
1967 | 646 |
|
5413 | 647 |
mX := magnification x. |
648 |
mY := magnification y. |
|
649 |
magnifiedWidth := mX * imgWidth. |
|
650 |
magnifiedHeight := mY * imgHeight. |
|
651 |
||
652 |
"/ draw the rest to the right and at the bottom |
|
653 |
(x + w - 1) > (xI + magnifiedWidth) ifTrue:[ |
|
654 |
self |
|
655 |
clearRectangleX:(xI + magnifiedWidth) y:y |
|
656 |
width:(x + w - magnifiedWidth - xI) height:h |
|
627 | 657 |
]. |
5413 | 658 |
(y + h - 1) > (yI + magnifiedHeight) ifTrue:[ |
659 |
self |
|
660 |
clearRectangleX:margin y:(yI + magnifiedHeight) |
|
661 |
width:w height:(y + h - magnifiedHeight - yI) |
|
627 | 662 |
]. |
663 |
self drawFrame. |
|
5413 | 664 |
self clippingBounds: nil. |
1037 | 665 |
|
666 |
"Modified: / 31.7.1998 / 02:22:45 / cg" |
|
3476 | 667 |
! |
668 |
||
669 |
startSpray |
|
670 |
spraySpot isNil ifTrue:[ |
|
671 |
spraySpot := 8 |
|
672 |
]. |
|
673 |
||
674 |
sprayProcess isNil ifTrue:[ |
|
675 |
sprayProcess := [ |
|
676 |
|p rnd norm sprayPoint dly angle x y dist| |
|
677 |
||
678 |
rnd := Random new. |
|
3477 | 679 |
Distributions::NormalDistribution notNil ifTrue:[ |
680 |
norm := Distributions::NormalDistribution mean:0 deviation:0.5. |
|
681 |
]. |
|
3487 | 682 |
dly := Delay forMilliseconds:20. |
3476 | 683 |
[true] whileTrue:[ |
684 |
10 timesRepeat:[ |
|
685 |
p := sprayPosition. |
|
686 |
p notNil ifTrue:[ |
|
687 |
angle := rnd next * 359.999. "/ the angle is uniformly ditributed |
|
3477 | 688 |
norm notNil ifTrue:[ |
689 |
dist := norm next * spraySpot. "/ the distance is a normalDistribution |
|
690 |
] ifFalse:[ |
|
691 |
dist := (rnd nextBetween:-1 and:1) * spraySpot. |
|
692 |
]. |
|
3476 | 693 |
sprayPoint := (Point r:dist degrees:angle)*magnification. |
694 |
||
695 |
x := p x + sprayPoint x truncated. |
|
696 |
y := p y + sprayPoint y truncated. |
|
4111 | 697 |
self pointAt:(x@y) width:1. |
3476 | 698 |
]. |
699 |
]. |
|
700 |
dly wait. |
|
701 |
]. |
|
702 |
] fork. |
|
703 |
] |
|
704 |
||
4111 | 705 |
"Modified: / 15-02-2012 / 22:44:54 / cg" |
3476 | 706 |
! |
707 |
||
708 |
stopSpray |
|
709 |
sprayProcess notNil ifTrue:[ |
|
710 |
sprayProcess terminate. |
|
711 |
sprayProcess := nil |
|
712 |
]. |
|
627 | 713 |
! ! |
714 |
||
715 |
!ImageEditView methodsFor:'edit modes'! |
|
716 |
||
717 |
editMode |
|
5413 | 718 |
"is one of the edit modes: |
719 |
||
720 |
EditModePoint |
|
721 |
EditModeBox |
|
722 |
EditModePaste |
|
723 |
EditModePasteUnder |
|
724 |
EditModePasteWithMask |
|
725 |
EditModeFilledBox |
|
726 |
EditModeFill |
|
727 |
EditModeCopy |
|
728 |
EditModeSpecialOperation |
|
729 |
EditModeSpray |
|
730 |
EditModeCircle |
|
731 |
EditModeSmooth |
|
732 |
" |
|
627 | 733 |
|
1106 | 734 |
^editMode |
627 | 735 |
! |
736 |
||
2440 | 737 |
editMode: anEditModeSymbol |
2889 | 738 |
"must be one of the edit modes: |
739 |
||
740 |
EditModePoint |
|
741 |
EditModeBox |
|
742 |
EditModePaste |
|
743 |
EditModePasteUnder |
|
744 |
EditModePasteWithMask |
|
745 |
EditModeFilledBox |
|
746 |
EditModeFill |
|
747 |
EditModeCopy |
|
748 |
EditModeSpecialOperation |
|
3476 | 749 |
EditModeSpray |
750 |
EditModeCircle |
|
4715 | 751 |
EditModeSmooth |
2889 | 752 |
" |
627 | 753 |
|
2440 | 754 |
editMode := anEditModeSymbol |
627 | 755 |
! |
756 |
||
757 |
mouseKeyColorMode |
|
758 |
||
759 |
^mouseKeyColorMode printString |
|
760 |
! |
|
761 |
||
762 |
mouseKeyColorMode:aMode |
|
763 |
||
1106 | 764 |
mouseKeyColorMode := aMode |
627 | 765 |
! ! |
766 |
||
767 |
!ImageEditView methodsFor:'event handling'! |
|
768 |
||
769 |
buttonMotion:state x:x y:y |
|
1693 | 770 |
|p| |
771 |
||
2072
abd4e246f393
care for negative pos in buttonMotion (win32 klusge)
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
772 |
(x < 0 or:[y < 0]) ifTrue:[ |
abd4e246f393
care for negative pos in buttonMotion (win32 klusge)
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
773 |
^ self |
abd4e246f393
care for negative pos in buttonMotion (win32 klusge)
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
774 |
]. |
5413 | 775 |
"/ readOnly ifTrue:[^ self]. |
2072
abd4e246f393
care for negative pos in buttonMotion (win32 klusge)
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
776 |
|
1693 | 777 |
p := x@y. |
778 |
||
779 |
state ~~ 0 ifTrue:[ |
|
3476 | 780 |
"/ button down |
781 |
||
782 |
"/ self selectedColor notNil ifTrue:[ |
|
783 |
(self imageContainsPoint:p) ifTrue:[ |
|
784 |
(editMode == EditModePoint) ifTrue:[ |
|
785 |
self pointAt:p. |
|
786 |
^ self |
|
787 |
]. |
|
4715 | 788 |
(editMode == EditModeSmooth) ifTrue:[ |
789 |
self smoothAt:p. |
|
790 |
^ self |
|
791 |
]. |
|
3476 | 792 |
sprayProcess notNil ifTrue:[ |
793 |
sprayPosition := p. |
|
794 |
^ self |
|
795 |
]. |
|
1246 | 796 |
]. |
1693 | 797 |
self drawCursorAt:p. |
3476 | 798 |
^ self |
799 |
]. |
|
800 |
||
5413 | 801 |
"/ button is up (care for paste-mode, dragging the pasted image) |
3476 | 802 |
self drawCursorAt:p. |
803 |
self inPasteMode ifTrue: [ |
|
804 |
self sensor shiftDown ifTrue:[ |
|
805 |
p := p - Clipboard extent |
|
806 |
]. |
|
807 |
("self selectedColor notNil" true and: [self imageContainsPastePoint:p]) |
|
3729 | 808 |
ifTrue:[ |
3476 | 809 |
(self sensor hasButtonMotionEventFor:self) ifFalse:[ |
810 |
self drawPasteRectangleAt:p]] |
|
811 |
ifFalse: [self cursor:Cursor stop. self releasePasteDrawing] |
|
686 | 812 |
] |
1019
e68414752bc9
only change the cursor for myself.
Claus Gittinger <cg@exept.de>
parents:
1013
diff
changeset
|
813 |
|
4041 | 814 |
"Modified: / 03-05-2011 / 12:26:54 / cg" |
624 | 815 |
! |
255 | 816 |
|
627 | 817 |
buttonPress:button x:x y:y |
2889 | 818 |
|p clr masked| |
627 | 819 |
|
1693 | 820 |
p := x@y. |
821 |
||
3278 | 822 |
self inPasteMode ifTrue:[ |
823 |
self sensor shiftDown ifTrue:[ |
|
824 |
p := p - Clipboard extent |
|
825 |
] |
|
826 |
]. |
|
827 |
||
1693 | 828 |
self drawCursorAt:p. |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
829 |
|
1246 | 830 |
("self selectedColor notNil" true |
1693 | 831 |
and: [self imageContainsPoint:p]) |
1246 | 832 |
ifTrue:[ |
3278 | 833 |
(self inPasteMode not |
834 |
and:[self sensor shiftDown]) ifTrue:[ |
|
2277 | 835 |
(image maskAt:(p // magnification)) == 0 ifTrue:[ |
836 |
masked := true. |
|
837 |
] ifFalse:[ |
|
838 |
masked := false. |
|
839 |
clr := image colorAt:(p // magnification). |
|
840 |
]. |
|
1246 | 841 |
pickedColorHolder notNil ifTrue:[ |
842 |
"/ select the color under the cursor, place it into the |
|
843 |
"/ pickedColorHolder/ |
|
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
844 |
pickedColorHolder value:clr. |
1246 | 845 |
]. |
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
846 |
self selectedColor:clr. |
2277 | 847 |
masked ifTrue:[self selectedColorIndex:nil]. |
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
848 |
self changed:#selectedColor with:clr. |
1246 | 849 |
] ifFalse:[ |
5413 | 850 |
(readOnly not |
851 |
or:[editMode == EditModeCopy |
|
852 |
or:[editMode == EditModeSpecialOperation]] |
|
853 |
) ifTrue:[ |
|
4853 | 854 |
(button between:1 and:2) ifTrue:[ |
855 |
mouseKeyColorMode := button. |
|
856 |
self makeUndo. |
|
857 |
||
858 |
clickInfoCallBack notNil ifTrue:[ |
|
859 |
"/ still a kludge, but less ugly ... |
|
860 |
clickInfoCallBack value:button value:p |
|
861 |
]. |
|
862 |
"/ editMode is something like #point, #rectangle etc. |
|
863 |
[ |
|
864 |
self perform: (editMode, 'At:') asSymbol with:p |
|
865 |
] on:Error do:[:ex | |
|
866 |
(Dialog confirm:('Error during operation: ', ex description,'\\Debug ?') withCRs ) |
|
867 |
ifTrue:[ |
|
868 |
ex reject |
|
869 |
]. |
|
4041 | 870 |
]. |
2889 | 871 |
]. |
872 |
]. |
|
1246 | 873 |
] |
686 | 874 |
] |
995 | 875 |
|
4041 | 876 |
"Modified: / 03-05-2011 / 12:26:06 / cg" |
632 | 877 |
! |
878 |
||
994
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
879 |
buttonRelease:button x:x y:y |
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
880 |
|
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
881 |
self drawCursorAt: x@y. |
4041 | 882 |
readOnly ifTrue:[^ self]. |
1246 | 883 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
884 |
("self selectedColor notNil" true and: [self imageContainsPoint: x@y]) |
3476 | 885 |
ifTrue: [ |
886 |
sprayProcess notNil ifTrue:[ |
|
887 |
self stopSpray |
|
888 |
]. |
|
889 |
||
1763
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
890 |
image release. |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
891 |
|
1693 | 892 |
"/ "/ cg: what a kludge - please change to use a valueHolder, |
893 |
"/ "/ which gets the information ... |
|
894 |
"/ masterApplication imagePreView invalidate. |
|
895 |
||
896 |
"/ cg: still a kludge - but less ugly |
|
897 |
self changed:#subImageIn with:(image bounds). |
|
994
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
898 |
] |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
899 |
|
4041 | 900 |
"Modified: / 03-05-2011 / 12:26:31 / cg" |
994
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
901 |
! |
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
902 |
|
2508 | 903 |
inPasteMode |
2889 | 904 |
^ (editMode notNil and:[editMode startsWith:#paste]) |
2508 | 905 |
! |
906 |
||
5277 | 907 |
keyboardZoom:larger |
908 |
larger ifTrue:[ |
|
909 |
self magnification: ((magnification + 1) min:63) |
|
910 |
] ifFalse:[ |
|
911 |
self magnification: ((magnification - 1) max:1) |
|
912 |
]. |
|
913 |
! |
|
914 |
||
686 | 915 |
pointerLeave:state |
916 |
||
688 | 917 |
super pointerLeave: state. |
686 | 918 |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
919 |
self updateImageInfo: self imageInfoString. |
1019
e68414752bc9
only change the cursor for myself.
Claus Gittinger <cg@exept.de>
parents:
1013
diff
changeset
|
920 |
self cursor:Cursor normal. |
995 | 921 |
|
2508 | 922 |
self inPasteMode ifTrue: [ |
1246 | 923 |
self releasePasteDrawing |
924 |
] |
|
995 | 925 |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
926 |
"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
|
927 |
! ! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
928 |
|
636 | 929 |
!ImageEditView methodsFor:'image editing'! |
627 | 930 |
|
931 |
boxAt: aPoint |
|
5413 | 932 |
"drag a rectangular outline, |
933 |
when released draw a rectangle with the currently selected color" |
|
627 | 934 |
|
3610
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
935 |
|choosenBox imageBox clr pix| |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
936 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
937 |
(clr := self selectedColor) notNil ifTrue:[ |
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
938 |
choosenBox := self dragRectangleStartingAt: aPoint emphasis: #box. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
939 |
choosenBox notNil ifTrue:[ |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
940 |
imageBox := choosenBox origin//magnification extent: (choosenBox extent//magnification). |
3610
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
941 |
image colorMap isNil ifTrue:[ |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
942 |
image drawRectangle:imageBox withColor:clr. |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
943 |
] ifFalse:[ |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
944 |
pix := self selectedColorIndex. |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
945 |
image drawRectangle:imageBox withValue:pix. |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
946 |
]. |
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
947 |
image restored. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
948 |
self redraw: (choosenBox expandedBy: 1). |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
949 |
|
1693 | 950 |
"/ "/ cg: what a kludge - please change to use a valueHolder, |
951 |
"/ "/ which gets the information ... |
|
952 |
"/ masterApplication imagePreView redraw: (imageBox expandedBy: 1). |
|
953 |
||
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
954 |
"/ cg: still a kludge - but less ugly |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
955 |
self changed:#subImageIn with:(imageBox expandedBy: 1). |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
956 |
|
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
957 |
self setModified. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
958 |
]. |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
959 |
]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
960 |
|
1693 | 961 |
"Modified: / 10.2.2000 / 23:42:08 / cg" |
632 | 962 |
! |
963 |
||
3476 | 964 |
circleAt: aPoint |
5413 | 965 |
"drag an ellipse, |
966 |
when released draw an ellipse with the currently selected color" |
|
3476 | 967 |
|
3610
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
968 |
|choosenBox imageBox clr pix| |
3476 | 969 |
|
970 |
(clr := self selectedColor) notNil ifTrue:[ |
|
971 |
choosenBox := self dragRectangleStartingAt: aPoint emphasis: #box. |
|
972 |
choosenBox notNil ifTrue:[ |
|
973 |
imageBox := choosenBox origin//magnification extent: (choosenBox extent//magnification). |
|
3610
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
974 |
image colorMap isNil ifTrue:[ |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
975 |
image drawEllipse:imageBox withColor:clr. |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
976 |
] ifFalse:[ |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
977 |
pix := self selectedColorIndex. |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
978 |
image drawEllipse:imageBox withValue:pix. |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
979 |
]. |
3476 | 980 |
image restored. |
981 |
self redraw: (choosenBox expandedBy: 1). |
|
982 |
||
983 |
"/ cg: still a kludge - but less ugly |
|
984 |
self changed:#subImageIn with:(imageBox expandedBy: 1). |
|
985 |
||
986 |
self setModified. |
|
987 |
]. |
|
988 |
]. |
|
989 |
||
990 |
"Modified: / 10.2.2000 / 23:42:08 / cg" |
|
991 |
! |
|
992 |
||
632 | 993 |
copyAt: aPoint |
5413 | 994 |
"drag a filled box, |
995 |
when released copy the selected rectangle to the clipboard" |
|
996 |
||
3696 | 997 |
|choosenBox box copiedImage| |
1084
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
998 |
|
1449 | 999 |
choosenBox := self dragRectangleStartingAt: aPoint emphasis: #inverseFilledBox. |
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1000 |
choosenBox notNil ifTrue:[ |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1001 |
box := choosenBox origin // magnification extent: (choosenBox extent // magnification). |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1002 |
copiedImage := image subImageIn: box. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1003 |
|
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1004 |
self class copyImageToClipboard:copiedImage. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1005 |
|
3696 | 1006 |
self redraw:(choosenBox expandedBy:1) |
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1007 |
] |
632 | 1008 |
|
1084
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
1009 |
"Modified: / 21.8.1998 / 20:16:41 / cg" |
632 | 1010 |
! |
1011 |
||
2480 | 1012 |
copyImageToClipboard |
1013 |
self class copyImageToClipboard:image. |
|
4264 | 1014 |
self setClipboardObject:image. |
2480 | 1015 |
! |
1016 |
||
1228 | 1017 |
cropLeft:doLeft right:doRight top:doTop bottom:doBottom |
1121 | 1018 |
|yMinNew yMaxNew xMinNew xMaxNew |
5093 | 1019 |
pix stillCropping xMax yMax| |
1121 | 1020 |
|
1021 |
xMax := image width - 1. |
|
1022 |
yMax := image height - 1. |
|
1023 |
||
1024 |
xMinNew := 0. |
|
1025 |
doLeft ifTrue:[ |
|
1026 |
pix := image pixelAtX:xMinNew y:0. |
|
5093 | 1027 |
stillCropping := true. |
1028 |
[stillCropping] whileTrue:[ |
|
1121 | 1029 |
0 to:yMax do:[:y | |
1030 |
(image pixelAtX:xMinNew y:y) ~~ pix ifTrue:[ |
|
5093 | 1031 |
stillCropping := false |
1121 | 1032 |
] |
1033 |
]. |
|
5093 | 1034 |
stillCropping ifTrue:[ |
1121 | 1035 |
xMinNew := xMinNew + 1. |
1036 |
xMinNew >= image width ifTrue:[ |
|
5093 | 1037 |
self warn:(resources string:'Image is all the same color - no crop.'). |
1121 | 1038 |
^ self |
1039 |
] |
|
1040 |
]. |
|
1041 |
]. |
|
1042 |
]. |
|
1043 |
||
1044 |
xMaxNew := xMax. |
|
1045 |
doRight ifTrue:[ |
|
5093 | 1046 |
stillCropping := true. |
1121 | 1047 |
pix := image pixelAtX:xMaxNew y:0. |
5093 | 1048 |
[stillCropping] whileTrue:[ |
1121 | 1049 |
0 to:yMax do:[:y | |
1050 |
(image pixelAtX:xMaxNew y:y) ~~ pix ifTrue:[ |
|
5093 | 1051 |
stillCropping := false |
1121 | 1052 |
] |
1053 |
]. |
|
5093 | 1054 |
stillCropping ifTrue:[ |
1121 | 1055 |
xMaxNew := xMaxNew - 1. |
1056 |
]. |
|
1057 |
]. |
|
1058 |
]. |
|
1059 |
||
1060 |
yMinNew := 0. |
|
1061 |
doTop ifTrue:[ |
|
1062 |
pix := image pixelAtX:xMinNew y:yMinNew. |
|
5093 | 1063 |
stillCropping := true. |
1064 |
[stillCropping] whileTrue:[ |
|
1121 | 1065 |
xMinNew to:xMaxNew do:[:x | |
1066 |
(image pixelAtX:x y:yMinNew) ~~ pix ifTrue:[ |
|
5093 | 1067 |
stillCropping := false |
1121 | 1068 |
] |
1069 |
]. |
|
5093 | 1070 |
stillCropping ifTrue:[ |
1121 | 1071 |
yMinNew := yMinNew + 1. |
1072 |
]. |
|
1073 |
]. |
|
1074 |
]. |
|
1075 |
||
1076 |
yMaxNew := yMax. |
|
1077 |
doRight ifTrue:[ |
|
5093 | 1078 |
stillCropping := true. |
1121 | 1079 |
pix := image pixelAtX:xMaxNew y:yMaxNew. |
5093 | 1080 |
[stillCropping] whileTrue:[ |
1121 | 1081 |
xMinNew to:xMaxNew do:[:x | |
1082 |
(image pixelAtX:x y:yMaxNew) ~~ pix ifTrue:[ |
|
5093 | 1083 |
stillCropping := false |
1121 | 1084 |
] |
1085 |
]. |
|
5093 | 1086 |
stillCropping ifTrue:[ |
1121 | 1087 |
yMaxNew := yMaxNew - 1. |
1088 |
]. |
|
1089 |
]. |
|
1090 |
]. |
|
1091 |
||
1092 |
(xMinNew == 0 |
|
1093 |
and:[xMaxNew == (image width - 1) |
|
1094 |
and:[yMinNew == 0 |
|
1095 |
and:[yMaxNew == (image height - 1)]]]) ifTrue:[ |
|
5061 | 1096 |
self warn:(resources string:'No border found - no crob.'). |
1121 | 1097 |
^ self |
1098 |
]. |
|
1099 |
||
1100 |
"/ self warn:'extract subImage ' |
|
1101 |
"/ , (xMinNew @ yMinNew) printString |
|
1102 |
"/ , ' -> ' |
|
1103 |
"/ , (xMaxNew @ yMaxNew) printString. |
|
1104 |
||
2006 | 1105 |
self makeUndo. |
1121 | 1106 |
self |
1107 |
makeSubImageX:xMinNew y:yMinNew |
|
1108 |
width:(xMaxNew - xMinNew + 1) |
|
1109 |
height:(yMaxNew - yMinNew + 1) |
|
1110 |
||
1111 |
"Created: / 7.9.1998 / 14:25:52 / cg" |
|
1112 |
"Modified: / 7.9.1998 / 16:35:35 / cg" |
|
1113 |
! |
|
1114 |
||
632 | 1115 |
fillAt: aPoint |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1116 |
"perform a flood-fill with the currently selected color" |
627 | 1117 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1118 |
windowGroup withExecuteCursorDo:[ |
1693 | 1119 |
|filledPoints clr| |
1002 | 1120 |
|
1693 | 1121 |
(clr := self selectedColor) notNil ifTrue:[ |
1122 |
self updateActivity:'Flood filling - press CTRL-y to abort ...'. |
|
1123 |
[ |
|
3610
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
1124 |
|pix fillColor| |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
1125 |
|
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
1126 |
image colorMap isNil ifTrue:[ |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
1127 |
image floodFillAt: aPoint//magnification withColor:clr. |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
1128 |
] ifFalse:[ |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
1129 |
pix := self selectedColorIndex. |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
1130 |
image floodFillAt:aPoint//magnification withValue:pix. |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
1131 |
]. |
1693 | 1132 |
image restored. |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
1133 |
|
2349 | 1134 |
self invalidate. |
1693 | 1135 |
self changed:#subImageIn with:(image bounds). |
1136 |
||
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1137 |
self setModified. |
4129
65e5f7358a70
changed: #fillAt: use #ifCurtailed:
Stefan Vogel <sv@exept.de>
parents:
4111
diff
changeset
|
1138 |
] ifCurtailed:[ |
1693 | 1139 |
self updateActivity:'Flood fill aborted.' |
1140 |
]. |
|
1141 |
]. |
|
1142 |
self updateActivity:'' |
|
632 | 1143 |
] |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1144 |
|
1693 | 1145 |
"Modified: / 10.2.2000 / 23:40:58 / cg" |
632 | 1146 |
! |
1147 |
||
1148 |
filledBoxAt: aPoint |
|
5413 | 1149 |
"drag a filled box, |
1150 |
when released fill a rectangular area with the currently selected color" |
|
632 | 1151 |
|
4233 | 1152 |
|choosenBox imageBox clr pix| |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
1153 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1154 |
(clr := self selectedColor) notNil ifTrue:[ |
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1155 |
choosenBox := self dragRectangleStartingAt: aPoint emphasis: #filledBox. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1156 |
choosenBox notNil ifTrue:[ |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1157 |
imageBox := choosenBox origin//magnification extent: (choosenBox extent//magnification). |
3610
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
1158 |
|
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
1159 |
image colorMap isNil ifTrue:[ |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
1160 |
image fillRectangle:imageBox withColor:clr. |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
1161 |
] ifFalse:[ |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
1162 |
pix := self selectedColorIndex. |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
1163 |
image fillRectangle:imageBox withValue:pix. |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
1164 |
"/ maskVal := pix isNil ifTrue:[0] ifFalse:[1]. |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
1165 |
"/ image mask notNil ifTrue:[ |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
1166 |
"/ image mask fillRectangle:imageBox withValue:maskVal |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
1167 |
"/ ]. |
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
1168 |
]. |
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1169 |
image restored. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1170 |
self redraw: (choosenBox expandedBy: 1). |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1171 |
|
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1172 |
self changed:#subImageIn with:(imageBox expandedBy: 1). |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1173 |
self setModified. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1174 |
] |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1175 |
] |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1176 |
|
1693 | 1177 |
"Modified: / 10.2.2000 / 23:37:04 / cg" |
632 | 1178 |
! |
1179 |
||
4032 | 1180 |
flipSubImage:how in:imageBox |
1181 |
"/ now, do it |
|
4624 | 1182 |
"/ caveat: this should go into image class |
4032 | 1183 |
|
1184 |
|x0 y0 x1 y1 image t| |
|
1185 |
||
4623 | 1186 |
self makeUndo. |
1187 |
||
4032 | 1188 |
x0 := imageBox left. |
1189 |
y0 := imageBox top. |
|
1190 |
x1 := imageBox right-1. |
|
1191 |
y1 := imageBox bottom-1. |
|
1192 |
||
1193 |
image := self image. |
|
1194 |
||
1195 |
how == #vertical ifTrue:[ |
|
1196 |
0 to:((y1-y0)//2) do:[:dy | |
|
1197 |
x0 to:x1 do:[:x | |
|
1198 |
t := image pixelAtX:x y:(y0+dy). |
|
1199 |
image pixelAtX:x y:(y0+dy) put:(image pixelAtX:x y:(y1-dy)). |
|
1200 |
image pixelAtX:x y:(y1-dy) put:t. |
|
4624 | 1201 |
image mask notNil ifTrue:[ |
1202 |
t := image maskAtX:x y:(y0+dy). |
|
1203 |
image maskAtX:x y:(y0+dy) put:(image maskAtX:x y:(y1-dy)). |
|
1204 |
image maskAtX:x y:(y1-dy) put:t. |
|
1205 |
]. |
|
4032 | 1206 |
]. |
1207 |
] |
|
1208 |
] ifFalse:[ |
|
1209 |
0 to:((x1-x0)//2) do:[:dx | |
|
1210 |
y0 to:y1 do:[:y | |
|
1211 |
t := image pixelAtX:(x0+dx) y:y. |
|
1212 |
image pixelAtX:(x0+dx) y:y put:(image pixelAtX:(x1-dx) y:y). |
|
1213 |
image pixelAtX:(x1-dx) y:y put:t. |
|
4623 | 1214 |
|
4624 | 1215 |
image mask notNil ifTrue:[ |
1216 |
t := image maskAtX:(x0+dx) y:y. |
|
1217 |
image maskAtX:(x0+dx) y:y put:(image maskAtX:(x1-dx) y:y). |
|
1218 |
image maskAtX:(x1-dx) y:y put:t. |
|
1219 |
]. |
|
4032 | 1220 |
]. |
1221 |
] |
|
1222 |
]. |
|
1223 |
||
1224 |
self setModified. |
|
1225 |
||
1226 |
"Created: / 07-04-2011 / 09:34:23 / cg" |
|
1227 |
! |
|
1228 |
||
4723 | 1229 |
magnifyAntiAliasedImageTo:newSize |
4730 | 1230 |
self newImageWithUndo: (image hardAntiAliasedMagnifiedBy: newSize/image extent). |
4723 | 1231 |
! |
1232 |
||
1706 | 1233 |
magnifyImageTo:newSize |
4730 | 1234 |
self newImageWithUndo: (image magnifiedBy: newSize/image extent). |
636 | 1235 |
! |
1236 |
||
2168 | 1237 |
makeNewColorMapByMapping:functionOfColor |
2566
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1238 |
|xMax yMax map revMap anyChange |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1239 |
newColors newColorArray newImage pixelAction| |
2168 | 1240 |
|
1886 | 1241 |
anyChange := false. |
1242 |
||
1243 |
xMax := image width - 1. |
|
1244 |
yMax := image height - 1. |
|
1245 |
||
1246 |
newImage := image class width:image width height:image height depth:image depth. |
|
1247 |
newImage photometric:image photometric. |
|
2489 | 1248 |
"/ newImage colorMap:(image colorMap copy). |
1886 | 1249 |
newImage bits:(ByteArray new:(image bits size)). |
1250 |
newImage mask:(image mask copy). |
|
1251 |
||
2566
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1252 |
image colorMap notNil ifTrue:[ |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1253 |
newColors := Set new. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1254 |
newColorArray := OrderedCollection new. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1255 |
map := Array new:256. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1256 |
revMap := OrderedCollection new. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1257 |
|
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1258 |
pixelAction := |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1259 |
[:x :y | |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1260 |
|pix n_pix clr n_clr| |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1261 |
|
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1262 |
pix := image pixelAtX:x y:y. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1263 |
(n_pix := map at:pix+1) isNil ifTrue:[ |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1264 |
clr := image colorAtX:x y:y. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1265 |
n_clr := functionOfColor value:clr. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1266 |
(newColors includes:n_clr) ifFalse:[ |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1267 |
newColors add:n_clr. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1268 |
newColorArray add:n_clr. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1269 |
revMap add:pix. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1270 |
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
|
1271 |
] ifTrue:[ |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1272 |
"/ mhmh - multiple pixels mapped to the same color |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1273 |
n_pix := (newColorArray indexOf:n_clr) - 1. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1274 |
map at:pix+1 put:n_pix. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1275 |
] |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1276 |
]. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1277 |
newImage pixelAtX:x y:y put:n_pix. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1278 |
]. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1279 |
] ifFalse:[ |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1280 |
pixelAction := |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1281 |
[:x :y | |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1282 |
|
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1283 |
|clr n_clr| |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1284 |
|
1886 | 1285 |
clr := image colorAtX:x y:y. |
2168 | 1286 |
n_clr := functionOfColor value:clr. |
2566
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1287 |
newImage colorAtX:x y:y put:n_clr. |
1886 | 1288 |
]. |
2566
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1289 |
]. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1290 |
|
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1291 |
0 to:yMax do:[:y | |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1292 |
0 to:xMax do:[:x | |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1293 |
pixelAction value:x value:y |
1886 | 1294 |
] |
1295 |
]. |
|
1296 |
||
2566
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1297 |
image colorMap notNil ifTrue:[ |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1298 |
newImage colorMap:(MappedPalette withColors:newColorArray). |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
1299 |
]. |
4730 | 1300 |
self newImageWithUndo:newImage. |
1886 | 1301 |
^ true |
1302 |
! |
|
1303 |
||
1121 | 1304 |
makeSubImageX:oldX y:oldY width:newWidth height:newHeight |
3706 | 1305 |
|oldWidth oldHeight newImage newMaskImage needRedraw redrawRect1 redrawRect2 | |
1306 |
||
1307 |
oldWidth := image width. |
|
1308 |
oldHeight := image height. |
|
1309 |
self assert:(newWidth <= oldWidth). |
|
1310 |
self assert:(newHeight <= oldHeight). |
|
1121 | 1311 |
|
1312 |
newImage := image class width:newWidth height:newHeight depth:image depth. |
|
1313 |
newImage photometric:image photometric. |
|
1314 |
newImage colorMap:image colorMap copy. |
|
1315 |
newImage bits:(ByteArray new:(newImage bytesPerRow * newHeight)). |
|
1316 |
||
3706 | 1317 |
image mask notNil ifTrue:[ |
1121 | 1318 |
newMaskImage := Depth1Image width:newWidth height:newHeight. |
1319 |
newMaskImage photometric: image mask photometric. |
|
1320 |
newMaskImage colorMap: image mask colorMap copy. |
|
1321 |
newMaskImage bits:(ByteArray new: newMaskImage bytesPerRow * newHeight). |
|
1322 |
newImage mask: newMaskImage |
|
1323 |
]. |
|
1324 |
||
1325 |
newImage copyFrom:image x:oldX y:oldY toX:0 y:0 width:newWidth height:newHeight. |
|
3706 | 1326 |
|
1327 |
needRedraw := true. |
|
1328 |
(oldX == 0 and:[oldY == 0]) ifTrue:[ |
|
1329 |
needRedraw := false. |
|
5332 | 1330 |
redrawRect1 := ((newWidth@0) * magnification) corner:(((oldWidth@oldHeight)+1) * magnification). |
1331 |
redrawRect2 := ((0@newHeight) * magnification) corner:(((oldWidth@oldHeight)+1) * magnification). |
|
3706 | 1332 |
]. |
1333 |
self image:newImage scroll:false invalidate:needRedraw. |
|
1334 |
redrawRect1 notNil ifTrue:[ |
|
1335 |
self invalidateRectangle:redrawRect1 repairNow:false. |
|
1336 |
]. |
|
1337 |
redrawRect2 notNil ifTrue:[ |
|
1338 |
self invalidateRectangle:redrawRect2 repairNow:false. |
|
1339 |
]. |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1340 |
self setModified. |
1121 | 1341 |
|
5332 | 1342 |
"Created: / 07-09-1998 / 13:00:16 / cg" |
1343 |
"Modified: / 07-09-1998 / 14:15:32 / cg" |
|
1344 |
"Modified (format): / 16-11-2016 / 23:07:50 / cg" |
|
1121 | 1345 |
! |
1346 |
||
2915 | 1347 |
makeUndo |
1348 |
image notNil ifTrue:[ |
|
3278 | 1349 |
[undoImages size >= MaxUndos] whileTrue:[ |
2915 | 1350 |
undoImages removeFirst. |
1351 |
]. |
|
3610
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
1352 |
undoImages add:image copy |
2915 | 1353 |
] |
3278 | 1354 |
|
1355 |
"Modified: / 20-11-2007 / 17:26:50 / cg" |
|
2915 | 1356 |
! |
1357 |
||
636 | 1358 |
pasteAt: aPoint |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1359 |
"paste the image in the clipboard at aPoint" |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1360 |
|
2135 | 1361 |
self pasteAt:aPoint mode:nil. |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1362 |
! |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1363 |
|
2135 | 1364 |
pasteAt: aPoint mode:modeSymbol |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1365 |
"paste the image in the clipboard at aPoint" |
636 | 1366 |
|
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1367 |
|answer anyColorMissing choosenBox imagePoint imgX imgY copiedImage imageBox newColorMap |
2764 | 1368 |
existingColors newColors allColors currentColorMap newColormap anyColorAdded oldColorMap| |
1888 | 1369 |
|
4203 | 1370 |
Error handle:[:ex| |
1371 |
ex creator == Image unrepresentableColorSignal ifFalse:[ |
|
1246 | 1372 |
ex reject |
1373 |
]. |
|
1374 |
self undo. |
|
5061 | 1375 |
self warn:(resources stringWithCRs:'Paste failed !!\Increasing the images depth might help.'). |
1823 | 1376 |
] do: [ |
1246 | 1377 |
windowGroup withExecuteCursorDo:[ |
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1378 |
choosenBox := self dragRectangleStartingAt: aPoint emphasis: #inverseFilledBox. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1379 |
choosenBox isNil ifTrue:[ ^ self ]. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1380 |
|
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1381 |
imagePoint := choosenBox origin//magnification. |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1382 |
|
1246 | 1383 |
copiedImage := Clipboard copy. |
5417 | 1384 |
copiedImage isNil ifTrue:[^ self]. |
1385 |
||
2440 | 1386 |
true "/ image photometric == #palette |
1888 | 1387 |
ifTrue:[ |
1246 | 1388 |
"/ for all colors in the pasted image, |
1389 |
"/ check, if its in the colormap of the |
|
1390 |
"/ target image. |
|
995 | 1391 |
|
2764 | 1392 |
anyColorMissing := anyColorAdded := false. |
1393 |
oldColorMap := image colorMap. |
|
1394 |
oldColorMap notNil ifTrue:[ |
|
1395 |
newColorMap := oldColorMap asOrderedCollection. |
|
1957
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1396 |
copiedImage usedValues do:[:pixel | |
2764 | 1397 |
|pastedColor | |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1398 |
|
1957
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1399 |
pastedColor := copiedImage colorFromValue:pixel. |
2764 | 1400 |
|
3762 | 1401 |
(newColorMap includes:pastedColor) ifFalse:[ |
2764 | 1402 |
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
|
1403 |
"/ add to colormap |
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1404 |
newColorMap add:pastedColor. |
2764 | 1405 |
anyColorAdded := true. |
1957
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1406 |
"/ 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
|
1407 |
] ifFalse:[ |
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1408 |
"/ Transcript showCR:'color:' , pastedColor displayString , ' not found in targets colorMap'. |
1987 | 1409 |
"/ copiedImage colorMap notNil ifTrue:[ |
1410 |
"/ copiedImage colorMap at: pixel+1 put: Color black. |
|
1411 |
"/ ]. |
|
1957
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1412 |
anyColorMissing := true. |
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1413 |
] |
1246 | 1414 |
] |
1957
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1415 |
]. |
1246 | 1416 |
]. |
2764 | 1417 |
|
1888 | 1418 |
anyColorMissing ifTrue:[ |
1419 |
answer := Dialog |
|
5061 | 1420 |
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
|
1421 |
labels:#( 'Cancel' 'New ColorMap' 'Use Nearest' ) |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1422 |
values:#( nil new nearest) |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1423 |
default:3. |
1888 | 1424 |
|
1425 |
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
|
1426 |
|
630db3277f10
support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents:
1980
diff
changeset
|
1427 |
currentColorMap := image colorMap. |
1987 | 1428 |
imgX := imagePoint x. |
1429 |
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
|
1430 |
|
1888 | 1431 |
answer == #nearest ifTrue:[ |
1432 |
0 to:copiedImage height-1 do:[:y | |
|
1433 |
0 to:copiedImage width-1 do:[:x | |
|
1434 |
|clr n_clr| |
|
1435 |
||
1987 | 1436 |
(copiedImage maskAtX:x y:y) == 0 ifTrue:[ |
1437 |
image mask isNil ifTrue:[ |
|
1438 |
image createMask. |
|
1439 |
]. |
|
1440 |
image maskAtX:imgX+x y:imgY+y put:0. |
|
1441 |
] ifFalse:[ |
|
2582 | 1442 |
clr := copiedImage colorAtX:x y:y. |
1987 | 1443 |
n_clr := clr nearestIn:currentColorMap. |
2582 | 1444 |
image colorAtX:imgX+x y:imgY+y put:n_clr |
1987 | 1445 |
] |
1888 | 1446 |
] |
1447 |
]. |
|
1987 | 1448 |
image restored. |
1449 |
self redraw: (imageBox := (imagePoint * magnification extent: (Clipboard extent * magnification)) expandedBy: 1@1). |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1450 |
self setModified. |
1987 | 1451 |
^ self. |
2135 | 1452 |
]. |
1453 |
answer == #new ifTrue:[ |
|
1454 |
existingColors := image usedValues asIdentitySet. |
|
1455 |
newColors := copiedImage usedValues. |
|
1456 |
allColors := existingColors addAll:newColors. |
|
1457 |
allColors size > (1 bitShift:image depth) ifTrue:[ |
|
5061 | 1458 |
self warn:(resources string:'Sorry: too many colors - unimplemented function'). |
2135 | 1459 |
self undo. |
1986
630db3277f10
support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents:
1980
diff
changeset
|
1460 |
^ self. |
630db3277f10
support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents:
1980
diff
changeset
|
1461 |
]. |
2135 | 1462 |
|
1463 |
newColormap := OrderedCollection new. |
|
1464 |
newColormap addAll:image usedColors. |
|
1465 |
newColormap addAll:copiedImage usedColors. |
|
1466 |
"/ translate image to use new colorMap... |
|
1467 |
||
1468 |
"/ translate image to use new colors ... |
|
1469 |
0 to:image height-1 do:[:y | |
|
1470 |
0 to:image width-1 do:[:x | |
|
1471 |
|clr n_idx| |
|
1472 |
||
1473 |
(image maskAtX:x y:y) == 1 ifTrue:[ |
|
2582 | 1474 |
clr := image colorAtX:x y:y. |
2135 | 1475 |
n_idx := newColormap indexOf:clr. |
1476 |
image pixelAtX:x y:y put:n_idx-1. |
|
1477 |
] |
|
1478 |
] |
|
1479 |
]. |
|
1480 |
image colorMap:newColormap. |
|
1481 |
currentColorMap := newColormap. |
|
1482 |
||
1483 |
"/ paste new image... |
|
1484 |
0 to:copiedImage height-1 do:[:y | |
|
1485 |
0 to:copiedImage width-1 do:[:x | |
|
1486 |
|clr idx| |
|
1487 |
||
1488 |
(copiedImage maskAtX:x y:y) == 1 |
|
1489 |
ifTrue:[ |
|
2582 | 1490 |
clr := copiedImage colorAtX:x y:y. |
2135 | 1491 |
idx := currentColorMap indexOf:clr. |
1492 |
idx == 0 ifTrue:[ |
|
1493 |
currentColorMap add:clr. |
|
1494 |
idx := currentColorMap size. |
|
1495 |
idx > (1 bitShift:image depth) ifTrue:[ |
|
5061 | 1496 |
self warn:(resources string:'Sorry: too many colors'). |
2135 | 1497 |
self undo. |
1498 |
^ self. |
|
1499 |
]. |
|
1500 |
]. |
|
1501 |
image pixelAtX:imgX+x y:imgY+y put:idx-1. |
|
1502 |
image maskAtX:imgX+x y:imgY+y put:1. |
|
1503 |
] |
|
1504 |
] |
|
1505 |
]. |
|
1506 |
image restored. |
|
1507 |
self redraw: (imageBox := (imagePoint * magnification extent: (Clipboard extent * magnification)) expandedBy: 1@1). |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1508 |
self setModified. |
1888 | 1509 |
^ self. |
1510 |
]. |
|
5061 | 1511 |
self warn:(resources string:'Sorry: unimplemented function'). |
2135 | 1512 |
self undo. |
1513 |
^ self. |
|
1888 | 1514 |
]. |
2764 | 1515 |
anyColorAdded ifTrue:[ |
2490
62230519175a
slowly getting rid of the Colormap class
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1516 |
image colorMap:(MappedPalette withColors:newColorMap). |
1246 | 1517 |
]. |
1518 |
]. |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1519 |
|
1246 | 1520 |
copiedImage := image class fromImage: copiedImage. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1521 |
(newColorMap isNil |
2135 | 1522 |
and:[modeSymbol isNil |
1987 | 1523 |
and:[copiedImage mask isNil] ]) ifTrue:[ |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1524 |
"/ use images copy functionality |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1525 |
"/ however, this copies the mask as well, |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1526 |
"/ which is not useful here |
1246 | 1527 |
image copyFrom: copiedImage x:0 y:0 toX: imagePoint x y: imagePoint y width: copiedImage width height: copiedImage height. |
1528 |
] ifFalse:[ |
|
1529 |
imgX := imagePoint x. |
|
1530 |
imgY := imagePoint y. |
|
1028
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
1531 |
|
1246 | 1532 |
0 to:copiedImage height-1 do:[:y | |
1533 |
0 to:copiedImage width-1 do:[:x | |
|
1534 |
|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
|
1535 |
|
1246 | 1536 |
dstX := imgX + x. |
1537 |
dstY := imgY + y. |
|
1538 |
wasMasked := (image maskAtX:dstX y:dstY) == 0. |
|
1539 |
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
|
1540 |
|
1246 | 1541 |
"/ with modeUnder, |
1542 |
"/ only replace, if its either unmasked, |
|
1543 |
"/ or the current drawing color. |
|
2135 | 1544 |
(modeSymbol isNil |
1246 | 1545 |
or:[wasMasked |
2135 | 1546 |
or:[modeSymbol == #withMask]]) |
1246 | 1547 |
ifTrue:[ |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1548 |
newMasked ifFalse:[ |
2764 | 1549 |
image colorAtX:dstX y:dstY put:(copiedImage colorAtX:x y:y). |
1823 | 1550 |
wasMasked ifTrue:[ |
1986
630db3277f10
support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents:
1980
diff
changeset
|
1551 |
image maskAtX:dstX y:dstY put:1 |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1552 |
]. |
1823 | 1553 |
] ifTrue:[ |
1554 |
wasMasked ifFalse:[ |
|
2135 | 1555 |
modeSymbol == #withMask ifTrue:[ |
1556 |
image maskAtX:dstX y:dstY put:0 |
|
1557 |
] |
|
1823 | 1558 |
] |
1559 |
]. |
|
1987 | 1560 |
]. |
1561 |
||
1246 | 1562 |
] |
1563 |
]. |
|
1564 |
]. |
|
1565 |
image restored. |
|
1566 |
self redraw: (imageBox := (imagePoint * magnification extent: (Clipboard extent * magnification)) expandedBy: 1@1). |
|
1028
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
1567 |
"/ masterApplication imagePreView redraw: (imageBox expandedBy: 1). |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1568 |
self setModified. |
1246 | 1569 |
] |
1028
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
1570 |
] |
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
1571 |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1572 |
"Modified: / 18.5.1999 / 20:40:37 / cg" |
636 | 1573 |
! |
1574 |
||
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1575 |
pasteUnderAt: aPoint |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1576 |
"pasteUnder the image in the clipboard at aPoint. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1577 |
In this mode, only pixels which are not equal to |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1578 |
the current color or masked are pasted." |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1579 |
|
2135 | 1580 |
self pasteAt:aPoint mode:#under. |
1581 |
! |
|
1582 |
||
1583 |
pasteWithMaskAt: aPoint |
|
1584 |
"paste the image in the clipboard at aPoint. |
|
1585 |
In this mode, both the mask and the image pixel are pasted" |
|
1586 |
||
1587 |
||
1588 |
self pasteAt:aPoint mode:#withMask. |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1589 |
! |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1590 |
|
1858 | 1591 |
performSpecialOperationOn:imageBox withColor:clr |
5413 | 1592 |
|listOfOpNames listOfOpSelectors operation x0 y0 x1 y1 pixelAction requiredColors missingColors answer hue| |
1593 |
||
1594 |
listOfOpNames := OrderedCollection new. |
|
1595 |
listOfOpSelectors := OrderedCollection new. |
|
1596 |
||
5415 | 1597 |
listOfOpNames addAll: |
1598 |
(resources array:#( |
|
1599 |
'edit separately' |
|
1600 |
'extract subimage' |
|
1601 |
)). |
|
1602 |
listOfOpSelectors addAll: |
|
1603 |
#( |
|
1604 |
#edit |
|
1605 |
#editSubImage |
|
1606 |
). |
|
1607 |
||
5413 | 1608 |
self readOnly ifFalse:[ |
1609 |
listOfOpNames addAll: |
|
1610 |
(resources array:#( |
|
1611 |
'-' |
|
1612 |
'flip vertical' |
|
1613 |
'flip horizontal' |
|
1614 |
'-' |
|
1615 |
'slightly brightened' |
|
1616 |
'slightly darkened' |
|
1617 |
'brightened' |
|
1618 |
'darkened' |
|
1619 |
'-' |
|
1620 |
'make grey' |
|
1621 |
'greyed' |
|
1622 |
'grey pattern' |
|
1623 |
'grey pattern (unmasked)' |
|
1624 |
'-' |
|
1625 |
'reversed' |
|
1626 |
'-' |
|
1627 |
'change hue' |
|
1628 |
'colorize' |
|
1629 |
)). |
|
1630 |
||
1631 |
listOfOpSelectors addAll: |
|
1632 |
#(nil |
|
1633 |
flipVertical flipHorizontal nil |
|
1634 |
slightlyBrightened slightlyDarkened brightened darkened nil |
|
1635 |
makeGrey greyed greyPattern unmaskedGreyPattern nil |
|
1636 |
reversed nil |
|
1637 |
changeHue colorize |
|
1638 |
). |
|
1639 |
]. |
|
1640 |
||
1858 | 1641 |
operation := Dialog |
2680 | 1642 |
choose:(resources string:'Which Operation:') |
5413 | 1643 |
fromList:listOfOpNames |
1644 |
values:listOfOpSelectors |
|
1645 |
lines:10 |
|
1858 | 1646 |
cancel:nil. |
1647 |
||
1648 |
self invalidate. |
|
1649 |
self windowGroup processExposeEvents. |
|
1650 |
||
1651 |
operation isNil ifTrue:[^ false]. |
|
1652 |
||
1653 |
x0 := imageBox left. |
|
1654 |
y0 := imageBox top. |
|
1861 | 1655 |
x1 := imageBox right - 1. |
1656 |
y1 := imageBox bottom -1 . |
|
1858 | 1657 |
|
2784 | 1658 |
operation == #edit ifTrue:[ |
1659 |
(self image subImageIn:imageBox) edit. |
|
1660 |
^ false. |
|
1661 |
]. |
|
5415 | 1662 |
operation == #editSubImage ifTrue:[ |
1663 |
self makeUndo. |
|
1664 |
self image:(self image subImageIn:imageBox). |
|
1665 |
^ false. |
|
1666 |
]. |
|
4032 | 1667 |
operation == #flipVertical ifTrue:[ |
1668 |
self flipSubImage:#vertical in:imageBox. |
|
1669 |
^ true. |
|
1670 |
]. |
|
1671 |
operation == #flipHorizontal ifTrue:[ |
|
1672 |
self flipSubImage:#horizontal in:imageBox. |
|
1673 |
^ true. |
|
1674 |
]. |
|
1675 |
||
2177 | 1676 |
operation == #slightlyBrightened ifTrue:[ |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1677 |
pixelAction := [:x :y :clr | clr slightlyLightened]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1678 |
]. |
2177 | 1679 |
operation == #slightlyDarkened ifTrue:[ |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1680 |
pixelAction := [:x :y :clr | clr slightlyDarkened]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1681 |
]. |
2177 | 1682 |
operation == #brightened ifTrue:[ |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1683 |
pixelAction := [:x :y :clr | clr lightened]. |
1858 | 1684 |
]. |
2177 | 1685 |
operation == #darkened ifTrue:[ |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1686 |
pixelAction := [:x :y :clr | clr darkened]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1687 |
]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1688 |
operation == #reversed ifTrue:[ |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1689 |
pixelAction := [:x :y :clr | Color red:(100-clr red) green:(100-clr green) blue:(100-clr blue) ]. |
1858 | 1690 |
]. |
2765 | 1691 |
operation == #makeGrey ifTrue:[ |
1692 |
pixelAction := [:x :y :clr | Color grey:(clr greyIntensity)]. |
|
1693 |
]. |
|
2177 | 1694 |
operation == #greyed ifTrue:[ |
4646 | 1695 |
pixelAction := [:x :y :clr | clr blendWith:Color gray]. |
1858 | 1696 |
]. |
1697 |
operation == #greyPattern ifTrue:[ |
|
2765 | 1698 |
pixelAction := [:x :y :clr | x odd == y even |
4646 | 1699 |
ifTrue:[Color gray] |
2765 | 1700 |
ifFalse:[clr]]. |
1701 |
]. |
|
1702 |
operation == #unmaskedGreyPattern ifTrue:[ |
|
1703 |
pixelAction := [:x :y :clr | x odd == y even |
|
4646 | 1704 |
ifTrue:[self image maskAtX:x y:y put:1. Color gray] |
2765 | 1705 |
ifFalse:[clr]]. |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1706 |
]. |
2765 | 1707 |
|
1708 |
operation == #changeHue ifTrue:[ |
|
5418 | 1709 |
hue := Dialog request:'Hue (0..360)\red->yellow->green->blue->red' withCRs. |
2765 | 1710 |
hue := Number readFrom:hue onError:nil. |
1711 |
hue isNil ifTrue:[^ false]. |
|
1712 |
pixelAction := [:x :y :clr | Color hue:(hue+(clr hue?0)) light:clr light saturation:clr saturation]. |
|
1713 |
]. |
|
1714 |
operation == #colorize ifTrue:[ |
|
5418 | 1715 |
hue := Dialog request:'Hue (0..360)\red->yellow->green->blue->red' withCRs. |
2765 | 1716 |
hue := Number readFrom:hue onError:nil. |
1717 |
hue isNil ifTrue:[^ false]. |
|
1718 |
pixelAction := [:x :y :clr | Color hue:hue light:clr light saturation:100] |
|
1719 |
]. |
|
1720 |
||
3564
a587be34447c
no halt should be without an argument
Claus Gittinger <cg@exept.de>
parents:
3487
diff
changeset
|
1721 |
pixelAction isNil ifTrue:[ |
5061 | 1722 |
self halt:(resources string:'no pixelAction'). |
3564
a587be34447c
no halt should be without an argument
Claus Gittinger <cg@exept.de>
parents:
3487
diff
changeset
|
1723 |
^ false |
a587be34447c
no halt should be without an argument
Claus Gittinger <cg@exept.de>
parents:
3487
diff
changeset
|
1724 |
]. |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1725 |
|
2889 | 1726 |
image colorMap notNil ifTrue:[ |
1727 |
"/ compute required colors ... |
|
1728 |
requiredColors := Set new. |
|
1729 |
self image |
|
1730 |
colorsFromX:x0 y:y0 toX:x1 y:y1 |
|
1731 |
do:[:x :y :clr | |
|
1732 |
requiredColors add:(pixelAction value:x value:y value:clr) |
|
2680 | 1733 |
]. |
2889 | 1734 |
|
4231 | 1735 |
missingColors := requiredColors reject:[:clr | (image colorMap includes:clr)]. |
2889 | 1736 |
|
1737 |
missingColors notEmpty ifTrue:[ |
|
1738 |
answer := Dialog |
|
5061 | 1739 |
confirmWithCancel:(resources stringWithCRs:'Some color(s) cannot be represented in the images colorMap.\Use nearest or compute colorMap ?') |
2889 | 1740 |
labels:#( 'Cancel' 'Add to ColorMap' 'Use Nearest') |
1741 |
values:#( nil add nearest) |
|
1742 |
default:3. |
|
1743 |
answer isNil ifTrue:[^ false]. |
|
1744 |
answer == #add ifTrue:[ |
|
1745 |
missingColors size + image colorMap size > (2 raisedTo:image depth) ifTrue:[ |
|
5061 | 1746 |
self warn:(resources string:'Missing colors cannot be added to images colormap.'). |
2889 | 1747 |
^ false |
1748 |
]. |
|
1749 |
missingColors do:[:eachColor | |
|
1750 |
image colorMap add:eachColor |
|
1751 |
]. |
|
1752 |
answer := #nearest. |
|
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1753 |
]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1754 |
]. |
1858 | 1755 |
]. |
1756 |
||
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1757 |
"/ now, do it |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1758 |
self image |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1759 |
colorsFromX:x0 y:y0 toX:x1 y:y1 |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1760 |
do:[:x :y :clr | |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1761 |
|newClr| |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1762 |
|
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1763 |
newClr := pixelAction value:x value:y value:clr. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1764 |
answer == #nearest ifTrue:[ |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1765 |
newClr := newClr nearestIn:image colorMap |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1766 |
]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1767 |
self image colorAtX:x y:y put:newClr |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1768 |
]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1769 |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1770 |
self setModified. |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1771 |
^ true. |
4032 | 1772 |
|
1773 |
"Modified: / 07-04-2011 / 09:28:20 / cg" |
|
1858 | 1774 |
! |
1775 |
||
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
1776 |
pointAt:aPoint |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1777 |
"draw a single pixel with the currently selected color" |
636 | 1778 |
|
4111 | 1779 |
self pointAt:aPoint width:self penWidth. |
1780 |
||
1781 |
"Modified: / 15-02-2012 / 22:47:30 / cg" |
|
1782 |
! |
|
1783 |
||
1784 |
pointAt:aPoint width:pw |
|
4715 | 1785 |
"draw a single pixel (or dot of width pw) with the currently selected color" |
4111 | 1786 |
|
1787 |
|draw imagePoint clr pix| |
|
796 | 1788 |
|
1246 | 1789 |
imagePoint := aPoint // magnification. |
3476 | 1790 |
(imagePoint x between:0 and:image width-1) ifFalse:[^ self]. |
1791 |
(imagePoint y between:0 and:image height-1) ifFalse:[^ self]. |
|
1792 |
||
4111 | 1793 |
draw := |
1794 |
[:point | |
|
1795 |
image colorMap isNil ifTrue:[ |
|
1796 |
clr := self selectedColor. |
|
1797 |
image atImageAndMask:point put:clr. |
|
1798 |
] ifFalse:[ |
|
1799 |
pix := self selectedColorIndex. |
|
1800 |
image atImageAndMask:point putValue:pix. |
|
1801 |
]. |
|
1802 |
self invalidate:((point * magnification extent: magnification) expandedBy:1). |
|
1803 |
]. |
|
4715 | 1804 |
|
3265 | 1805 |
draw value:imagePoint. |
1806 |
||
4715 | 1807 |
pw > 1 ifTrue:[ |
3610
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
1808 |
"/ draw with a wide pen |
4111 | 1809 |
(pw//2) negated to:(pw-(pw//2)-1) do:[:xOffs | |
1810 |
(pw//2) negated to:(pw-(pw//2)-1) do:[:yOffs | |
|
3267 | 1811 |
imagePoint x + xOffs >= 0 ifTrue:[ |
3476 | 1812 |
imagePoint y + yOffs >= 0 ifTrue:[ |
1813 |
draw value:(imagePoint + (xOffs@yOffs)). |
|
1814 |
]. |
|
3267 | 1815 |
]. |
3266 | 1816 |
]. |
3265 | 1817 |
]. |
1246 | 1818 |
]. |
2823 | 1819 |
self setModified. |
3265 | 1820 |
|
4111 | 1821 |
"Created: / 15-02-2012 / 22:47:08 / cg" |
636 | 1822 |
! |
1823 |
||
2086 | 1824 |
shiftImageHorizontal:shiftH vertical:shiftV |
2489 | 1825 |
self shiftImageHorizontal:shiftH vertical:shiftV wrap:false |
1826 |
! |
|
1827 |
||
1828 |
shiftImageHorizontal:shiftH vertical:shiftV wrap:doWrap |
|
1829 |
"shift the pixels; |
|
1830 |
shift<0 is left-shift/up-shift; shift>0 is right-shift/down-shift; |
|
1831 |
doWrap controls if shifted-out pixels are to be shifted in at the opposite side. |
|
1832 |
i.e.: |
|
1833 |
0123456789 -> 3456789789 (shift: -3) 0123456789 -> 0120123456 (shift:3) |
|
1834 |
or, with wrap: |
|
1835 |
0123456789 -> 3456789012 (shift: -3) 0123456789 -> 7890123456 (shift:3) |
|
1836 |
" |
|
1837 |
||
1838 |
|newImage| |
|
1839 |
||
1840 |
newImage := self shifted:image horizontal:shiftH vertical:shiftV wrap:doWrap. |
|
1841 |
self image:newImage. |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1842 |
self setModified. |
2489 | 1843 |
! |
1844 |
||
1845 |
shifted:image horizontal:shiftH vertical:shiftV wrap:doWrap |
|
1846 |
"shift the pixels; |
|
1847 |
shift<0 is left-shift/up-shift; shift>0 is right-shift/down-shift; |
|
1848 |
doWrap controls if shifted-out pixels are to be shifted in at the opposite side. |
|
1849 |
i.e.: |
|
1850 |
0123456789 -> 3456789789 (shift: -3) 0123456789 -> 0120123456 (shift:3) |
|
1851 |
or, with wrap: |
|
1852 |
0123456789 -> 3456789012 (shift: -3) 0123456789 -> 7890123456 (shift:3) |
|
1853 |
" |
|
1854 |
||
2086 | 1855 |
|w h srcX srcY dstX dstY newImage| |
1856 |
||
2489 | 1857 |
doWrap ifTrue:[ |
1858 |
"/ if wrapping, split into two operations to make wrap-code below simpler. |
|
1859 |
||
1860 |
shiftH ~~ 0 ifTrue:[ |
|
1861 |
shiftV ~~ 0 ifTrue:[ |
|
1862 |
newImage := self shifted:image horizontal:shiftH vertical:0 wrap:doWrap. |
|
1863 |
newImage := self shifted:newImage horizontal:0 vertical:shiftV wrap:doWrap. |
|
1864 |
^ newImage |
|
1865 |
]. |
|
1866 |
]. |
|
1867 |
]. |
|
1868 |
(shiftV == 0 and:[shiftH == 0]) ifTrue:[ |
|
1869 |
^ image |
|
1870 |
]. |
|
1871 |
||
2086 | 1872 |
w := image width. |
1873 |
h := image height. |
|
1874 |
||
1875 |
newImage := image copy. |
|
1876 |
||
1877 |
srcX := srcY := dstX := dstY := 0. |
|
1878 |
shiftH < 0 ifTrue:[ |
|
1879 |
srcX := shiftH negated |
|
1880 |
] ifFalse:[ |
|
1881 |
dstX := shiftH |
|
1882 |
]. |
|
1883 |
shiftV < 0 ifTrue:[ |
|
1884 |
srcY := shiftV negated |
|
1885 |
] ifFalse:[ |
|
1886 |
dstY := shiftV |
|
1887 |
]. |
|
1888 |
||
1889 |
newImage copyFrom:image x:srcX y:srcY toX:dstX y:dstY width:w-shiftH abs height:h-shiftV abs. |
|
1890 |
||
2489 | 1891 |
doWrap ifTrue:[ |
1892 |
srcX := srcY := dstX := dstY := 0. |
|
1893 |
||
1894 |
"/ already simplified - see above |
|
1895 |
shiftH ~~ 0 ifTrue:[ |
|
1896 |
"/ shiftV known to be 0 |
|
1897 |
shiftH < 0 ifTrue:[ |
|
1898 |
dstX := w-1-shiftH negated |
|
1899 |
] ifFalse:[ |
|
1900 |
srcX := w-1-shiftH |
|
1901 |
]. |
|
1902 |
w := shiftH abs. |
|
1903 |
] ifFalse:[ |
|
1904 |
"/ shiftH known to be 0 |
|
1905 |
shiftV < 0 ifTrue:[ |
|
1906 |
dstY := h-1-shiftV negated |
|
1907 |
] ifFalse:[ |
|
1908 |
srcY := h-1-shiftV |
|
1909 |
]. |
|
1910 |
h := shiftV abs. |
|
1911 |
]. |
|
1912 |
newImage copyFrom:image x:srcX y:srcY toX:dstX y:dstY width:w height:h. |
|
1913 |
^ newImage |
|
1914 |
]. |
|
1915 |
||
1916 |
^ newImage. |
|
2086 | 1917 |
|
1918 |
"Created: / 7.9.1998 / 13:00:16 / cg" |
|
1919 |
"Modified: / 7.9.1998 / 14:15:32 / cg" |
|
1920 |
! |
|
1921 |
||
4715 | 1922 |
smoothAt:aPoint |
1923 |
"smoth (average) a single pixel with pixels around" |
|
1924 |
||
1925 |
|draw imagePoint x y w h| |
|
1926 |
||
1927 |
imagePoint := aPoint // magnification. |
|
1928 |
w := image width. |
|
1929 |
h := image height. |
|
1930 |
((x := imagePoint x) between:0 and:w-1) ifFalse:[^ self]. |
|
1931 |
((y := imagePoint y) between:0 and:h-1) ifFalse:[^ self]. |
|
1932 |
||
1933 |
draw := |
|
1934 |
[:point | |
|
1935 |
|sumRed sumGreen sumBlue newClr| |
|
1936 |
||
1937 |
sumRed := sumGreen := sumBlue := 0. |
|
1938 |
-1 to:1 do:[:dx | |
|
1939 |
-1 to:1 do:[:dy | |
|
1940 |
|clr| |
|
1941 |
||
1942 |
((x + dx) between:0 and:w-1) ifTrue:[ |
|
1943 |
((y + dy) between:0 and:h-1) ifTrue:[ |
|
1944 |
clr := image colorAtX:(x + dx) y:(y + dy). |
|
1945 |
sumRed := sumRed + clr redByte. |
|
1946 |
sumGreen := sumGreen + clr greenByte. |
|
1947 |
sumBlue := sumBlue + clr blueByte. |
|
1948 |
] |
|
1949 |
]. |
|
1950 |
] |
|
1951 |
]. |
|
1952 |
newClr := Color |
|
1953 |
redByte:(sumRed / 9) rounded |
|
1954 |
greenByte:(sumGreen / 9) rounded |
|
1955 |
blueByte:(sumBlue / 9) rounded. |
|
1956 |
image colorMap isNil ifTrue:[ |
|
1957 |
Transcript |
|
1958 |
show:(image colorAt:point); |
|
1959 |
show:' -> '; |
|
1960 |
showCR:newClr. |
|
1961 |
image atImageAndMask:point put:newClr. |
|
1962 |
] ifFalse:[ |
|
1963 |
image atImageAndMask:point put:(image colorMap colorNearestTo:newClr). |
|
1964 |
]. |
|
1965 |
self invalidate:((point * magnification extent: magnification) expandedBy:1). |
|
1966 |
]. |
|
1967 |
||
1968 |
draw value:imagePoint. |
|
1969 |
self setModified. |
|
1970 |
! |
|
1971 |
||
1858 | 1972 |
specialOperationAt: aPoint |
1973 |
"special operation on a rectangular area" |
|
1974 |
||
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1975 |
|choosenBox imageBox| |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1976 |
|
5413 | 1977 |
choosenBox := self dragRectangleStartingAt: aPoint emphasis:#inverseFilledBox. |
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1978 |
choosenBox isNil ifTrue:[ ^ self ]. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1979 |
|
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1980 |
imageBox := choosenBox origin//magnification extent: (choosenBox extent//magnification). |
1858 | 1981 |
|
1982 |
(self performSpecialOperationOn:imageBox withColor:self selectedColor) ifFalse:[ |
|
1983 |
^ self |
|
1984 |
]. |
|
1985 |
||
1986 |
image restored. |
|
1861 | 1987 |
self invalidate. "/ : (choosedBox expandedBy: 1). |
1988 |
||
1989 |
"/ self redraw: (choosedBox expandedBy: 1). |
|
1858 | 1990 |
|
1991 |
"/ "/ cg: what a kludge - please change to use a valueHolder, |
|
1992 |
"/ "/ which gets the information ... |
|
1993 |
"/ masterApplication imagePreView redraw: (imageBox expandedBy: 1). |
|
1994 |
||
1995 |
"/ cg: still a kludge - but less ugly |
|
1996 |
self changed:#subImageIn with:(imageBox expandedBy: 1). |
|
1997 |
||
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1998 |
self setModified. |
1858 | 1999 |
! |
2000 |
||
3476 | 2001 |
sprayAt: aPoint |
2002 |
"start spraying with the currently selected color" |
|
2003 |
||
2004 |
|clr| |
|
2005 |
||
2006 |
(clr := self selectedColor) notNil ifTrue:[ |
|
2007 |
sprayPosition := aPoint. |
|
2008 |
self startSpray. |
|
2009 |
]. |
|
2010 |
! |
|
2011 |
||
3277 | 2012 |
text:aString at:aPoint |
2013 |
"draw a character" |
|
2014 |
||
2015 |
|tempForm| |
|
2016 |
||
4999 | 2017 |
tempForm := Form extent:(image extent) depth:1 onDevice:device. |
3277 | 2018 |
tempForm clear. |
2019 |
tempForm paint:(Color colorId:1). |
|
2020 |
tempForm displayString:aString at:aPoint. |
|
2021 |
0 to:image extent x - 1 do:[:x | |
|
2022 |
0 to:image extent y - 1 do:[:y | |
|
2023 |
(tempForm valueAt:(x@y)) == 1 ifTrue:[ |
|
4111 | 2024 |
self pointAt:(x@y) width:1 |
3277 | 2025 |
]. |
2026 |
] |
|
2027 |
]. |
|
2028 |
||
4111 | 2029 |
"Modified: / 15-02-2012 / 22:47:44 / cg" |
3277 | 2030 |
! |
2031 |
||
636 | 2032 |
undo |
1693 | 2033 |
undoImages notEmpty ifTrue:[ |
1374 | 2034 |
windowGroup withExecuteCursorDo:[ |
4967 | 2035 |
|oldImage newImage| |
2036 |
||
2037 |
oldImage := self image. |
|
2038 |
newImage := undoImages removeLast. |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
2039 |
self clearModified. |
4967 | 2040 |
self image:newImage scroll:(newImage extent ~= oldImage extent) "false". |
3610
11e215de80a0
color selection when undoing
Claus Gittinger <cg@exept.de>
parents:
3564
diff
changeset
|
2041 |
"/ self changed:#image. |
1374 | 2042 |
] |
636 | 2043 |
] |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
2044 |
|
1693 | 2045 |
"Modified: / 10.2.2000 / 23:21:24 / cg" |
627 | 2046 |
! ! |
2047 |
||
2839 | 2048 |
!ImageEditView methodsFor:'image manipulation'! |
2049 |
||
2050 |
brightenImage |
|
4730 | 2051 |
self newImageWithUndo: (image copy lightened). |
2839 | 2052 |
! |
2053 |
||
2054 |
darkenImage |
|
4730 | 2055 |
self newImageWithUndo: (image copy darkened). |
2839 | 2056 |
! |
2057 |
||
2058 |
flipHorizontal |
|
2059 |
||
4730 | 2060 |
self newImageWithUndo: image copy flipHorizontal. |
2839 | 2061 |
! |
2062 |
||
2063 |
flipVertical |
|
2064 |
||
2065 |
self makeUndo. |
|
2066 |
self image: image copy flipVertical. |
|
2067 |
self setModified. |
|
2068 |
! |
|
2069 |
||
2070 |
makeBorderedImageX:newX y:newY width:newWidth height:newHeight |
|
2071 |
|newImage oldWidth oldHeight| |
|
2072 |
||
2073 |
oldWidth := image width. |
|
2074 |
oldHeight := image height. |
|
2075 |
||
2076 |
newImage := image class width:newWidth height:newHeight depth:image depth. |
|
2077 |
newImage photometric:image photometric. |
|
2078 |
newImage colorMap:image colorMap copy. |
|
2079 |
newImage bits:(ByteArray new:(newImage bytesPerRow * newHeight)). |
|
2080 |
||
2842 | 2081 |
image mask notNil ifTrue:[ |
2839 | 2082 |
|newMaskImage| |
2083 |
||
2084 |
newMaskImage := Depth1Image width:newWidth height:newHeight. |
|
2085 |
newMaskImage photometric: image mask photometric. |
|
2086 |
newMaskImage colorMap: image mask colorMap copy. |
|
2087 |
newMaskImage bits:(ByteArray new: newMaskImage bytesPerRow * newHeight). |
|
2088 |
newImage mask: newMaskImage |
|
2089 |
]. |
|
2090 |
||
2091 |
newImage copyFrom:image x:0 y:0 toX:newX y:newY width:oldWidth height:oldHeight. |
|
4730 | 2092 |
self newImageWithUndo:newImage. |
2839 | 2093 |
|
2094 |
"Created: / 7.9.1998 / 13:00:16 / cg" |
|
2095 |
"Modified: / 7.9.1998 / 14:15:32 / cg" |
|
2096 |
! |
|
2097 |
||
2098 |
makeBrighter |
|
2099 |
^ self makeNewColorMapByMapping:[:clr | clr lightened]. |
|
2100 |
! |
|
2101 |
||
2102 |
makeDarker |
|
2103 |
^ self makeNewColorMapByMapping:[:clr | clr darkened]. |
|
2104 |
! |
|
2105 |
||
2841 | 2106 |
makeGrayScaleImage |
4730 | 2107 |
^ self makeNewColorMapByMapping: |
2108 |
[:clr | Color brightness:(clr brightness)]. |
|
2839 | 2109 |
! |
2110 |
||
2111 |
makeInverse |
|
4730 | 2112 |
^ self makeNewColorMapByMapping: |
2113 |
[:clr | |
|
2114 |
Color red:(100-clr red) green:(100-clr green) blue:(100-clr blue) |
|
2115 |
]. |
|
2839 | 2116 |
! |
2117 |
||
3971 | 2118 |
makeSlightlyBrighter |
4730 | 2119 |
^ self makeNewColorMapByMapping: |
2120 |
[:clr | |
|
2121 |
clr brightness > Color lightGray brightness |
|
5163 | 2122 |
ifTrue:[ clr blendWith:self whiteColor ] |
4730 | 2123 |
ifFalse:[ clr blendWith:Color lightGray ] |
2124 |
]. |
|
3971 | 2125 |
|
2126 |
"Created: / 24-11-2010 / 11:08:18 / cg" |
|
2127 |
! |
|
2128 |
||
2129 |
makeSlightlyDarker |
|
4730 | 2130 |
^ self makeNewColorMapByMapping: |
2131 |
[:clr | |
|
2132 |
clr brightness < Color darkGray brightness |
|
2133 |
ifTrue:[ clr blendWith:Color black ] |
|
2134 |
ifFalse:[ clr blendWith:Color darkGray ] |
|
2135 |
]. |
|
3971 | 2136 |
|
2137 |
"Created: / 24-11-2010 / 11:08:08 / cg" |
|
2138 |
! |
|
2139 |
||
2839 | 2140 |
negativeImage |
2141 |
||
4730 | 2142 |
self newImageWithUndo: (image copy bits:(image bits invert)). |
2143 |
! |
|
2144 |
||
2145 |
newImageWithUndo:newImage |
|
2146 |
||
2839 | 2147 |
self makeUndo. |
4730 | 2148 |
self image: newImage. |
2839 | 2149 |
self setModified. |
2150 |
! |
|
2151 |
||
2152 |
reduceColorResolutionBy:numBits |
|
2153 |
|newImage| |
|
2154 |
||
2155 |
numBits > 7 ifTrue:[ |
|
5061 | 2156 |
self warn:(resources string:'Max. number of bits to strip off is 7.'). |
2839 | 2157 |
^ false |
2158 |
]. |
|
2159 |
newImage := image withColorResolutionReducedBy:numBits. |
|
2160 |
newImage isNil ifTrue:[ |
|
5061 | 2161 |
self warn:(resources string:'Could not reduce color resolution.'). |
2839 | 2162 |
^ false. |
2163 |
]. |
|
2164 |
||
4730 | 2165 |
self newImageWithUndo:newImage. |
2839 | 2166 |
^ true |
2167 |
! |
|
2168 |
||
2169 |
resizeImageTo:newSize |
|
4730 | 2170 |
self newImageWithUndo: (self resizedImage:image to:newSize). |
2171 |
! |
|
2172 |
||
2173 |
resizedImage:image to:newSize |
|
2174 |
"helper for image resize and mask resize. |
|
2175 |
return a resized version of image" |
|
2839 | 2176 |
|
2177 |
|newImage newMaskImage| |
|
2178 |
||
2179 |
newImage := image class width: newSize x height: newSize y depth: image depth. |
|
2180 |
newImage photometric:image photometric. |
|
2181 |
newImage colorMap:image colorMap copy. |
|
2182 |
newImage bits: (ByteArray new: newImage bytesPerRow * newSize y). |
|
2183 |
||
2184 |
image mask notNil ifTrue:[ |
|
2185 |
newMaskImage := Depth1Image width: newSize x height: newSize y. |
|
2186 |
newMaskImage photometric: image mask photometric. |
|
2187 |
newMaskImage colorMap: image mask colorMap copy. |
|
2188 |
newMaskImage bits:(ByteArray new: newMaskImage bytesPerRow * newSize y). |
|
2189 |
newImage mask: newMaskImage |
|
2190 |
]. |
|
2191 |
||
2192 |
newImage copyFrom:image x:0 y:0 toX:0 y:0 width: (image width min:newSize x) height: (image height min:newSize y). |
|
4730 | 2193 |
^ newImage. |
2839 | 2194 |
! |
2195 |
||
2196 |
rotateImageBy:rotation |
|
2197 |
"rotate by (degrees)" |
|
2198 |
||
4212 | 2199 |
Error handle:[:ex| |
3435
400079196849
3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents:
3319
diff
changeset
|
2200 |
self warn: 'Image rotation failed!!\' withCRs, 'Increasing the image depth could help.' |
2839 | 2201 |
] do:[ |
4730 | 2202 |
self newImageWithUndo: (image hardRotated: rotation). |
2839 | 2203 |
] |
2204 |
||
2205 |
"Modified: / 29.7.1998 / 18:21:14 / cg" |
|
3435
400079196849
3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents:
3319
diff
changeset
|
2206 |
! |
400079196849
3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents:
3319
diff
changeset
|
2207 |
|
400079196849
3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents:
3319
diff
changeset
|
2208 |
threeDProjection:dx1 and:dx2 |
400079196849
3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents:
3319
diff
changeset
|
2209 |
"3D projection" |
400079196849
3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents:
3319
diff
changeset
|
2210 |
|
4212 | 2211 |
Error handle:[:ex| |
3435
400079196849
3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents:
3319
diff
changeset
|
2212 |
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
|
2213 |
] do:[ |
4730 | 2214 |
self newImageWithUndo:(image threeDProjected:dx1 and:dx2) |
3435
400079196849
3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents:
3319
diff
changeset
|
2215 |
] |
400079196849
3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents:
3319
diff
changeset
|
2216 |
|
400079196849
3D perspecitve (first attempt)
Claus Gittinger <cg@exept.de>
parents:
3319
diff
changeset
|
2217 |
"Modified: / 29.7.1998 / 18:21:14 / cg" |
2839 | 2218 |
! ! |
2219 |
||
2511 | 2220 |
!ImageEditView methodsFor:'image-dragging & info'! |
2221 |
||
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
2222 |
dragRectangleStartingAt:aPointIn emphasis:emphasis |
5413 | 2223 |
"draw a drag rectangle (filled or unfilled, depending on the emphasis arg). |
2224 |
This is called by operation like |
|
2225 |
rectangle, filledRectangle, copy etc. |
|
2226 |
(i.e. any operation which operates on a box). |
|
2227 |
emphasis is one of: |
|
2228 |
box - a frame is drawn |
|
2229 |
inverseFilledBox - the dragged box is filled by the inverse color |
|
2230 |
filledBox - the dragged box is filled with black |
|
2231 |
grayedBox - the dragged box is drawn with a gray shadow |
|
2232 |
" |
|
2511 | 2233 |
|
2234 |
|currentPoint currentExtent firstPoint lastCurrentPoint gridCorrection |
|
5413 | 2235 |
mp lastMp p whichQuarter scrollX scrollY aPoint sensor| |
2511 | 2236 |
|
2237 |
aPoint := aPointIn. |
|
2238 |
firstPoint := currentPoint := lastCurrentPoint := aPoint//magnification*magnification. |
|
2239 |
magnification >= GridMagnificationLimit ifFalse: [gridCorrection := 0] ifTrue: [gridCorrection := 1]. |
|
2240 |
||
5413 | 2241 |
sensor := self sensor. |
2242 |
[sensor anyButtonPressed] whileTrue: [ |
|
2243 |
(sensor hasKeyEventFor:nil) ifTrue:[ |
|
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
2244 |
self invalidate. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
2245 |
^ nil. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
2246 |
]. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
2247 |
|
5413 | 2248 |
mp := sensor mousePoint. |
2511 | 2249 |
mp = lastMp ifTrue:[ |
2250 |
Delay waitForSeconds:0.05 |
|
2251 |
] ifFalse:[ |
|
2252 |
lastMp := mp. |
|
4999 | 2253 |
mp := device translatePoint:mp fromView:nil toView:self. |
2511 | 2254 |
"/ mp is a device coordinate here ... |
2255 |
scrollX := 0. |
|
2256 |
mp x > width ifTrue:[ |
|
2257 |
scrollX := mp x - width. |
|
2258 |
] ifFalse:[ |
|
2259 |
mp x < 0 ifTrue:[ |
|
2260 |
scrollX := mp x. |
|
2261 |
] |
|
2262 |
]. |
|
2263 |
scrollY := 0. |
|
2264 |
mp y > height ifTrue:[ |
|
2265 |
scrollY := mp y - height. |
|
2266 |
] ifFalse:[ |
|
2267 |
mp y < 0 ifTrue:[ |
|
2268 |
scrollY := mp y. |
|
2269 |
] |
|
2270 |
]. |
|
2271 |
(scrollX + scrollY) ~~ 0 ifTrue:[ |
|
2272 |
self scrollTo:(self viewOrigin + (scrollX @ scrollY)). |
|
2273 |
lastMp := nil. |
|
2274 |
]. |
|
2275 |
||
2276 |
mp := mp + self viewOrigin. |
|
2277 |
"/ mp is now a logical coordinate. |
|
2278 |
||
2279 |
currentPoint := (0@0) max: (image extent * magnification min: (p := mp)). |
|
2280 |
currentPoint := currentPoint//magnification*magnification. |
|
2281 |
currentExtent := (firstPoint - currentPoint) abs. |
|
2282 |
whichQuarter := (firstPoint x - currentPoint x) > 0 |
|
2283 |
ifTrue: [(firstPoint y - currentPoint y) > 0 ifTrue: ["4"1@1] ifFalse: ["3"1@0]] |
|
2284 |
ifFalse: [(firstPoint y - currentPoint y) > 0 ifTrue: ["1"0@1] ifFalse: ["2"0@0]]. |
|
2285 |
||
5413 | 2286 |
self showCursorAt: p andInformation: |
2511 | 2287 |
((firstPoint//magnification - whichQuarter + 1) printString, |
2288 |
' to: ', |
|
2289 |
(currentPoint//magnification + whichQuarter) printString), |
|
2290 |
' (extent: ', |
|
2291 |
(currentExtent//magnification) printString, ')'. |
|
2292 |
||
5413 | 2293 |
currentPoint ~= lastCurrentPoint ifTrue:[ |
2294 |
||
2295 |
emphasis == #grayedBox ifTrue:[ |
|
2296 |
"/ does not yet work |
|
2297 |
|org ext| |
|
2298 |
||
2299 |
"/ org := (firstPoint min: lastCurrentPoint) - 1. |
|
2300 |
"/ ext := (firstPoint - lastCurrentPoint) abs + 2. |
|
2301 |
||
2302 |
(lastCurrentPoint x > currentPoint x |
|
2303 |
or:[ (lastCurrentPoint y > currentPoint y) ] |
|
2304 |
) ifTrue:[ |
|
2305 |
self |
|
2306 |
redrawImageX:firstPoint x"-1" y:firstPoint y"-1" |
|
2307 |
width:(lastCurrentPoint x-firstPoint x"+2") height:(lastCurrentPoint y-firstPoint y"+2") |
|
2308 |
unmaskedOnly:false processColorsWith:[:clr | clr ]. |
|
2309 |
"/ self drawFramesIn:(firstPoint corner:lastCurrentPoint). |
|
2310 |
]. |
|
2311 |
||
2312 |
self |
|
2313 |
redrawImageX:firstPoint x"-1" y:firstPoint y"-1 " |
|
2314 |
width:(currentPoint x-firstPoint x"+2") height:(currentPoint y-firstPoint y"+2") |
|
2315 |
unmaskedOnly:true processColorsWith:[:clr | Color gray: clr grayIntensity / 2 ]. |
|
2316 |
]. |
|
2317 |
||
2318 |
emphasis == #inverseFilledBox ifTrue: [ |
|
5414 | 2319 |
|union invertOutside| |
2320 |
||
2321 |
invertOutside := false. |
|
2322 |
"/ union := (firstPoint corner:currentPoint) merge:(firstPoint corner:lastCurrentPoint). |
|
2323 |
"/ ((lastCurrentPoint x > currentPoint x) |
|
2324 |
"/ and:[ lastCurrentPoint y > currentPoint y ]) ifTrue:[ |
|
2325 |
"/ "/ a real shrink |
|
2326 |
"/ invertOutside := true. |
|
2327 |
"/ self xoring: [ |
|
2328 |
"/ union areasOutside:(firstPoint corner:lastCurrentPoint) do:[:r | |
|
2329 |
"/ self fillRectangle: ((firstPoint min: currentPoint) + margin extent: currentExtent - gridCorrection) |
|
2330 |
"/ ] |
|
2331 |
"/ ] |
|
2332 |
"/ ] ifFalse:[ |
|
2333 |
"/ ((currentPoint x > lastCurrentPoint x) |
|
2334 |
"/ and:[ currentPoint y > lastCurrentPoint y ]) ifTrue:[ |
|
2335 |
"/ "/ a real grow |
|
2336 |
"/ invertOutside := true. |
|
2337 |
"/ self xoring: [ |
|
2338 |
"/ union areasOutside:(firstPoint corner:currentPoint) do:[:r | |
|
2339 |
"/ self fillRectangle: ((firstPoint min: currentPoint) + margin extent: currentExtent - gridCorrection) |
|
2340 |
"/ ] |
|
2341 |
"/ ] |
|
2342 |
"/ ]. |
|
2343 |
"/ ]. |
|
2344 |
invertOutside ifFalse:[ |
|
2345 |
self redraw: ((firstPoint min: lastCurrentPoint) - 1 extent: (firstPoint - lastCurrentPoint) abs + 2). |
|
5432 | 2346 |
gc xoring: [ |
2347 |
gc fillRectangle: ((firstPoint min: currentPoint) + margin extent: currentExtent - gridCorrection) |
|
5414 | 2348 |
] |
2349 |
]. |
|
2511 | 2350 |
]. |
5413 | 2351 |
|
2352 |
emphasis == #box ifTrue:[ |
|
2511 | 2353 |
|origin extent lineWidthY lineWidthX| |
5413 | 2354 |
|
2511 | 2355 |
origin := (firstPoint min: lastCurrentPoint) - 1. |
2356 |
extent := (firstPoint - lastCurrentPoint) abs + 2. |
|
2357 |
lineWidthY := extent y min: (magnification y + 2). |
|
2358 |
lineWidthX := extent x min: (magnification x + 2). |
|
2359 |
self redraw: (origin extent: (extent x@lineWidthY)). |
|
2360 |
self redraw: ((origin x@(origin y + extent y - lineWidthY)) extent: (extent x@lineWidthY)). |
|
2361 |
self redraw: ((origin x@(origin y + lineWidthY)) extent: (lineWidthX@(0 max: (extent y - (lineWidthY * 2))))). |
|
2362 |
self redraw: (((origin x + extent x - lineWidthX)@(origin y + lineWidthY)) extent: (lineWidthX@(extent y - (lineWidthY * 2)))). |
|
5413 | 2363 |
(self selectedColor ~= Color noColor) |
5432 | 2364 |
ifTrue: [gc paint: self selectedColor] |
2365 |
ifFalse: [gc paint: self viewBackground]. |
|
2511 | 2366 |
origin := (firstPoint min: currentPoint) + margin. |
2367 |
extent := currentExtent - gridCorrection. |
|
2368 |
lineWidthY := extent y min: magnification y. |
|
2369 |
lineWidthX := extent x min: magnification x. |
|
5413 | 2370 |
(lineWidthY > 0 and: [lineWidthX > 0]) ifTrue:[ |
5432 | 2371 |
gc fillRectangle: (origin extent: (extent x@lineWidthY)). |
2372 |
gc fillRectangle: ((origin x@(origin y + extent y - lineWidthY)) extent: (extent x@lineWidthY)). |
|
2373 |
gc fillRectangle: ((origin x@(origin y + lineWidthY)) extent: (lineWidthX@(0 max: (extent y - (lineWidthY * 2))))). |
|
2374 |
gc fillRectangle: (((origin x + extent x - lineWidthX)@(origin y + lineWidthY)) extent: (lineWidthX@(extent y - (lineWidthY * 2)))). |
|
2511 | 2375 |
] |
2376 |
]. |
|
5413 | 2377 |
|
2378 |
emphasis == #filledBox ifTrue:[ |
|
2511 | 2379 |
self redraw: ((firstPoint min: lastCurrentPoint) - 1 extent: (firstPoint - lastCurrentPoint) abs + 2). |
5413 | 2380 |
(self selectedColor ~= Color noColor) |
5432 | 2381 |
ifTrue: [gc paint: self selectedColor] |
2382 |
ifFalse: [gc paint: self viewBackground]. |
|
2383 |
gc fillRectangle: ((firstPoint min: currentPoint) + margin extent: currentExtent - gridCorrection). |
|
2511 | 2384 |
]. |
2385 |
]. |
|
2386 |
lastCurrentPoint := currentPoint. |
|
2387 |
]. |
|
2388 |
]. |
|
2389 |
||
2390 |
^((0@0) max: (firstPoint min: currentPoint)) extent: (firstPoint - currentPoint) abs |
|
2391 |
||
2392 |
"Created: / 21.8.1998 / 20:17:07 / cg" |
|
2393 |
"Modified: / 10.10.2001 / 14:13:08 / cg" |
|
2394 |
! |
|
2395 |
||
2396 |
drawCursorAt:aPoint |
|
5413 | 2397 |
|imgPoint shownCursor| |
2511 | 2398 |
|
4041 | 2399 |
readOnly ifTrue:[^ self]. |
2511 | 2400 |
image isNil ifTrue: [ |
2401 |
self updateImageInfo: self imageInfoString. |
|
2402 |
self cursor:Cursor stop. |
|
2403 |
^ self |
|
2404 |
]. |
|
2405 |
||
2406 |
imgPoint := aPoint // magnification. |
|
2407 |
((imgPoint x between:0 and:(image width-1)) |
|
5413 | 2408 |
and:[imgPoint y between:0 and: (image height-1)] |
2409 |
) ifFalse:[ |
|
2410 |
self updateImageInfo:self imageInfoString. |
|
2411 |
shownCursor := Cursor stop. |
|
2511 | 2412 |
] ifTrue: [ |
3729 | 2413 |
self updateImageInfoFor:imgPoint. |
5413 | 2414 |
shownCursor := Cursor crossHair |
2511 | 2415 |
]. |
5413 | 2416 |
self cursor:shownCursor. |
2511 | 2417 |
|
4041 | 2418 |
"Modified: / 03-05-2011 / 12:27:52 / cg" |
2511 | 2419 |
! |
2420 |
||
5413 | 2421 |
showCursorAt: aPoint andInformation: aLabel |
2422 |
|shownCursor| |
|
2423 |
||
4041 | 2424 |
readOnly ifTrue:[^ self]. |
2511 | 2425 |
|
2426 |
((0@0 extent: image extent * magnification) containsPoint: aPoint) |
|
5413 | 2427 |
ifTrue: [ shownCursor := Cursor crossHair ] |
5414 | 2428 |
ifFalse:[ shownCursor := Cursor stop ]. |
5413 | 2429 |
self cursor:shownCursor. |
2430 |
self updateImageInfo: aLabel. |
|
2511 | 2431 |
|
4041 | 2432 |
"Modified: / 03-05-2011 / 12:28:15 / cg" |
2511 | 2433 |
! |
2434 |
||
2435 |
updateActivity: something |
|
2436 |
|msg| |
|
2437 |
||
2438 |
msg := something printString. |
|
2439 |
||
2440 |
activityInfoHolder notNil ifTrue:[ |
|
3847
c09d45071125
comment/format in: #updateImageInfo:
Claus Gittinger <cg@exept.de>
parents:
3840
diff
changeset
|
2441 |
activityInfoHolder value:msg. |
2511 | 2442 |
]. |
2443 |
||
2444 |
"Modified: / 29.7.1998 / 18:41:47 / cg" |
|
2445 |
! |
|
2446 |
||
2447 |
updateImageInfo: something |
|
3847
c09d45071125
comment/format in: #updateImageInfo:
Claus Gittinger <cg@exept.de>
parents:
3840
diff
changeset
|
2448 |
|msg| |
2511 | 2449 |
|
2450 |
msg := something printString. |
|
2451 |
||
2452 |
imageInfoHolder notNil ifTrue:[ |
|
3847
c09d45071125
comment/format in: #updateImageInfo:
Claus Gittinger <cg@exept.de>
parents:
3840
diff
changeset
|
2453 |
msg ~= imageInfoHolder value ifTrue:[ |
c09d45071125
comment/format in: #updateImageInfo:
Claus Gittinger <cg@exept.de>
parents:
3840
diff
changeset
|
2454 |
imageInfoHolder value:msg. |
c09d45071125
comment/format in: #updateImageInfo:
Claus Gittinger <cg@exept.de>
parents:
3840
diff
changeset
|
2455 |
]. |
c09d45071125
comment/format in: #updateImageInfo:
Claus Gittinger <cg@exept.de>
parents:
3840
diff
changeset
|
2456 |
^ self |
2511 | 2457 |
]. |
2458 |
||
2459 |
"Modified: / 29.7.1998 / 19:00:21 / cg" |
|
3729 | 2460 |
! |
2461 |
||
2462 |
updateImageInfoFor:aPoint |
|
2463 |
|clr pixel r g b a| |
|
2464 |
||
2465 |
clr := image colorAt:aPoint. |
|
2466 |
pixel := image pixelAt:aPoint. |
|
2467 |
||
2468 |
r := clr redByte. |
|
2469 |
g := clr greenByte. |
|
2470 |
b := clr blueByte. |
|
2471 |
a := clr alphaByte. |
|
2472 |
||
2473 |
self updateImageInfo: |
|
2474 |
(String streamContents:[:s | |
|
2475 |
s print:aPoint. |
|
2476 |
s print:' (r:'; print:r. |
|
2477 |
s print:' g:'; print:g. |
|
2478 |
s print:' b:'; print:b. |
|
2479 |
image depth > 24 ifTrue:[ |
|
2480 |
s print:' a:'; print:a. |
|
2481 |
]. |
|
2482 |
s print:' #'; print:(r hexPrintString:2); print:(g hexPrintString:2); print:(b hexPrintString:2). |
|
2483 |
pixel <= 16rFFFF ifTrue:[ |
|
2484 |
s print:' pixel:'; print:pixel. |
|
2485 |
]. |
|
2486 |
s print:')'. |
|
2487 |
]) |
|
2511 | 2488 |
! ! |
2489 |
||
2818 | 2490 |
!ImageEditView methodsFor:'initialization & release'! |
1327 | 2491 |
|
2492 |
destroy |
|
2440 | 2493 |
ClipboardMagnified := Clipboard := nil. |
1327 | 2494 |
LastMagnification := magnification. |
2495 |
||
2496 |
super destroy |
|
2497 |
! |
|
1 | 2498 |
|
161 | 2499 |
initialize |
2500 |
super initialize. |
|
627 | 2501 |
|
4041 | 2502 |
readOnly := false. |
2503 |
||
686 | 2504 |
self enableMotionEvents. |
995 | 2505 |
|
1374 | 2506 |
undoImages := List new: MaxUndos. |
2915 | 2507 |
|
1706 | 2508 |
magnification := LastMagnification ? (8@8). |
2747 | 2509 |
modifiedHolder := false asValue. |
627 | 2510 |
mouseKeyColorMode := 1. |
2908
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
2511 |
resourceClass := resourceSelector := nil. |
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
2512 |
drawingColorHolders := Array with:(nil asValue) with:(nil asValue). "/ left/right mouse colors |
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
2513 |
drawingPixelHolders := Array with:(nil asValue) with:(nil asValue). "/ left/right mouse colors |
4111 | 2514 |
|
2515 |
spraySpot := 8. |
|
2516 |
penWidth := 1. |
|
2517 |
||
2889 | 2518 |
self editMode:EditModePoint. |
4041 | 2519 |
|
4111 | 2520 |
"Modified: / 15-02-2012 / 22:39:22 / cg" |
1 | 2521 |
! ! |
2522 |
||
2915 | 2523 |
!ImageEditView methodsFor:'loading & saving'! |
1 | 2524 |
|
1994 | 2525 |
askForFileNameToSave:msg |
2526 |
"ask for a fileName" |
|
2527 |
||
2528 |
|lastFn fn filters| |
|
2529 |
||
2530 |
filters := FileSelectionBrowser saveImageFileNameFilters. |
|
2531 |
lastFn := self image fileName. |
|
2532 |
lastFn isNil ifTrue:[ |
|
2533 |
fn := FileSelectionBrowser |
|
2534 |
request: msg |
|
2535 |
inDirectory: LastSaveDirectory |
|
2536 |
withFileFilters: filters |
|
2537 |
] ifFalse:[ |
|
2538 |
fn := FileSelectionBrowser |
|
2539 |
request: msg |
|
2540 |
fileName: lastFn |
|
2541 |
withFileFilters: filters |
|
2542 |
]. |
|
2543 |
||
2544 |
^ fn |
|
2545 |
! |
|
2546 |
||
724 | 2547 |
loadFromClass |
2915 | 2548 |
|classAndSelector| |
2549 |
||
2550 |
classAndSelector := ResourceSelectionBrowser |
|
1184 | 2551 |
request: 'Load Image From Class' |
2552 |
onSuperclass: nil |
|
2915 | 2553 |
andClass: self resourceClass |
1184 | 2554 |
andSelector: self resourceSelector |
2915 | 2555 |
withResourceTypes: #(image fileImage programImage). |
2556 |
||
2557 |
classAndSelector notNil ifTrue:[ |
|
2558 |
self loadFromClass:(classAndSelector methodClass) andSelector:(classAndSelector methodSelector) |
|
2559 |
]. |
|
161 | 2560 |
! |
2561 |
||
2915 | 2562 |
loadFromClass:aClassOrClassName andSelector: aStringOrSymbol |
2563 |
"support for names will vanish - obsolete left over from tz" |
|
2564 |
||
2565 |
imageReaderClass := nil. |
|
2566 |
self resourceClass: aClassOrClassName. |
|
2567 |
self resourceSelector: aStringOrSymbol. |
|
2568 |
||
2569 |
resourceClass isBehavior ifFalse:[^ nil]. |
|
2570 |
||
2571 |
(resourceClass respondsTo:resourceSelector) ifTrue:[ |
|
2572 |
image := resourceClass perform:resourceSelector. |
|
2573 |
]. |
|
2574 |
||
2575 |
image isNil ifTrue:[^ nil]. |
|
2576 |
||
2577 |
image := image copy. |
|
2578 |
self releaseUndos. |
|
2579 |
self image:image. |
|
2580 |
self clearModified. |
|
2581 |
^ image |
|
2556 | 2582 |
! |
2583 |
||
2915 | 2584 |
loadFromFile: aFileName |
2585 |
|imageFromFile| |
|
2586 |
||
2587 |
aFileName isNil ifTrue: [^nil]. |
|
2588 |
||
5029 | 2589 |
Error handle:[:exception| |
2590 |
self warn: exception errorString. |
|
4351 | 2591 |
^ nil |
2915 | 2592 |
] do:[ |
4351 | 2593 |
(imageFromFile := Image fromFile: aFileName) isNil ifTrue:[ |
2594 |
imageFromFile := JPEGReader fromFile:aFileName |
|
2595 |
]. |
|
2596 |
imageFromFile notNil ifTrue:[ |
|
2915 | 2597 |
self releaseUndos. |
2598 |
self image: imageFromFile. |
|
2599 |
self clearModified. |
|
2600 |
"/ imageReaderClass := ImageReader allSubclasses |
|
2601 |
"/ detect: [:cls| cls isValidImageFile: aFileName asFilename pathName] |
|
2602 |
"/ ifNone: [self error: 'Unknown image file format!!'] |
|
2603 |
] ifFalse:[ |
|
4965 | 2604 |
aFileName asFilename isReadable ifTrue:[ |
2605 |
self error: 'Not an image file (or unrecognized format)' |
|
2606 |
] ifFalse:[ |
|
2607 |
self error: 'File does not exist or is unreadable' |
|
2608 |
] |
|
2915 | 2609 |
] |
2555 | 2610 |
]. |
2915 | 2611 |
^ imageFromFile |
2612 |
||
2613 |
"Modified: / 29.7.1998 / 18:09:13 / cg" |
|
2614 |
! |
|
2615 |
||
2616 |
loadFromMessage:classAndSelector |
|
2617 |
"switch to the class and selector specified by classAndSelector." |
|
2618 |
||
2619 |
^ self loadFromClass:(classAndSelector methodClass) andSelector:(classAndSelector methodSelector) |
|
2620 |
! |
|
2621 |
||
2622 |
loadfromClass:aClassOrSymbol andSelector: aStringOrSymbol |
|
3643 | 2623 |
<resource: #obsolete> |
2915 | 2624 |
self obsoleteMethodWarning. |
2625 |
^ self loadFromClass:aClassOrSymbol andSelector: aStringOrSymbol |
|
624 | 2626 |
! |
2627 |
||
2628 |
save |
|
632 | 2629 |
self saveImageOrMask: #image. |
624 | 2630 |
! |
2631 |
||
2239 | 2632 |
save:image imageOrMask:what |
2633 |
"save the image or the mask only (if what == #mask)" |
|
297 | 2634 |
|
2239 | 2635 |
image isNil ifTrue:[ |
4249 | 2636 |
Dialog warn:(resources string:'No image to save!!'). |
2239 | 2637 |
^ self. |
2638 |
]. |
|
2639 |
self save:image imageOrMask:what as:image fileName. |
|
627 | 2640 |
! |
297 | 2641 |
|
2239 | 2642 |
save:image imageOrMask:what as:fileNameArg |
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2643 |
"save the image or the mask only (if what == #mask)" |
628 | 2644 |
|
2240 | 2645 |
|fileName fileNameString| |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2646 |
|
2239 | 2647 |
fileName := fileNameArg asFilename. |
2783 | 2648 |
LastSaveDirectory := fileName directoryName. |
2239 | 2649 |
|
4203 | 2650 |
Error handle:[:ex| |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2651 |
|msg| |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2652 |
|
4203 | 2653 |
ex creator == Image fileCreationErrorSignal ifTrue:[ |
1896 | 2654 |
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
|
2655 |
] ifFalse:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2656 |
msg := ex errorString. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2657 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2658 |
Dialog warn:msg. |
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2659 |
] do:[ |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2660 |
Image informationLostQuerySignal handle:[:ex| |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2661 |
"/ should make those warnings visible ... |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2662 |
(self confirm:(ex errorString , '\\Save anyway ?') withCRs) ifTrue:[ |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2663 |
ex proceed. |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2664 |
] |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2665 |
] do:[ |
4137 | 2666 |
windowGroup withWriteCursorDo:[ |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2667 |
|suff fn| |
1027
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
2668 |
|
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2669 |
image isNil ifTrue:[ |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2670 |
^ self error: 'No image to save!!' |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2671 |
]. |
632 | 2672 |
|
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2673 |
what = #mask ifTrue:[ |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2674 |
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
|
2675 |
]. |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2676 |
|
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2677 |
fileName name size = 0 ifTrue: [^self error: 'No file name detected!!']. |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2678 |
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
|
2679 |
imageReaderClass := nil. |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
2680 |
imageReaderClass := MIMETypes imageReaderForSuffix:suff. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2681 |
|
1373
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
2682 |
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
|
2683 |
imageReaderClass := XPMReader. |
2589
10827ba87692
obsolete method calls cleaned up
Claus Gittinger <cg@exept.de>
parents:
2582
diff
changeset
|
2684 |
fileNameString := fileName name , '.xpm'. |
2240 | 2685 |
fileName := fileNameString asFilename. |
2686 |
image fileName:fileNameString. |
|
5314 | 2687 |
Dialog warn:(('Don''t know how to write ''.' , suff , '''-files\\Saving in xpm format as ''%1''.') |
2240 | 2688 |
withCRs bindWith: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
|
2689 |
]. |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
2690 |
(imageReaderClass canRepresent:image) ifFalse:[ |
1991 | 2691 |
imageReaderClass == XPMReader ifTrue:[ |
2692 |
Dialog warn:('Saving in ''.' , suff , '''-format is not supported (or image cannot be represented in this format).\\Please try another format.') withCRs. |
|
2693 |
^ self. |
|
2694 |
]. |
|
1373
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
2695 |
imageReaderClass := XPMReader. |
2589
10827ba87692
obsolete method calls cleaned up
Claus Gittinger <cg@exept.de>
parents:
2582
diff
changeset
|
2696 |
fileNameString := fileName name , '.xpm'. |
2240 | 2697 |
fileName := fileNameString asFilename. |
2698 |
image fileName:fileNameString. |
|
2690
53bc9dc52ce4
allow cancel when saving in wrong format
Claus Gittinger <cg@exept.de>
parents:
2680
diff
changeset
|
2699 |
(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
|
2700 |
withCRs bindWith:fileNameString allBold)) ifFalse:[ |
53bc9dc52ce4
allow cancel when saving in wrong format
Claus Gittinger <cg@exept.de>
parents:
2680
diff
changeset
|
2701 |
^ self. |
53bc9dc52ce4
allow cancel when saving in wrong format
Claus Gittinger <cg@exept.de>
parents:
2680
diff
changeset
|
2702 |
]. |
1373
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
2703 |
]. |
2240 | 2704 |
Transcript showCR:('saving as:' , fileName pathName). |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2705 |
|
2824 | 2706 |
what = #image ifTrue: [ |
2707 |
image saveOn:fileName using: imageReaderClass. self clearModified. |
|
2708 |
image fileName:fileNameString. |
|
2709 |
]. |
|
2710 |
what = #mask ifTrue: [ |
|
2711 |
image mask saveOn:fileName using: imageReaderClass |
|
2712 |
]. |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2713 |
|
2240 | 2714 |
fileName exists ifFalse:[ |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2715 |
Dialog warn:'Oops image save failed.' |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2716 |
] |
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2717 |
] |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2718 |
] |
1027
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
2719 |
] |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
2720 |
|
4137 | 2721 |
"Modified: / 27-07-2012 / 09:45:49 / cg" |
633 | 2722 |
! |
2723 |
||
2239 | 2724 |
saveAs |
2725 |
self saveImageFileAs |
|
2726 |
! |
|
2727 |
||
2728 |
saveButtonImageToFileAs |
|
2729 |
|fn| |
|
2730 |
||
2731 |
fn := self askForFileNameToSave:'Save Button Image to File'. |
|
2732 |
self saveButtonImageToFileAs:fn |
|
2733 |
||
2734 |
"Modified: / 30.9.1998 / 23:04:11 / cg" |
|
2735 |
! |
|
2736 |
||
2737 |
saveButtonImageToFileAs: aFileName |
|
2738 |
"save the image as if in a button in aFileName" |
|
2739 |
||
2740 |
|button grabbedImage| |
|
2741 |
||
2742 |
aFileName isNil ifTrue: [^nil]. |
|
2743 |
||
2744 |
image isNil ifTrue:[ |
|
4249 | 2745 |
self warn:(resources string:'No image or image mask to save!!'). |
2239 | 2746 |
^ self. |
2747 |
]. |
|
2748 |
||
2749 |
button := Button label:image. |
|
2750 |
button openAt:5@5. |
|
2751 |
button waitUntilVisible. |
|
2752 |
||
2753 |
grabbedImage := Image fromView:button. |
|
2754 |
button destroy. |
|
2755 |
||
2756 |
self save:grabbedImage imageOrMask:#image as:aFileName |
|
2757 |
||
2758 |
"/ self saveImageOrMask: #mask |
|
2759 |
! |
|
2760 |
||
2761 |
saveImageFileAs |
|
2762 |
"ask for a fileName and save the image" |
|
2763 |
||
2764 |
|fn| |
|
2765 |
||
2766 |
fn := self askForFileNameToSave:'Save Image To File'. |
|
2767 |
self saveImageFileAs:fn |
|
2768 |
! |
|
2769 |
||
2770 |
saveImageFileAs: aFileName |
|
2771 |
"save the image in aFileName" |
|
2772 |
||
2773 |
aFileName isNil ifTrue: [^nil]. |
|
2774 |
image notNil ifTrue:[ |
|
2775 |
self save:image imageOrMask:#image as:aFileName. |
|
2776 |
] ifFalse:[ |
|
4249 | 2777 |
self warn:(resources string:'No image for saving!!') |
2239 | 2778 |
] |
2779 |
||
2780 |
"Modified: / 30.9.1998 / 23:04:55 / cg" |
|
2781 |
! |
|
2782 |
||
2783 |
saveImageMaskFileAs |
|
2784 |
"ask for a fileName and save the mask only" |
|
2785 |
||
2786 |
|fn| |
|
2787 |
||
2788 |
fn := self askForFileNameToSave:'Save Image Mask To File'. |
|
2789 |
self saveImageMaskFileAs:fn |
|
2790 |
||
2791 |
"Modified: / 30.9.1998 / 23:04:11 / cg" |
|
2792 |
! |
|
2793 |
||
2794 |
saveImageMaskFileAs: aFileName |
|
2795 |
"save the mask only in aFileName" |
|
2796 |
||
2797 |
aFileName isNil ifTrue: [^nil]. |
|
2798 |
(image notNil and:[image mask notNil]) ifTrue:[ |
|
2799 |
self save:image imageOrMask:#mask as:aFileName. |
|
2800 |
] ifFalse:[ |
|
4249 | 2801 |
self warn:(resources string:'No image or image mask to save!!') |
2239 | 2802 |
] |
2803 |
||
2804 |
"Modified: / 30.9.1998 / 23:06:24 / cg" |
|
2805 |
! |
|
2806 |
||
2807 |
saveImageOrMask:what |
|
2808 |
"save the image or the mask only (if what == #mask)" |
|
2809 |
||
2810 |
self save:image imageOrMask: what |
|
2811 |
! |
|
2812 |
||
633 | 2813 |
saveMethod |
5364 | 2814 |
"save the image as a resource method. |
2815 |
Return true if ok; false if not" |
|
2816 |
||
4149 | 2817 |
(resourceSelector trimBlanks notEmptyOrNil and:[ resourceClass isBehavior ]) ifFalse: [ |
2915 | 2818 |
^ self saveMethodAs. |
2914 | 2819 |
]. |
2820 |
||
2821 |
windowGroup withExecuteCursorDo:[ |
|
3859 | 2822 |
Error handle:[:ex| |
2823 |
(self confirm:(ex errorString,'\\Debug?' withCRs)) ifTrue:[ ex reject ]. |
|
2915 | 2824 |
^ false |
2914 | 2825 |
] do: [ |
5286 | 2826 |
|img imageSaved depth bestDepth colorsUsed numColorsUsed category imageStoreStream sel mthd imageKey| |
4149 | 2827 |
|
2828 |
img := self image. |
|
4714 | 2829 |
depth := bestDepth := img depth. |
2830 |
colorsUsed := (img usedColorsMax:256). |
|
2831 |
colorsUsed notNil ifTrue:[ |
|
2832 |
numColorsUsed := colorsUsed size. |
|
2833 |
#(8 4 2 1) do:[:d | |
|
2834 |
depth > d ifTrue:[ |
|
2835 |
numColorsUsed <= (1 << d) ifTrue:[ |
|
2836 |
bestDepth := d |
|
2837 |
] |
|
4149 | 2838 |
] |
4714 | 2839 |
]. |
4149 | 2840 |
]. |
5286 | 2841 |
imageSaved := img. |
4149 | 2842 |
bestDepth < depth ifTrue:[ |
5286 | 2843 |
|answer| |
2844 |
||
2845 |
answer := Dialog |
|
2846 |
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?' |
|
2847 |
with:depth with:bestDepth with:numColorsUsed). |
|
2848 |
answer isNil ifTrue:[ |
|
2849 |
"/ cancelled |
|
4149 | 2850 |
^ false |
5286 | 2851 |
]. |
2852 |
answer == true ifTrue:[ |
|
2853 |
imageSaved := (Image implementorForDepth:bestDepth) fromImage:imageSaved |
|
2854 |
]. |
|
4149 | 2855 |
]. |
822
cace81f0a86b
do not overwrite method categories + toggle between mouse button colors
tz
parents:
796
diff
changeset
|
2856 |
|
4000
21106540ffb5
CodeGeneratorTool->SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents:
3980
diff
changeset
|
2857 |
SmalltalkCodeGeneratorTool |
5286 | 2858 |
createImageSpecMethodFor:imageSaved |
1882
fbb4a3a869f1
made image-method generator a class method (for reusability)
martin
parents:
1875
diff
changeset
|
2859 |
comment:(ResourceSpecEditor codeGenerationCommentForClass: ImageEditor) |
2915 | 2860 |
in:resourceClass class |
2861 |
selector:resourceSelector. |
|
822
cace81f0a86b
do not overwrite method categories + toggle between mouse button colors
tz
parents:
796
diff
changeset
|
2862 |
|
5364 | 2863 |
"/ 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
|
2864 |
Icon flushCachedIcons. |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
2865 |
self clearModified. |
1901
b4b286ec221f
flush cached icons, when defining a new image-method
Claus Gittinger <cg@exept.de>
parents:
1896
diff
changeset
|
2866 |
|
2915 | 2867 |
LastSaveClass := resourceClass. |
1882
fbb4a3a869f1
made image-method generator a class method (for reusability)
martin
parents:
1875
diff
changeset
|
2868 |
] |
2915 | 2869 |
]. |
2870 |
^ true |
|
1027
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
2871 |
|
4000
21106540ffb5
CodeGeneratorTool->SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents:
3980
diff
changeset
|
2872 |
"Modified: / 31-01-2011 / 18:28:06 / cg" |
5364 | 2873 |
"Modified (comment): / 25-11-2016 / 08:48:44 / cg" |
633 | 2874 |
! |
2875 |
||
2876 |
saveMethodAs |
|
2915 | 2877 |
"ask for method/selector; save the image there. |
2878 |
Return true if saved, false if not" |
|
2879 |
||
5364 | 2880 |
|className classAndSelector |
2881 |
previousClass previousCategory previousSelector |
|
2882 |
previousMethod newMethod ok| |
|
2883 |
||
2884 |
previousSelector := self resourceSelector. |
|
2908
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
2885 |
className := self resourceClassName. |
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
2886 |
className isEmptyOrNil ifTrue:[ |
2177 | 2887 |
className := LastSaveClass |
1994 | 2888 |
]. |
5364 | 2889 |
(className notEmptyOrNil and:[previousSelector notNil]) ifTrue:[ |
2890 |
previousClass := Smalltalk classNamed:className. |
|
2891 |
previousClass notNil ifTrue:[ |
|
2892 |
previousMethod := previousClass class compiledMethodAt:previousSelector. |
|
2893 |
previousMethod notNil ifTrue:[ |
|
2894 |
previousCategory := previousMethod category. |
|
2895 |
] |
|
2896 |
] |
|
2897 |
]. |
|
633 | 2898 |
|
3840 | 2899 |
self withWaitCursorDo:[ |
2900 |
classAndSelector := ResourceSelectionBrowser |
|
2901 |
request: 'Save Image In Class' |
|
2902 |
onSuperclass: #Object |
|
2903 |
andClass: className |
|
2904 |
andSelector: self resourceSelector |
|
2905 |
withResourceTypes: #(image fileImage programImage). |
|
2906 |
]. |
|
2915 | 2907 |
classAndSelector isNil ifTrue:[^ false]. |
2908 |
||
2909 |
resourceClass := classAndSelector methodClass. |
|
2910 |
resourceSelector := classAndSelector methodSelector. |
|
2911 |
||
5364 | 2912 |
ok := self saveMethod. |
2913 |
ok ifTrue:[ |
|
2914 |
previousCategory notNil ifTrue:[ |
|
2915 |
newMethod := resourceClass class compiledMethodAt:resourceSelector asSymbol. |
|
2916 |
newMethod notNil ifTrue:[ |
|
2917 |
newMethod category:previousCategory. |
|
2918 |
] |
|
2919 |
] |
|
2920 |
]. |
|
2921 |
^ ok |
|
2922 |
||
2923 |
"Modified: / 25-11-2016 / 09:17:22 / cg" |
|
2915 | 2924 |
! ! |
2925 |
||
2926 |
!ImageEditView methodsFor:'printing'! |
|
2927 |
||
2928 |
||
2929 |
self printWithMagnification:1 |
|
2930 |
! |
|
2931 |
||
2932 |
printMagnified |
|
2933 |
self printWithMagnification:magnification |
|
2934 |
! |
|
2935 |
||
2936 |
printWithMagnification:magnification |
|
2937 |
|stream| |
|
2938 |
||
2939 |
image isNil ifTrue:[^ self]. |
|
2940 |
||
2941 |
Printer supportsPostscript ifFalse:[ |
|
4249 | 2942 |
^ self warn:(resources string:'No postscript printer configured !!') |
2915 | 2943 |
]. |
2944 |
||
2945 |
stream := Printer newNative. |
|
2946 |
stream isNil ifTrue:[ |
|
4249 | 2947 |
^ self warn:(resources string:'Cannot open printer stream !!') |
2915 | 2948 |
]. |
2949 |
||
2950 |
self withWaitCursorDo:[ |
|
2951 |
|psgc| |
|
2952 |
||
2953 |
psgc := PSGraphicsContext on:stream. |
|
2954 |
psgc displayForm: (image magnifiedBy: magnification) x:0 y:0. |
|
2955 |
psgc close |
|
2956 |
] |
|
1 | 2957 |
! ! |
2958 |
||
161 | 2959 |
!ImageEditView methodsFor:'queries'! |
5 | 2960 |
|
161 | 2961 |
heightOfContents |
2962 |
||
686 | 2963 |
image isNil ifTrue:[^0]. |
2964 |
^(image height * magnification y) rounded |
|
5 | 2965 |
! |
2966 |
||
995 | 2967 |
imageContainsPastePoint: aPoint |
2968 |
||
2969 |
^image notNil and: |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
2970 |
[Clipboard notNil and: |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
2971 |
[((0@0 corner:(image extent) "- 1" - Clipboard extent) containsPoint: (((aPoint - margin + 1) / magnification) floor))]] |
995 | 2972 |
! |
2973 |
||
627 | 2974 |
imageContainsPoint: aPoint |
632 | 2975 |
|
2976 |
^image notNil and: |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
2977 |
[((0@0 corner:(image extent) - 1) containsPoint: (((aPoint - margin + 1) / magnification) floor))] |
627 | 2978 |
! |
2979 |
||
783 | 2980 |
imageInfoString |
3729 | 2981 |
image isNil ifTrue: [^ 'No image loaded.']. |
2982 |
^ String streamContents:[:s | |
|
2983 |
s print:image width. |
|
2984 |
s print:'x'. |
|
2985 |
s print:image height. |
|
2986 |
s print:' | '. |
|
2987 |
||
2988 |
s print:(image depth). |
|
2989 |
s print:'bit'. |
|
2990 |
image mask notNil ifTrue: [s print:'+mask']. |
|
2991 |
||
5266 | 2992 |
' [%1/%2 colors]' expandPlaceholdersWith:{image nColorsUsed. (2 raisedTo: image depth)} on:s. |
3729 | 2993 |
]. |
783 | 2994 |
! |
2995 |
||
161 | 2996 |
widthOfContents |
5 | 2997 |
|
686 | 2998 |
image isNil ifTrue:[^0]. |
2999 |
^(image width * magnification x) rounded |
|
5 | 3000 |
! ! |
3001 |
||
627 | 3002 |
!ImageEditView methodsFor:'release'! |
3003 |
||
995 | 3004 |
releasePasteDrawing |
2085 | 3005 |
self repairDamage. |
2440 | 3006 |
(lastPastePoint notNil and: [ClipboardMagnified notNil]) |
2747 | 3007 |
ifTrue: [ |
2440 | 3008 |
self redraw: ((lastPastePoint"-self viewOrigin") extent: (ClipboardMagnified extent)). |
2085 | 3009 |
"/ self repairDamage. |
995 | 3010 |
]. |
2440 | 3011 |
lastPastePoint := ClipboardMagnified := nil |
995 | 3012 |
! |
3013 |
||
3014 |
releaseUndos |
|
3015 |
undoImages removeAll. |
|
627 | 3016 |
! ! |
3017 |
||
632 | 3018 |
!ImageEditView methodsFor:'testing'! |
3019 |
||
3020 |
checkModified |
|
2747 | 3021 |
modifiedHolder value ifTrue:[ |
2634 | 3022 |
((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
|
3023 |
noText:(resources string:'Cancel'); |
2634 | 3024 |
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
|
3025 |
showAtPointer; |
2747 | 3026 |
accepted |
3027 |
) ifFalse: [^false]. |
|
3028 |
||
3029 |
self modified:false. |
|
632 | 3030 |
]. |
2591
87cab7199c7e
Use 'Discard Changes and Exit' instead of 'Forget it...'
Stefan Vogel <sv@exept.de>
parents:
2590
diff
changeset
|
3031 |
^ true |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
3032 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
3033 |
"Modified: / 29.7.1998 / 18:55:24 / cg" |
632 | 3034 |
! ! |
3035 |
||
255 | 3036 |
!ImageEditView class methodsFor:'documentation'! |
161 | 3037 |
|
3038 |
version |
|
4853 | 3039 |
^ '$Header$' |
3762 | 3040 |
! |
3041 |
||
3042 |
version_CVS |
|
4853 | 3043 |
^ '$Header$' |
161 | 3044 |
! ! |
2239 | 3045 |
|
4203 | 3046 |
|
1245 | 3047 |
ImageEditView initialize! |