author | Claus Gittinger <cg@exept.de> |
Tue, 14 Feb 2006 11:06:11 +0100 | |
changeset 2917 | ac62b66582ce |
parent 2915 | 6f4e171a1092 |
child 3265 | f22de2c4383d |
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 |
" |
|
12 |
||
1763
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
13 |
"{ Package: 'stx:libwidg2' }" |
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
14 |
|
1 | 15 |
ImageView subclass:#ImageEditView |
1246 | 16 |
instanceVariableNames:'magnification imageReaderClass resourceClass resourceSelector |
2747 | 17 |
mouseKeyColorMode undoImages modifiedHolder editMode |
18 |
lastPastePoint imageInfoHolder activityInfoHolder |
|
19 |
pickedColorHolder drawingColors drawingPixels drawingColorHolders |
|
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
20 |
drawingPixelHolders clickInfoCallBack' |
2440 | 21 |
classVariableNames:'Clipboard ClipboardMagnified LastMagnification |
2889 | 22 |
GridMagnificationLimit MaxUndos LastSaveDirectory LastSaveClass |
23 |
EditModePoint EditModeBox EditModeFilledBox EditModeFill |
|
24 |
EditModeCopy EditModePasteUnder EditModePaste |
|
25 |
EditModePasteWithMask EditModeSpecialOperation' |
|
1035 | 26 |
poolDictionaries:'' |
1706 | 27 |
category:'Views-Misc' |
1 | 28 |
! |
29 |
||
636 | 30 |
!ImageEditView class methodsFor:'documentation'! |
31 |
||
32 |
copyright |
|
33 |
" |
|
704 | 34 |
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
|
35 |
All Rights Reserved |
636 | 36 |
|
37 |
This software is furnished under a license and may be used |
|
38 |
only in accordance with the terms of that license and with the |
|
39 |
inclusion of the above copyright notice. This software may not |
|
40 |
be provided or otherwise made available to, or used by, any |
|
41 |
other person. No title to or ownership of the software is |
|
42 |
hereby transferred. |
|
43 |
" |
|
44 |
! |
|
45 |
||
46 |
documentation |
|
47 |
" |
|
2747 | 48 |
An ImageEditView is a view which can be used by applications |
49 |
like the Image Editor for editing or inspecting (bitmap-) images. |
|
636 | 50 |
|
51 |
[see also:] |
|
2747 | 52 |
ImageEditor Image |
636 | 53 |
|
54 |
[author:] |
|
2747 | 55 |
Thomas Zwick |
636 | 56 |
" |
57 |
! ! |
|
353 | 58 |
|
1245 | 59 |
!ImageEditView class methodsFor:'initialization'! |
60 |
||
61 |
initialize |
|
2915 | 62 |
MaxUndos := 10. |
1706 | 63 |
GridMagnificationLimit := 8 @ 8. |
1245 | 64 |
|
2889 | 65 |
EditModePoint := #point. |
66 |
EditModeBox := #box. |
|
67 |
EditModePaste := #paste. |
|
68 |
EditModePasteUnder := #pasteUnder. |
|
69 |
EditModePasteWithMask := #pasteWithMask. |
|
70 |
EditModeFilledBox := #filledBox. |
|
71 |
EditModeFill := #fill. |
|
72 |
EditModeCopy := #copy. |
|
73 |
EditModeSpecialOperation := #specialOperation. |
|
74 |
||
1245 | 75 |
" |
76 |
self initialize |
|
77 |
" |
|
78 |
! ! |
|
79 |
||
1706 | 80 |
!ImageEditView class methodsFor:'accessing'! |
81 |
||
2889 | 82 |
editModeBox |
83 |
^ EditModeBox |
|
84 |
! |
|
85 |
||
86 |
editModeCopy |
|
87 |
^ EditModeCopy |
|
88 |
! |
|
89 |
||
90 |
editModeFill |
|
91 |
^ EditModeFill |
|
92 |
! |
|
93 |
||
94 |
editModeFilledBox |
|
95 |
^ EditModeFilledBox |
|
96 |
! |
|
97 |
||
98 |
editModePaste |
|
99 |
^ EditModePaste |
|
100 |
! |
|
101 |
||
102 |
editModePasteUnder |
|
103 |
^ EditModePasteUnder |
|
104 |
! |
|
105 |
||
106 |
editModePasteWithMask |
|
107 |
^ EditModePasteWithMask |
|
108 |
! |
|
109 |
||
110 |
editModePoint |
|
111 |
^ EditModePoint |
|
112 |
! |
|
113 |
||
114 |
editModeSpecialOperation |
|
115 |
^ EditModeSpecialOperation |
|
116 |
! |
|
117 |
||
1706 | 118 |
gridMagnificationLimit |
119 |
^ GridMagnificationLimit |
|
120 |
! |
|
121 |
||
122 |
gridMagnificationLimit:anInteger |
|
123 |
GridMagnificationLimit := anInteger |
|
124 |
! ! |
|
125 |
||
2480 | 126 |
!ImageEditView class methodsFor:'helpers'! |
127 |
||
128 |
copyImageToClipboard:copiedImage |
|
129 |
ClipboardMagnified := nil. |
|
130 |
Clipboard := copiedImage. |
|
131 |
! ! |
|
132 |
||
2634 | 133 |
!ImageEditView class methodsFor:'resources'! |
134 |
||
135 |
classResources |
|
136 |
^ ImageEditor classResources |
|
137 |
! ! |
|
138 |
||
7 | 139 |
!ImageEditView methodsFor:'accessing'! |
140 |
||
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
141 |
activityInfoHolder |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
142 |
"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
|
143 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
144 |
^ activityInfoHolder |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
145 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
146 |
"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
|
147 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
148 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
149 |
activityInfoHolder:something |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
150 |
"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
|
151 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
152 |
activityInfoHolder := something. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
153 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
154 |
"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
|
155 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
156 |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
157 |
clearModified |
2915 | 158 |
self modified:false |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
159 |
! |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
160 |
|
1693 | 161 |
clickInfoCallBack:aTwoArgBlock |
162 |
clickInfoCallBack := aTwoArgBlock |
|
163 |
||
164 |
"Created: / 10.2.2000 / 23:07:14 / cg" |
|
165 |
! |
|
166 |
||
2440 | 167 |
clipBoard |
168 |
^ Clipboard |
|
169 |
! |
|
170 |
||
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
171 |
drawingColors:anArrayTwoColors |
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
172 |
(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
|
173 |
(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
|
174 |
! |
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
175 |
|
2915 | 176 |
image:anImage scroll:doScroll |
177 |
|retVal fileName| |
|
178 |
||
179 |
anImage isImage ifTrue:[ |
|
180 |
true "(image isNil or: [self checkModified])" ifTrue: [ |
|
181 |
image notNil ifTrue: [ |
|
182 |
fileName := image fileName. |
|
183 |
anImage fileName isNil ifTrue: [anImage fileName: fileName]. |
|
184 |
]. |
|
185 |
super image:anImage scroll:doScroll. |
|
186 |
retVal := self. |
|
187 |
]. |
|
188 |
] ifFalse: [ |
|
189 |
super image:nil scroll:true. |
|
190 |
]. |
|
191 |
"/ self changed:#image. |
|
192 |
image isNil ifTrue:[ |
|
193 |
self clearModified. |
|
194 |
] ifFalse:[ |
|
195 |
self setModified. |
|
196 |
]. |
|
197 |
self updateImageInfo: self imageInfoString. |
|
198 |
^ retVal |
|
199 |
||
200 |
"Modified: / 10.2.2000 / 23:33:12 / cg" |
|
201 |
! |
|
202 |
||
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
203 |
imageInfoHolder |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
204 |
^ imageInfoHolder |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
205 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
206 |
"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
|
207 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
208 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
209 |
imageInfoHolder:something |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
210 |
imageInfoHolder := something. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
211 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
212 |
"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
|
213 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
214 |
|
624 | 215 |
magnification |
216 |
||
217 |
^magnification |
|
218 |
||
255 | 219 |
! |
220 |
||
636 | 221 |
magnification: aPoint |
1037 | 222 |
|oldOrg| |
255 | 223 |
|
627 | 224 |
magnification ~= aPoint |
624 | 225 |
ifTrue: |
226 |
[ |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
227 |
oldOrg := self viewOrigin / magnification. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
228 |
magnification := aPoint asPoint. |
1037 | 229 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
230 |
self scrollTo:(oldOrg * magnification) rounded redraw:false. |
1037 | 231 |
"/ self scrollToTopLeft. |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
232 |
self contentsChanged. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
233 |
self invalidate. |
2440 | 234 |
ClipboardMagnified := nil. |
686 | 235 |
] |
1037 | 236 |
|
237 |
"Modified: / 31.7.1998 / 02:38:47 / cg" |
|
624 | 238 |
! |
255 | 239 |
|
2913 | 240 |
modified |
241 |
^ modifiedHolder value |
|
242 |
! |
|
243 |
||
2747 | 244 |
modified:aBoolean |
245 |
modifiedHolder value:aBoolean |
|
246 |
! |
|
247 |
||
248 |
modifiedHolder |
|
249 |
^ modifiedHolder |
|
250 |
! |
|
251 |
||
2915 | 252 |
removelastUndo |
253 |
undoImages removeLast |
|
254 |
! |
|
255 |
||
627 | 256 |
resourceClass |
2915 | 257 |
^ resourceClass |
627 | 258 |
! |
259 |
||
2915 | 260 |
resourceClass: aClassOrClassNameString |
261 |
"support for names will vanish - obsolete left over from tz" |
|
262 |
||
263 |
resourceClass := aClassOrClassNameString. |
|
264 |
resourceClass notNil ifTrue:[ |
|
265 |
resourceClass isBehavior ifFalse: [ |
|
266 |
resourceClass := Smalltalk classNamed:aClassOrClassNameString |
|
267 |
] |
|
268 |
] |
|
2908
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
269 |
! |
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
270 |
|
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
271 |
resourceClassName |
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
272 |
resourceClass isNil ifTrue:[^ '']. |
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
273 |
^ resourceClass name |
627 | 274 |
! |
275 |
||
276 |
resourceMessage |
|
2909 | 277 |
(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
|
278 |
^ resourceClass name, ' ', resourceSelector |
627 | 279 |
! |
280 |
||
281 |
resourceSelector |
|
2915 | 282 |
^ resourceSelector |
627 | 283 |
! |
284 |
||
285 |
resourceSelector: aStringOrSymbol |
|
2909 | 286 |
aStringOrSymbol isNil ifTrue:[ |
287 |
resourceSelector := nil |
|
288 |
] ifFalse:[ |
|
289 |
resourceSelector := aStringOrSymbol asSymbol |
|
290 |
] |
|
627 | 291 |
! |
292 |
||
293 |
selectedColor |
|
2915 | 294 |
^ (drawingColorHolders at:mouseKeyColorMode) value |
1246 | 295 |
! |
296 |
||
297 |
selectedColor: aColor |
|
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
298 |
(drawingColorHolders at:mouseKeyColorMode) value:aColor |
627 | 299 |
! |
300 |
||
1246 | 301 |
selectedColorIndex |
2915 | 302 |
^ (drawingPixelHolders at:mouseKeyColorMode) value |
1246 | 303 |
! |
304 |
||
305 |
selectedColorIndex: aPixelIndex |
|
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
306 |
(drawingPixelHolders at:mouseKeyColorMode) value: aPixelIndex |
995 | 307 |
! |
308 |
||
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
309 |
setModified |
2915 | 310 |
self modified:true |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
311 |
! |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
312 |
|
995 | 313 |
undoImages |
2915 | 314 |
^ undoImages |
627 | 315 |
! ! |
316 |
||
317 |
!ImageEditView methodsFor:'drawing'! |
|
318 |
||
1036 | 319 |
drawFrame |
320 |
||
321 |
self paint:Color black. |
|
322 |
self lineWidth: (magnification x//3 min: 3). |
|
1104 | 323 |
self displayRectangle: ((0@0) extent:(image extent * magnification) + margin). |
1036 | 324 |
self lineWidth:1. |
325 |
! |
|
326 |
||
327 |
drawFramesIn: aRectangle |
|
328 |
||
1706 | 329 |
magnification >= GridMagnificationLimit |
1036 | 330 |
ifTrue: |
331 |
[ |
|
1706 | 332 |
|origin lineStartingPoint lineEndingPoint oldColor| |
333 |
origin := aRectangle origin - 1. |
|
334 |
lineStartingPoint := origin + (0@magnification y). |
|
335 |
lineEndingPoint := lineStartingPoint + (aRectangle width@0). |
|
336 |
oldColor := self paint. |
|
337 |
self xoring: |
|
338 |
[ |
|
339 |
self displayLineFrom: lineStartingPoint to: lineEndingPoint. |
|
340 |
lineStartingPoint x to: lineStartingPoint x + aRectangle width - magnification x by: magnification x do: |
|
341 |
[:x| |
|
342 |
self displayLineFrom: x@(origin y) to: x@(origin y + magnification y) |
|
343 |
]. |
|
344 |
]. |
|
345 |
self paint: oldColor. |
|
1036 | 346 |
] |
347 |
||
348 |
||
349 |
||
350 |
! |
|
351 |
||
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
352 |
drawPasteRectangleAt: aPoint |
2889 | 353 |
|currentPoint gridCorrection extent| |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
354 |
|
1706 | 355 |
magnification >= GridMagnificationLimit ifFalse: [gridCorrection := 0] ifTrue: [gridCorrection := 1]. |
1449 | 356 |
currentPoint := aPoint // magnification*magnification + margin. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
357 |
|
2085 | 358 |
self repairDamage. |
359 |
||
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
360 |
currentPoint ~= lastPastePoint ifTrue:[ |
2440 | 361 |
ClipboardMagnified isNil ifTrue:[ |
362 |
ClipboardMagnified := (Clipboard magnifiedBy: magnification) onDevice: device |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
363 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
364 |
|
2440 | 365 |
extent := ClipboardMagnified extent. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
366 |
|
1967 | 367 |
"/ currentPoint := currentPoint - self viewOrigin. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
368 |
|
2085 | 369 |
self redraw: (((lastPastePoint ? currentPoint)"-self viewOrigin") extent: extent). |
370 |
self repairDamage. |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
371 |
|
2085 | 372 |
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
|
373 |
self xoring: [ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
374 |
self fillRectangle: (currentPoint extent: extent) |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
375 |
] |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
376 |
] ifFalse:[ |
2440 | 377 |
ClipboardMagnified notNil ifTrue:[ |
378 |
self displayDeviceForm: ClipboardMagnified |
|
2089 | 379 |
x: currentPoint x - self viewOrigin x |
380 |
y: currentPoint y - self viewOrigin y. |
|
381 |
]. |
|
2889 | 382 |
editMode == EditModePastUnder ifTrue:[ |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
383 |
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
|
384 |
] |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
385 |
] |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
386 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
387 |
lastPastePoint := currentPoint. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
388 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
389 |
"Modified: / 18.5.1999 / 20:23:33 / cg" |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
390 |
! |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
391 |
|
662 | 392 |
fillFramedRectangle: aRectangle |
393 |
||
394 |
self fillRectangle: aRectangle. |
|
395 |
self drawFramesIn: aRectangle |
|
396 |
! |
|
397 |
||
1449 | 398 |
redraw:aRectangle |
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
399 |
self |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
400 |
invalidate:(aRectangle origin "+ self viewOrigin" extent:aRectangle extent) |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
401 |
repairNow:true. |
2053
5c19fe5b2db3
invalidate rather than redraw
Claus Gittinger <cg@exept.de>
parents:
2034
diff
changeset
|
402 |
"/ super redraw:(aRectangle origin + self viewOrigin extent:aRectangle extent). |
1449 | 403 |
|
2053
5c19fe5b2db3
invalidate rather than redraw
Claus Gittinger <cg@exept.de>
parents:
2034
diff
changeset
|
404 |
"Modified: / 15.11.2001 / 16:43:53 / cg" |
1449 | 405 |
! |
406 |
||
627 | 407 |
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
|
408 |
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
|
409 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
410 |
"Modified: / 18.5.1999 / 20:14:03 / cg" |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
411 |
! |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
412 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
413 |
redrawImageX:x y:y width:w height:h unmaskedOnly:unmaskedOnly |
636 | 414 |
|
1037 | 415 |
|ih iw magX magY minX maxX minY maxY |
416 |
color lastColor lastY runW x0 xI yI maskColor mask |
|
1180 | 417 |
sizeOfMaskPoint useNearestColor| |
418 |
||
419 |
useNearestColor := device visualType == #PseudoColor. |
|
627 | 420 |
|
1037 | 421 |
mask := image mask. |
627 | 422 |
ih := image height. |
423 |
iw := image width. |
|
662 | 424 |
magX := magnification x. |
425 |
magY := magnification y. |
|
627 | 426 |
|
662 | 427 |
minX := (x // magX - 1) max: 0. |
725 | 428 |
minX >= iw ifTrue:[minX := (iw - 1) max: 0]. |
662 | 429 |
minY := (y // magY - 1) max: 0. |
725 | 430 |
minY >= ih ifTrue:[minY := (ih - 1) max: 0]. |
662 | 431 |
maxX := (x + w) // magX + 1. |
627 | 432 |
maxX > iw ifTrue:[maxX := iw]. |
662 | 433 |
maxY := (y + h) // magY + 1. |
627 | 434 |
maxY > ih ifTrue:[maxY := ih]. |
435 |
||
436 |
lastY := -1. |
|
437 |
||
438 |
x0 := minX. |
|
439 |
runW := 0. |
|
440 |
maskColor := false. |
|
662 | 441 |
sizeOfMaskPoint := magnification//3. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
442 |
image |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
443 |
colorsFromX:minX y:minY toX:maxX-1 y:maxY-1 |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
444 |
do:[:xx :yy :color| |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
445 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
446 |
shown ifFalse:[^ self]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
447 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
448 |
yy ~~ lastY ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
449 |
runW ~~ 0 ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
450 |
|origin| |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
451 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
452 |
origin := (x0 * magX + margin)@(lastY * magY + margin). |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
453 |
(unmaskedOnly not or:[maskColor not]) ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
454 |
self fillFramedRectangle: (origin extent: (runW@magY)). |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
455 |
maskColor ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
456 |
self xoring: [self fillRectangle: (origin + sizeOfMaskPoint extent: sizeOfMaskPoint)] |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
457 |
] |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
458 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
459 |
runW := 0. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
460 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
461 |
x0 := xx. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
462 |
lastY := yy. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
463 |
]. |
1160 | 464 |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
465 |
color ~= lastColor ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
466 |
runW ~~ 0 ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
467 |
|origin| |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
468 |
origin := (x0 * magX + margin)@(yy * magY + margin). |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
469 |
(unmaskedOnly not or:[maskColor not]) ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
470 |
self fillFramedRectangle: (origin extent: (runW@magY)). |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
471 |
maskColor ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
472 |
self xoring: [self fillRectangle: (origin + sizeOfMaskPoint extent: sizeOfMaskPoint)] |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
473 |
]. |
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 |
runW := 0. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
476 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
477 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
478 |
lastColor := color. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
479 |
useNearestColor ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
480 |
lastColor := lastColor nearestOn:device |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
481 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
482 |
self paint:lastColor. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
483 |
mask notNil ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
484 |
maskColor := false. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
485 |
(mask pixelAtX:xx y:yy) == 0 ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
486 |
unmaskedOnly ifFalse:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
487 |
self paint: (lastColor := self viewBackground). |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
488 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
489 |
maskColor := true. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
490 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
491 |
lastColor := nil. |
1160 | 492 |
]. |
493 |
runW := 0. |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
494 |
x0 := xx. |
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 |
runW := runW + magX |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
497 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
498 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
499 |
runW ~~ 0 ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
500 |
|origin| |
624 | 501 |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
502 |
origin := (x0 * magX + margin)@(lastY * magY + margin). |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
503 |
(unmaskedOnly not or:[maskColor not]) ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
504 |
self fillFramedRectangle: (origin extent: runW@magY). |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
505 |
maskColor ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
506 |
self xoring:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
507 |
self fillRectangle: (origin + sizeOfMaskPoint extent: sizeOfMaskPoint) |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
508 |
] |
1180 | 509 |
]. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
510 |
] |
627 | 511 |
]. |
1037 | 512 |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
513 |
"Created: / 18.5.1999 / 20:13:39 / cg" |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
514 |
"Modified: / 18.5.1999 / 20:36:20 / cg" |
627 | 515 |
! |
516 |
||
517 |
redrawX:x y:y width:w height:h |
|
636 | 518 |
|
1967 | 519 |
|ih iw xI yI devImage imgWidth imgHeight| |
627 | 520 |
|
1037 | 521 |
image isNil ifTrue:[^self]. |
662 | 522 |
|
1037 | 523 |
magnification = (1@1) ifTrue: [ |
1510
fd0cd6065dc6
catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
524 |
Object errorSignal handle:[:ex | |
2092 | 525 |
Transcript showCR:'cannot convert image: ', ex description. |
1510
fd0cd6065dc6
catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
526 |
] do:[ |
1763
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
527 |
devImage := image onDevice:device. |
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
528 |
devImage ~~ image ifTrue:[ |
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
529 |
image := devImage. |
1764 | 530 |
self changed:#image. |
1763
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
531 |
]. |
1510
fd0cd6065dc6
catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
532 |
]. |
fd0cd6065dc6
catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
533 |
image device == device ifTrue:[ |
fd0cd6065dc6
catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
534 |
^ super redrawX:x y:y width:w height:h |
fd0cd6065dc6
catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
535 |
]. |
1037 | 536 |
]. |
627 | 537 |
|
1449 | 538 |
self clippingRectangle: (x@y extent:w@h). |
627 | 539 |
|
540 |
self redrawImageX:x y:y width:w height:h. |
|
541 |
||
542 |
"/ right of image ? |
|
543 |
adjust == #center ifTrue: |
|
544 |
[ |
|
1449 | 545 |
xI := (width - ih) // 2 - margin. |
546 |
yI := (height - iw) // 2 - margin. |
|
627 | 547 |
] |
548 |
ifFalse: |
|
549 |
[ |
|
1449 | 550 |
xI := yI := margin |
627 | 551 |
]. |
1967 | 552 |
|
553 |
imgWidth := image width. |
|
554 |
imgHeight := image height. |
|
555 |
||
556 |
(x + w - 1) > (xI + (magnification x * imgWidth)) ifTrue: |
|
627 | 557 |
[ |
1967 | 558 |
self clearRectangleX:(xI + (magnification x * imgWidth)) |
1449 | 559 |
y:y |
1967 | 560 |
width:(x + w - (magnification x * imgWidth) - xI) |
1449 | 561 |
height:h |
627 | 562 |
]. |
1967 | 563 |
(y + h - 1) > (yI + (magnification y * imgHeight)) ifTrue: |
627 | 564 |
[ |
1449 | 565 |
self clearRectangleX:margin |
1967 | 566 |
y:(yI + (magnification y * imgHeight)) |
1449 | 567 |
width:w |
1967 | 568 |
height:(y + h - (magnification y * imgHeight) - yI) |
627 | 569 |
]. |
570 |
self drawFrame. |
|
571 |
self clippingRectangle: nil. |
|
1037 | 572 |
|
573 |
"Modified: / 31.7.1998 / 02:22:45 / cg" |
|
627 | 574 |
! ! |
575 |
||
576 |
!ImageEditView methodsFor:'edit modes'! |
|
577 |
||
578 |
editMode |
|
579 |
||
1106 | 580 |
^editMode |
627 | 581 |
! |
582 |
||
2440 | 583 |
editMode: anEditModeSymbol |
2889 | 584 |
"must be one of the edit modes: |
585 |
||
586 |
EditModePoint |
|
587 |
EditModeBox |
|
588 |
EditModePaste |
|
589 |
EditModePasteUnder |
|
590 |
EditModePasteWithMask |
|
591 |
EditModeFilledBox |
|
592 |
EditModeFill |
|
593 |
EditModeCopy |
|
594 |
EditModeSpecialOperation |
|
595 |
" |
|
627 | 596 |
|
2440 | 597 |
editMode := anEditModeSymbol |
627 | 598 |
! |
599 |
||
600 |
mouseKeyColorMode |
|
601 |
||
602 |
^mouseKeyColorMode printString |
|
603 |
! |
|
604 |
||
605 |
mouseKeyColorMode:aMode |
|
606 |
||
1106 | 607 |
mouseKeyColorMode := aMode |
627 | 608 |
! ! |
609 |
||
610 |
!ImageEditView methodsFor:'event handling'! |
|
611 |
||
612 |
buttonMotion:state x:x y:y |
|
1693 | 613 |
|p| |
614 |
||
2072
abd4e246f393
care for negative pos in buttonMotion (win32 klusge)
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
615 |
(x < 0 or:[y < 0]) ifTrue:[ |
abd4e246f393
care for negative pos in buttonMotion (win32 klusge)
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
616 |
^ self |
abd4e246f393
care for negative pos in buttonMotion (win32 klusge)
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
617 |
]. |
abd4e246f393
care for negative pos in buttonMotion (win32 klusge)
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
618 |
|
1693 | 619 |
p := x@y. |
620 |
||
621 |
state ~~ 0 ifTrue:[ |
|
1245 | 622 |
("self selectedColor notNil" true |
1693 | 623 |
and:[(self imageContainsPoint:p) |
2889 | 624 |
and:[editMode == EditModePoint]]) |
1693 | 625 |
ifTrue:[ |
626 |
self pointAt:p. |
|
1246 | 627 |
^ self |
628 |
]. |
|
1693 | 629 |
self drawCursorAt:p. |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
630 |
] ifFalse:[ |
2092 | 631 |
"/ Transcript showCR:'m'. |
1693 | 632 |
self drawCursorAt:p. |
2508 | 633 |
self inPasteMode ifTrue: [ |
2092 | 634 |
"/ Transcript show:'p '; showCR:(self imageContainsPastePoint:p). |
1693 | 635 |
("self selectedColor notNil" true and: [self imageContainsPastePoint:p]) |
636 |
ifTrue: [self drawPasteRectangleAt:p] |
|
1245 | 637 |
ifFalse: [self cursor:Cursor stop. self releasePasteDrawing] |
638 |
] |
|
686 | 639 |
] |
1019
e68414752bc9
only change the cursor for myself.
Claus Gittinger <cg@exept.de>
parents:
1013
diff
changeset
|
640 |
|
1693 | 641 |
"Modified: / 10.2.2000 / 22:03:18 / cg" |
624 | 642 |
! |
255 | 643 |
|
627 | 644 |
buttonPress:button x:x y:y |
2889 | 645 |
|p clr masked| |
627 | 646 |
|
1693 | 647 |
p := x@y. |
648 |
||
649 |
self drawCursorAt:p. |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
650 |
|
1246 | 651 |
("self selectedColor notNil" true |
1693 | 652 |
and: [self imageContainsPoint:p]) |
1246 | 653 |
ifTrue:[ |
654 |
self sensor shiftDown ifTrue:[ |
|
2277 | 655 |
(image maskAt:(p // magnification)) == 0 ifTrue:[ |
656 |
masked := true. |
|
657 |
] ifFalse:[ |
|
658 |
masked := false. |
|
659 |
clr := image colorAt:(p // magnification). |
|
660 |
]. |
|
1246 | 661 |
pickedColorHolder notNil ifTrue:[ |
662 |
"/ select the color under the cursor, place it into the |
|
663 |
"/ pickedColorHolder/ |
|
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
664 |
pickedColorHolder value:clr. |
1246 | 665 |
]. |
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
666 |
self selectedColor:clr. |
2277 | 667 |
masked ifTrue:[self selectedColorIndex:nil]. |
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
668 |
self changed:#selectedColor with:clr. |
1246 | 669 |
] ifFalse:[ |
670 |
mouseKeyColorMode := button. |
|
671 |
self makeUndo. |
|
1693 | 672 |
|
673 |
clickInfoCallBack notNil ifTrue:[ |
|
674 |
"/ still a kludge, but less ugly ... |
|
675 |
clickInfoCallBack value:button value:p |
|
676 |
]. |
|
1246 | 677 |
"/ editMode is something like #point, #rectangle etc. |
2843 | 678 |
[ |
679 |
self perform: (editMode, 'At:') asSymbol with:p |
|
2889 | 680 |
] on:Error |
681 |
do:[:ex | |
|
682 |
(Dialog confirm:('Error during operation: ', ex description,'\\Debug ?') withCRs ) |
|
683 |
ifTrue:[ |
|
684 |
ex reject |
|
685 |
]. |
|
686 |
]. |
|
1246 | 687 |
] |
686 | 688 |
] |
995 | 689 |
|
1693 | 690 |
"Modified: / 10.2.2000 / 23:11:33 / cg" |
632 | 691 |
! |
692 |
||
994
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
693 |
buttonRelease:button x:x y:y |
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
694 |
|
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
695 |
self drawCursorAt: x@y. |
1246 | 696 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
697 |
("self selectedColor notNil" true and: [self imageContainsPoint: x@y]) |
1246 | 698 |
ifTrue: [ |
1763
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
699 |
image release. |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
700 |
|
1693 | 701 |
"/ "/ cg: what a kludge - please change to use a valueHolder, |
702 |
"/ "/ which gets the information ... |
|
703 |
"/ masterApplication imagePreView invalidate. |
|
704 |
||
705 |
"/ cg: still a kludge - but less ugly |
|
706 |
self changed:#subImageIn with:(image bounds). |
|
994
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
707 |
] |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
708 |
|
1693 | 709 |
"Modified: / 10.2.2000 / 23:41:41 / cg" |
994
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
710 |
! |
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
711 |
|
2508 | 712 |
inPasteMode |
2889 | 713 |
^ (editMode notNil and:[editMode startsWith:#paste]) |
2508 | 714 |
! |
715 |
||
686 | 716 |
pointerLeave:state |
717 |
||
688 | 718 |
super pointerLeave: state. |
686 | 719 |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
720 |
self updateImageInfo: self imageInfoString. |
1019
e68414752bc9
only change the cursor for myself.
Claus Gittinger <cg@exept.de>
parents:
1013
diff
changeset
|
721 |
self cursor:Cursor normal. |
995 | 722 |
|
2508 | 723 |
self inPasteMode ifTrue: [ |
1246 | 724 |
self releasePasteDrawing |
725 |
] |
|
995 | 726 |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
727 |
"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
|
728 |
! ! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
729 |
|
636 | 730 |
!ImageEditView methodsFor:'image editing'! |
627 | 731 |
|
732 |
boxAt: aPoint |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
733 |
"draw a rectangular outline with the currently selected color" |
627 | 734 |
|
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
735 |
|choosenBox imageBox clr| |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
736 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
737 |
(clr := self selectedColor) notNil ifTrue:[ |
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
738 |
choosenBox := self dragRectangleStartingAt: aPoint emphasis: #box. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
739 |
choosenBox notNil ifTrue:[ |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
740 |
imageBox := choosenBox origin//magnification extent: (choosenBox extent//magnification). |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
741 |
image drawRectangle:imageBox withColor:clr. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
742 |
image restored. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
743 |
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
|
744 |
|
1693 | 745 |
"/ "/ cg: what a kludge - please change to use a valueHolder, |
746 |
"/ "/ which gets the information ... |
|
747 |
"/ masterApplication imagePreView redraw: (imageBox expandedBy: 1). |
|
748 |
||
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
749 |
"/ cg: still a kludge - but less ugly |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
750 |
self changed:#subImageIn with:(imageBox expandedBy: 1). |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
751 |
|
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
752 |
self setModified. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
753 |
]. |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
754 |
]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
755 |
|
1693 | 756 |
"Modified: / 10.2.2000 / 23:42:08 / cg" |
632 | 757 |
! |
758 |
||
759 |
copyAt: aPoint |
|
2440 | 760 |
|choosenBox r box copiedImage| |
1084
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
761 |
|
1449 | 762 |
choosenBox := self dragRectangleStartingAt: aPoint emphasis: #inverseFilledBox. |
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
763 |
choosenBox notNil ifTrue:[ |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
764 |
box := choosenBox origin // magnification extent: (choosenBox extent // magnification). |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
765 |
copiedImage := image subImageIn: box. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
766 |
|
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
767 |
self class copyImageToClipboard:copiedImage. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
768 |
|
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
769 |
r := (choosenBox expandedBy:1). |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
770 |
self redraw:r |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
771 |
] |
632 | 772 |
|
1084
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
773 |
"Modified: / 21.8.1998 / 20:16:41 / cg" |
632 | 774 |
! |
775 |
||
2480 | 776 |
copyImageToClipboard |
777 |
self class copyImageToClipboard:image. |
|
778 |
! |
|
779 |
||
1228 | 780 |
cropLeft:doLeft right:doRight top:doTop bottom:doBottom |
1121 | 781 |
|yMinNew yMaxNew xMinNew xMaxNew |
782 |
pix stillCrobbing xMax yMax x y| |
|
783 |
||
784 |
xMax := image width - 1. |
|
785 |
yMax := image height - 1. |
|
786 |
||
787 |
xMinNew := 0. |
|
788 |
doLeft ifTrue:[ |
|
789 |
pix := image pixelAtX:xMinNew y:0. |
|
790 |
stillCrobbing := true. |
|
791 |
[stillCrobbing] whileTrue:[ |
|
792 |
0 to:yMax do:[:y | |
|
793 |
(image pixelAtX:xMinNew y:y) ~~ pix ifTrue:[ |
|
794 |
stillCrobbing := false |
|
795 |
] |
|
796 |
]. |
|
797 |
stillCrobbing ifTrue:[ |
|
798 |
xMinNew := xMinNew + 1. |
|
799 |
xMinNew >= image width ifTrue:[ |
|
800 |
self warn:'Image is all the same color - no crob.'. |
|
801 |
^ self |
|
802 |
] |
|
803 |
]. |
|
804 |
]. |
|
805 |
]. |
|
806 |
||
807 |
xMaxNew := xMax. |
|
808 |
doRight ifTrue:[ |
|
809 |
stillCrobbing := true. |
|
810 |
pix := image pixelAtX:xMaxNew y:0. |
|
811 |
[stillCrobbing] whileTrue:[ |
|
812 |
0 to:yMax do:[:y | |
|
813 |
(image pixelAtX:xMaxNew y:y) ~~ pix ifTrue:[ |
|
814 |
stillCrobbing := false |
|
815 |
] |
|
816 |
]. |
|
817 |
stillCrobbing ifTrue:[ |
|
818 |
xMaxNew := xMaxNew - 1. |
|
819 |
]. |
|
820 |
]. |
|
821 |
]. |
|
822 |
||
823 |
yMinNew := 0. |
|
824 |
doTop ifTrue:[ |
|
825 |
pix := image pixelAtX:xMinNew y:yMinNew. |
|
826 |
stillCrobbing := true. |
|
827 |
[stillCrobbing] whileTrue:[ |
|
828 |
xMinNew to:xMaxNew do:[:x | |
|
829 |
(image pixelAtX:x y:yMinNew) ~~ pix ifTrue:[ |
|
830 |
stillCrobbing := false |
|
831 |
] |
|
832 |
]. |
|
833 |
stillCrobbing ifTrue:[ |
|
834 |
yMinNew := yMinNew + 1. |
|
835 |
]. |
|
836 |
]. |
|
837 |
]. |
|
838 |
||
839 |
yMaxNew := yMax. |
|
840 |
doRight ifTrue:[ |
|
841 |
stillCrobbing := true. |
|
842 |
pix := image pixelAtX:xMaxNew y:yMaxNew. |
|
843 |
[stillCrobbing] whileTrue:[ |
|
844 |
xMinNew to:xMaxNew do:[:x | |
|
845 |
(image pixelAtX:x y:yMaxNew) ~~ pix ifTrue:[ |
|
846 |
stillCrobbing := false |
|
847 |
] |
|
848 |
]. |
|
849 |
stillCrobbing ifTrue:[ |
|
850 |
yMaxNew := yMaxNew - 1. |
|
851 |
]. |
|
852 |
]. |
|
853 |
]. |
|
854 |
||
855 |
(xMinNew == 0 |
|
856 |
and:[xMaxNew == (image width - 1) |
|
857 |
and:[yMinNew == 0 |
|
858 |
and:[yMaxNew == (image height - 1)]]]) ifTrue:[ |
|
859 |
self warn:'No border found - no crob.'. |
|
860 |
^ self |
|
861 |
]. |
|
862 |
||
863 |
"/ self warn:'extract subImage ' |
|
864 |
"/ , (xMinNew @ yMinNew) printString |
|
865 |
"/ , ' -> ' |
|
866 |
"/ , (xMaxNew @ yMaxNew) printString. |
|
867 |
||
2006 | 868 |
self makeUndo. |
1121 | 869 |
self |
870 |
makeSubImageX:xMinNew y:yMinNew |
|
871 |
width:(xMaxNew - xMinNew + 1) |
|
872 |
height:(yMaxNew - yMinNew + 1) |
|
873 |
||
874 |
"Created: / 7.9.1998 / 14:25:52 / cg" |
|
875 |
"Modified: / 7.9.1998 / 16:35:35 / cg" |
|
876 |
! |
|
877 |
||
632 | 878 |
fillAt: aPoint |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
879 |
"perform a flood-fill with the currently selected color" |
627 | 880 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
881 |
windowGroup withExecuteCursorDo:[ |
1693 | 882 |
|filledPoints clr| |
1002 | 883 |
|
1693 | 884 |
(clr := self selectedColor) notNil ifTrue:[ |
885 |
self updateActivity:'Flood filling - press CTRL-y to abort ...'. |
|
886 |
[ |
|
2349 | 887 |
image floodFillAt: aPoint//magnification withColor:clr. |
1693 | 888 |
image restored. |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
889 |
|
2349 | 890 |
self invalidate. |
1693 | 891 |
self changed:#subImageIn with:(image bounds). |
892 |
||
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
893 |
self setModified. |
1693 | 894 |
] valueOnUnwindDo:[ |
895 |
self updateActivity:'Flood fill aborted.' |
|
896 |
]. |
|
897 |
]. |
|
898 |
self updateActivity:'' |
|
632 | 899 |
] |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
900 |
|
1693 | 901 |
"Modified: / 10.2.2000 / 23:40:58 / cg" |
632 | 902 |
! |
903 |
||
904 |
filledBoxAt: aPoint |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
905 |
"fill a rectangular area with the currently selected color" |
632 | 906 |
|
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
907 |
|choosenBox imageBox clr| |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
908 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
909 |
(clr := self selectedColor) notNil ifTrue:[ |
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
910 |
choosenBox := self dragRectangleStartingAt: aPoint emphasis: #filledBox. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
911 |
choosenBox notNil ifTrue:[ |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
912 |
imageBox := choosenBox origin//magnification extent: (choosenBox extent//magnification). |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
913 |
image fillRectangle:imageBox withColor:clr. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
914 |
image restored. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
915 |
self redraw: (choosenBox expandedBy: 1). |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
916 |
|
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
917 |
self changed:#subImageIn with:(imageBox expandedBy: 1). |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
918 |
self setModified. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
919 |
] |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
920 |
] |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
921 |
|
1693 | 922 |
"Modified: / 10.2.2000 / 23:37:04 / cg" |
632 | 923 |
! |
924 |
||
1706 | 925 |
magnifyImageTo:newSize |
926 |
self makeUndo. |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
927 |
self image: (image magnifiedBy: newSize/image extent). |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
928 |
self setModified. |
636 | 929 |
! |
930 |
||
2168 | 931 |
makeNewColorMapByMapping:functionOfColor |
2566
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
932 |
|xMax yMax map revMap anyChange |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
933 |
newColors newColorArray newImage pixelAction| |
2168 | 934 |
|
1886 | 935 |
anyChange := false. |
936 |
||
937 |
xMax := image width - 1. |
|
938 |
yMax := image height - 1. |
|
939 |
||
940 |
newImage := image class width:image width height:image height depth:image depth. |
|
941 |
newImage photometric:image photometric. |
|
2489 | 942 |
"/ newImage colorMap:(image colorMap copy). |
1886 | 943 |
newImage bits:(ByteArray new:(image bits size)). |
944 |
newImage mask:(image mask copy). |
|
945 |
||
2566
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
946 |
image colorMap notNil ifTrue:[ |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
947 |
newColors := Set new. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
948 |
newColorArray := OrderedCollection new. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
949 |
map := Array new:256. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
950 |
revMap := OrderedCollection new. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
951 |
|
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
952 |
pixelAction := |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
953 |
[:x :y | |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
954 |
|pix n_pix clr n_clr| |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
955 |
|
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
956 |
pix := image pixelAtX:x y:y. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
957 |
(n_pix := map at:pix+1) isNil ifTrue:[ |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
958 |
clr := image colorAtX:x y:y. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
959 |
n_clr := functionOfColor value:clr. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
960 |
(newColors includes:n_clr) ifFalse:[ |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
961 |
newColors add:n_clr. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
962 |
newColorArray add:n_clr. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
963 |
revMap add:pix. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
964 |
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
|
965 |
] ifTrue:[ |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
966 |
"/ mhmh - multiple pixels mapped to the same color |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
967 |
n_pix := (newColorArray indexOf:n_clr) - 1. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
968 |
map at:pix+1 put:n_pix. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
969 |
] |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
970 |
]. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
971 |
newImage pixelAtX:x y:y put:n_pix. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
972 |
]. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
973 |
] ifFalse:[ |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
974 |
pixelAction := |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
975 |
[:x :y | |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
976 |
|
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
977 |
|clr n_clr| |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
978 |
|
1886 | 979 |
clr := image colorAtX:x y:y. |
2168 | 980 |
n_clr := functionOfColor value:clr. |
2566
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
981 |
newImage colorAtX:x y:y put:n_clr. |
1886 | 982 |
]. |
2566
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
983 |
]. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
984 |
|
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
985 |
0 to:yMax do:[:y | |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
986 |
0 to:xMax do:[:x | |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
987 |
pixelAction value:x value:y |
1886 | 988 |
] |
989 |
]. |
|
990 |
||
2566
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
991 |
image colorMap notNil ifTrue:[ |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
992 |
newImage colorMap:(MappedPalette withColors:newColorArray). |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
993 |
]. |
1886 | 994 |
self makeUndo. |
995 |
self image:newImage. |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
996 |
self setModified. |
1886 | 997 |
^ true |
998 |
! |
|
999 |
||
1121 | 1000 |
makeSubImageX:oldX y:oldY width:newWidth height:newHeight |
1001 |
|newImage| |
|
1002 |
||
1003 |
newImage := image class width:newWidth height:newHeight depth:image depth. |
|
1004 |
newImage photometric:image photometric. |
|
1005 |
newImage colorMap:image colorMap copy. |
|
1006 |
newImage bits:(ByteArray new:(newImage bytesPerRow * newHeight)). |
|
1007 |
||
1008 |
image mask notNil |
|
1009 |
ifTrue:[ |
|
1010 |
|newMaskImage| |
|
1011 |
||
1012 |
newMaskImage := Depth1Image width:newWidth height:newHeight. |
|
1013 |
newMaskImage photometric: image mask photometric. |
|
1014 |
newMaskImage colorMap: image mask colorMap copy. |
|
1015 |
newMaskImage bits:(ByteArray new: newMaskImage bytesPerRow * newHeight). |
|
1016 |
newImage mask: newMaskImage |
|
1017 |
]. |
|
1018 |
||
1019 |
newImage copyFrom:image x:oldX y:oldY toX:0 y:0 width:newWidth height:newHeight. |
|
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2534
diff
changeset
|
1020 |
self image:newImage scroll:false. |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1021 |
self setModified. |
1121 | 1022 |
|
1023 |
"Created: / 7.9.1998 / 13:00:16 / cg" |
|
1024 |
"Modified: / 7.9.1998 / 14:15:32 / cg" |
|
1025 |
! |
|
1026 |
||
2915 | 1027 |
makeUndo |
1028 |
image notNil ifTrue:[ |
|
1029 |
undoImages size >= MaxUndos ifTrue:[ |
|
1030 |
undoImages removeFirst. |
|
1031 |
]. |
|
1032 |
undoImages add: image copy |
|
1033 |
] |
|
1034 |
! |
|
1035 |
||
636 | 1036 |
pasteAt: aPoint |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1037 |
"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
|
1038 |
|
2135 | 1039 |
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
|
1040 |
! |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1041 |
|
2135 | 1042 |
pasteAt: aPoint mode:modeSymbol |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1043 |
"paste the image in the clipboard at aPoint" |
636 | 1044 |
|
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1045 |
|answer anyColorMissing choosenBox imagePoint imgX imgY copiedImage imageBox newColorMap |
2764 | 1046 |
existingColors newColors allColors currentColorMap newColormap anyColorAdded oldColorMap| |
1888 | 1047 |
|
2440 | 1048 |
Object errorSignal handle:[:ex| |
1246 | 1049 |
ex signal == Image unrepresentableColorSignal ifFalse:[ |
1050 |
ex reject |
|
1051 |
]. |
|
1052 |
self undo. |
|
1053 |
self warn: 'Paste failed !!\Increasing the images depth might help.' withCRs. |
|
1823 | 1054 |
] do: [ |
1246 | 1055 |
windowGroup withExecuteCursorDo:[ |
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1056 |
choosenBox := self dragRectangleStartingAt: aPoint emphasis: #inverseFilledBox. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1057 |
choosenBox isNil ifTrue:[ ^ self ]. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1058 |
|
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1059 |
imagePoint := choosenBox origin//magnification. |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1060 |
|
1246 | 1061 |
copiedImage := Clipboard copy. |
1987 | 1062 |
|
2440 | 1063 |
true "/ image photometric == #palette |
1888 | 1064 |
ifTrue:[ |
1246 | 1065 |
"/ for all colors in the pasted image, |
1066 |
"/ check, if its in the colormap of the |
|
1067 |
"/ target image. |
|
995 | 1068 |
|
2764 | 1069 |
anyColorMissing := anyColorAdded := false. |
1070 |
oldColorMap := image colorMap. |
|
1071 |
oldColorMap notNil ifTrue:[ |
|
1072 |
newColorMap := oldColorMap asOrderedCollection. |
|
1957
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1073 |
copiedImage usedValues do:[:pixel | |
2764 | 1074 |
|pastedColor | |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1075 |
|
1957
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1076 |
pastedColor := copiedImage colorFromValue:pixel. |
2764 | 1077 |
|
1078 |
(newColorMap detect: [:clr| clr = pastedColor] ifNone: nil) isNil |
|
2440 | 1079 |
ifTrue:[ |
2764 | 1080 |
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
|
1081 |
"/ add to colormap |
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1082 |
newColorMap add:pastedColor. |
2764 | 1083 |
anyColorAdded := true. |
1957
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1084 |
"/ 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
|
1085 |
] ifFalse:[ |
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1086 |
"/ Transcript showCR:'color:' , pastedColor displayString , ' not found in targets colorMap'. |
1987 | 1087 |
"/ copiedImage colorMap notNil ifTrue:[ |
1088 |
"/ copiedImage colorMap at: pixel+1 put: Color black. |
|
1089 |
"/ ]. |
|
1957
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1090 |
anyColorMissing := true. |
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1091 |
] |
1246 | 1092 |
] |
1957
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1093 |
]. |
1246 | 1094 |
]. |
2764 | 1095 |
|
1888 | 1096 |
anyColorMissing ifTrue:[ |
1097 |
answer := Dialog |
|
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1098 |
confirmWithCancel:'Some color(s) cannot be represented (colorMap full).\Use nearest or compute colorMap ?' withCRs |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1099 |
labels:#( 'Cancel' 'New ColorMap' 'Use Nearest' ) |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1100 |
values:#( nil new nearest) |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1101 |
default:3. |
1888 | 1102 |
|
1103 |
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
|
1104 |
|
630db3277f10
support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents:
1980
diff
changeset
|
1105 |
currentColorMap := image colorMap. |
1987 | 1106 |
imgX := imagePoint x. |
1107 |
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
|
1108 |
|
1888 | 1109 |
answer == #nearest ifTrue:[ |
1110 |
0 to:copiedImage height-1 do:[:y | |
|
1111 |
0 to:copiedImage width-1 do:[:x | |
|
1112 |
|clr n_clr| |
|
1113 |
||
1987 | 1114 |
(copiedImage maskAtX:x y:y) == 0 ifTrue:[ |
1115 |
image mask isNil ifTrue:[ |
|
1116 |
image createMask. |
|
1117 |
]. |
|
1118 |
image maskAtX:imgX+x y:imgY+y put:0. |
|
1119 |
] ifFalse:[ |
|
2582 | 1120 |
clr := copiedImage colorAtX:x y:y. |
1987 | 1121 |
n_clr := clr nearestIn:currentColorMap. |
2582 | 1122 |
image colorAtX:imgX+x y:imgY+y put:n_clr |
1987 | 1123 |
] |
1888 | 1124 |
] |
1125 |
]. |
|
1987 | 1126 |
image restored. |
1127 |
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
|
1128 |
self setModified. |
1987 | 1129 |
^ self. |
2135 | 1130 |
]. |
1131 |
answer == #new ifTrue:[ |
|
1132 |
existingColors := image usedValues asIdentitySet. |
|
1133 |
newColors := copiedImage usedValues. |
|
1134 |
allColors := existingColors addAll:newColors. |
|
1135 |
allColors size > (1 bitShift:image depth) ifTrue:[ |
|
1136 |
self warn:'Sorry: too many colors - unimplemented function'. |
|
1137 |
self undo. |
|
1986
630db3277f10
support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents:
1980
diff
changeset
|
1138 |
^ self. |
630db3277f10
support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents:
1980
diff
changeset
|
1139 |
]. |
2135 | 1140 |
|
1141 |
newColormap := OrderedCollection new. |
|
1142 |
newColormap addAll:image usedColors. |
|
1143 |
newColormap addAll:copiedImage usedColors. |
|
1144 |
"/ translate image to use new colorMap... |
|
1145 |
||
1146 |
"/ translate image to use new colors ... |
|
1147 |
0 to:image height-1 do:[:y | |
|
1148 |
0 to:image width-1 do:[:x | |
|
1149 |
|clr n_idx| |
|
1150 |
||
1151 |
(image maskAtX:x y:y) == 1 ifTrue:[ |
|
2582 | 1152 |
clr := image colorAtX:x y:y. |
2135 | 1153 |
n_idx := newColormap indexOf:clr. |
1154 |
image pixelAtX:x y:y put:n_idx-1. |
|
1155 |
] |
|
1156 |
] |
|
1157 |
]. |
|
1158 |
image colorMap:newColormap. |
|
1159 |
currentColorMap := newColormap. |
|
1160 |
||
1161 |
"/ paste new image... |
|
1162 |
0 to:copiedImage height-1 do:[:y | |
|
1163 |
0 to:copiedImage width-1 do:[:x | |
|
1164 |
|clr idx| |
|
1165 |
||
1166 |
(copiedImage maskAtX:x y:y) == 1 |
|
1167 |
ifTrue:[ |
|
2582 | 1168 |
clr := copiedImage colorAtX:x y:y. |
2135 | 1169 |
idx := currentColorMap indexOf:clr. |
1170 |
idx == 0 ifTrue:[ |
|
1171 |
currentColorMap add:clr. |
|
1172 |
idx := currentColorMap size. |
|
1173 |
idx > (1 bitShift:image depth) ifTrue:[ |
|
1174 |
self warn:'Sorry: too many colors'. |
|
1175 |
self undo. |
|
1176 |
^ self. |
|
1177 |
]. |
|
1178 |
]. |
|
1179 |
image pixelAtX:imgX+x y:imgY+y put:idx-1. |
|
1180 |
image maskAtX:imgX+x y:imgY+y put:1. |
|
1181 |
] |
|
1182 |
] |
|
1183 |
]. |
|
1184 |
image restored. |
|
1185 |
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
|
1186 |
self setModified. |
1888 | 1187 |
^ self. |
1188 |
]. |
|
2135 | 1189 |
self warn:'Sorry: unimplemented function'. |
1190 |
self undo. |
|
1191 |
^ self. |
|
1888 | 1192 |
]. |
2764 | 1193 |
anyColorAdded ifTrue:[ |
2490
62230519175a
slowly getting rid of the Colormap class
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1194 |
image colorMap:(MappedPalette withColors:newColorMap). |
1246 | 1195 |
]. |
1196 |
]. |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1197 |
|
1246 | 1198 |
copiedImage := image class fromImage: copiedImage. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1199 |
(newColorMap isNil |
2135 | 1200 |
and:[modeSymbol isNil |
1987 | 1201 |
and:[copiedImage mask isNil] ]) ifTrue:[ |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1202 |
"/ use images copy functionality |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1203 |
"/ however, this copies the mask as well, |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1204 |
"/ which is not useful here |
1246 | 1205 |
image copyFrom: copiedImage x:0 y:0 toX: imagePoint x y: imagePoint y width: copiedImage width height: copiedImage height. |
1206 |
] ifFalse:[ |
|
1207 |
imgX := imagePoint x. |
|
1208 |
imgY := imagePoint y. |
|
1028
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
1209 |
|
1246 | 1210 |
0 to:copiedImage height-1 do:[:y | |
1211 |
0 to:copiedImage width-1 do:[:x | |
|
1212 |
|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
|
1213 |
|
1246 | 1214 |
dstX := imgX + x. |
1215 |
dstY := imgY + y. |
|
1216 |
wasMasked := (image maskAtX:dstX y:dstY) == 0. |
|
1217 |
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
|
1218 |
|
1246 | 1219 |
"/ with modeUnder, |
1220 |
"/ only replace, if its either unmasked, |
|
1221 |
"/ or the current drawing color. |
|
2135 | 1222 |
(modeSymbol isNil |
1246 | 1223 |
or:[wasMasked |
2135 | 1224 |
or:[modeSymbol == #withMask]]) |
1246 | 1225 |
ifTrue:[ |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1226 |
newMasked ifFalse:[ |
2764 | 1227 |
image colorAtX:dstX y:dstY put:(copiedImage colorAtX:x y:y). |
1823 | 1228 |
wasMasked ifTrue:[ |
1986
630db3277f10
support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents:
1980
diff
changeset
|
1229 |
image maskAtX:dstX y:dstY put:1 |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1230 |
]. |
1823 | 1231 |
] ifTrue:[ |
1232 |
wasMasked ifFalse:[ |
|
2135 | 1233 |
modeSymbol == #withMask ifTrue:[ |
1234 |
image maskAtX:dstX y:dstY put:0 |
|
1235 |
] |
|
1823 | 1236 |
] |
1237 |
]. |
|
1987 | 1238 |
]. |
1239 |
||
1246 | 1240 |
] |
1241 |
]. |
|
1242 |
]. |
|
1243 |
image restored. |
|
1244 |
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
|
1245 |
"/ masterApplication imagePreView redraw: (imageBox expandedBy: 1). |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1246 |
self setModified. |
1246 | 1247 |
] |
1028
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
1248 |
] |
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
1249 |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1250 |
"Modified: / 18.5.1999 / 20:40:37 / cg" |
636 | 1251 |
! |
1252 |
||
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1253 |
pasteUnderAt: aPoint |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1254 |
"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
|
1255 |
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
|
1256 |
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
|
1257 |
|
2135 | 1258 |
self pasteAt:aPoint mode:#under. |
1259 |
! |
|
1260 |
||
1261 |
pasteWithMaskAt: aPoint |
|
1262 |
"paste the image in the clipboard at aPoint. |
|
1263 |
In this mode, both the mask and the image pixel are pasted" |
|
1264 |
||
1265 |
||
1266 |
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
|
1267 |
! |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1268 |
|
1858 | 1269 |
performSpecialOperationOn:imageBox withColor:clr |
2765 | 1270 |
|operation x0 y0 x1 y1 pixelAction requiredColors missingColors answer hue| |
1858 | 1271 |
|
1272 |
operation := Dialog |
|
2680 | 1273 |
choose:(resources string:'Which Operation:') |
1274 |
fromList:(resources array:#( |
|
2784 | 1275 |
'edit separately' |
1276 |
'-' |
|
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1277 |
'slightly brightened' |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1278 |
'slightly darkened' |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1279 |
'brightened' |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1280 |
'darkened' |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1281 |
'-' |
2765 | 1282 |
'make grey' |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1283 |
'greyed' |
1858 | 1284 |
'grey pattern' |
2765 | 1285 |
'grey pattern (unmasked)' |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1286 |
'-' |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1287 |
'reversed' |
2765 | 1288 |
'-' |
1289 |
'change hue' |
|
1290 |
'colorize' |
|
2680 | 1291 |
)) |
2784 | 1292 |
values:#(edit nil |
1293 |
slightlyBrightened slightlyDarkened brightened darkened |
|
2765 | 1294 |
nil makeGrey greyed greyPattern unmaskedGreyPattern |
1295 |
nil reversed nil changeHue colorize) |
|
1858 | 1296 |
lines:6 |
1297 |
cancel:nil. |
|
1298 |
||
1299 |
self invalidate. |
|
1300 |
self windowGroup processExposeEvents. |
|
1301 |
||
1302 |
operation isNil ifTrue:[^ false]. |
|
1303 |
||
1304 |
x0 := imageBox left. |
|
1305 |
y0 := imageBox top. |
|
1861 | 1306 |
x1 := imageBox right - 1. |
1307 |
y1 := imageBox bottom -1 . |
|
1858 | 1308 |
|
2784 | 1309 |
operation == #edit ifTrue:[ |
1310 |
(self image subImageIn:imageBox) edit. |
|
1311 |
^ false. |
|
1312 |
]. |
|
2177 | 1313 |
operation == #slightlyBrightened ifTrue:[ |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1314 |
pixelAction := [:x :y :clr | clr slightlyLightened]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1315 |
]. |
2177 | 1316 |
operation == #slightlyDarkened ifTrue:[ |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1317 |
pixelAction := [:x :y :clr | clr slightlyDarkened]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1318 |
]. |
2177 | 1319 |
operation == #brightened ifTrue:[ |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1320 |
pixelAction := [:x :y :clr | clr lightened]. |
1858 | 1321 |
]. |
2177 | 1322 |
operation == #darkened ifTrue:[ |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1323 |
pixelAction := [:x :y :clr | clr darkened]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1324 |
]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1325 |
operation == #reversed ifTrue:[ |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1326 |
pixelAction := [:x :y :clr | Color red:(100-clr red) green:(100-clr green) blue:(100-clr blue) ]. |
1858 | 1327 |
]. |
2765 | 1328 |
operation == #makeGrey ifTrue:[ |
1329 |
pixelAction := [:x :y :clr | Color grey:(clr greyIntensity)]. |
|
1330 |
]. |
|
2177 | 1331 |
operation == #greyed ifTrue:[ |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1332 |
pixelAction := [:x :y :clr | clr blendWith:Color grey]. |
1858 | 1333 |
]. |
1334 |
operation == #greyPattern ifTrue:[ |
|
2765 | 1335 |
pixelAction := [:x :y :clr | x odd == y even |
1336 |
ifTrue:[Color grey] |
|
1337 |
ifFalse:[clr]]. |
|
1338 |
]. |
|
1339 |
operation == #unmaskedGreyPattern ifTrue:[ |
|
1340 |
pixelAction := [:x :y :clr | x odd == y even |
|
1341 |
ifTrue:[self image maskAtX:x y:y put:1. Color grey] |
|
1342 |
ifFalse:[clr]]. |
|
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1343 |
]. |
2765 | 1344 |
|
1345 |
operation == #changeHue ifTrue:[ |
|
1346 |
hue := Dialog request:'Hue (0..360)'. |
|
1347 |
hue := Number readFrom:hue onError:nil. |
|
1348 |
hue isNil ifTrue:[^ false]. |
|
1349 |
pixelAction := [:x :y :clr | Color hue:(hue+(clr hue?0)) light:clr light saturation:clr saturation]. |
|
1350 |
]. |
|
1351 |
operation == #colorize ifTrue:[ |
|
1352 |
hue := Dialog request:'Hue (0..360)'. |
|
1353 |
hue := Number readFrom:hue onError:nil. |
|
1354 |
hue isNil ifTrue:[^ false]. |
|
1355 |
pixelAction := [:x :y :clr | Color hue:hue light:clr light saturation:100] |
|
1356 |
]. |
|
1357 |
||
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1358 |
pixelAction isNil ifTrue:[self halt. ^ false]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1359 |
|
2889 | 1360 |
image colorMap notNil ifTrue:[ |
1361 |
"/ compute required colors ... |
|
1362 |
requiredColors := Set new. |
|
1363 |
self image |
|
1364 |
colorsFromX:x0 y:y0 toX:x1 y:y1 |
|
1365 |
do:[:x :y :clr | |
|
1366 |
requiredColors add:(pixelAction value:x value:y value:clr) |
|
2680 | 1367 |
]. |
2889 | 1368 |
|
1369 |
missingColors := requiredColors select:[:clr | (image colorMap includes:clr) not]. |
|
1370 |
||
1371 |
missingColors notEmpty ifTrue:[ |
|
1372 |
answer := Dialog |
|
1373 |
confirmWithCancel:'Some color(s) cannot be represented in the images colorMap.\Use nearest or compute colorMap ?' withCRs |
|
1374 |
labels:#( 'Cancel' 'Add to ColorMap' 'Use Nearest') |
|
1375 |
values:#( nil add nearest) |
|
1376 |
default:3. |
|
1377 |
answer isNil ifTrue:[^ false]. |
|
1378 |
answer == #add ifTrue:[ |
|
1379 |
missingColors size + image colorMap size > (2 raisedTo:image depth) ifTrue:[ |
|
1380 |
self warn:'Missing colors cannot be added to images colormap.'. |
|
1381 |
^ false |
|
1382 |
]. |
|
1383 |
missingColors do:[:eachColor | |
|
1384 |
image colorMap add:eachColor |
|
1385 |
]. |
|
1386 |
answer := #nearest. |
|
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1387 |
]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1388 |
]. |
1858 | 1389 |
]. |
1390 |
||
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1391 |
"/ now, do it |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1392 |
self image |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1393 |
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
|
1394 |
do:[:x :y :clr | |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1395 |
|newClr| |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1396 |
|
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1397 |
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
|
1398 |
answer == #nearest ifTrue:[ |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1399 |
newClr := newClr nearestIn:image colorMap |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1400 |
]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1401 |
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
|
1402 |
]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1403 |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1404 |
self setModified. |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1405 |
^ true. |
1858 | 1406 |
! |
1407 |
||
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
1408 |
pointAt:aPoint |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1409 |
"draw a single pixel with the currently selected color" |
636 | 1410 |
|
1246 | 1411 |
|imagePoint clr pix| |
796 | 1412 |
|
1246 | 1413 |
imagePoint := aPoint // magnification. |
2823 | 1414 |
image colorMap isNil ifTrue:[ |
1415 |
clr := self selectedColor. |
|
1416 |
image atImageAndMask:imagePoint put:clr. |
|
1417 |
] ifFalse:[ |
|
1418 |
pix := self selectedColorIndex. |
|
1419 |
image atImageAndMask:imagePoint putValue:pix. |
|
1246 | 1420 |
]. |
2277 | 1421 |
|
2823 | 1422 |
self setModified. |
1277 | 1423 |
self invalidate:((imagePoint * magnification extent: magnification) expandedBy: 1). |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1424 |
|
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1425 |
"Modified: / 5.9.1998 / 13:25:29 / cg" |
636 | 1426 |
! |
1427 |
||
2086 | 1428 |
shiftImageHorizontal:shiftH vertical:shiftV |
2489 | 1429 |
self shiftImageHorizontal:shiftH vertical:shiftV wrap:false |
1430 |
! |
|
1431 |
||
1432 |
shiftImageHorizontal:shiftH vertical:shiftV wrap:doWrap |
|
1433 |
"shift the pixels; |
|
1434 |
shift<0 is left-shift/up-shift; shift>0 is right-shift/down-shift; |
|
1435 |
doWrap controls if shifted-out pixels are to be shifted in at the opposite side. |
|
1436 |
i.e.: |
|
1437 |
0123456789 -> 3456789789 (shift: -3) 0123456789 -> 0120123456 (shift:3) |
|
1438 |
or, with wrap: |
|
1439 |
0123456789 -> 3456789012 (shift: -3) 0123456789 -> 7890123456 (shift:3) |
|
1440 |
" |
|
1441 |
||
1442 |
|newImage| |
|
1443 |
||
1444 |
newImage := self shifted:image horizontal:shiftH vertical:shiftV wrap:doWrap. |
|
1445 |
self image:newImage. |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1446 |
self setModified. |
2489 | 1447 |
! |
1448 |
||
1449 |
shifted:image horizontal:shiftH vertical:shiftV wrap:doWrap |
|
1450 |
"shift the pixels; |
|
1451 |
shift<0 is left-shift/up-shift; shift>0 is right-shift/down-shift; |
|
1452 |
doWrap controls if shifted-out pixels are to be shifted in at the opposite side. |
|
1453 |
i.e.: |
|
1454 |
0123456789 -> 3456789789 (shift: -3) 0123456789 -> 0120123456 (shift:3) |
|
1455 |
or, with wrap: |
|
1456 |
0123456789 -> 3456789012 (shift: -3) 0123456789 -> 7890123456 (shift:3) |
|
1457 |
" |
|
1458 |
||
2086 | 1459 |
|w h srcX srcY dstX dstY newImage| |
1460 |
||
2489 | 1461 |
doWrap ifTrue:[ |
1462 |
"/ if wrapping, split into two operations to make wrap-code below simpler. |
|
1463 |
||
1464 |
shiftH ~~ 0 ifTrue:[ |
|
1465 |
shiftV ~~ 0 ifTrue:[ |
|
1466 |
newImage := self shifted:image horizontal:shiftH vertical:0 wrap:doWrap. |
|
1467 |
newImage := self shifted:newImage horizontal:0 vertical:shiftV wrap:doWrap. |
|
1468 |
^ newImage |
|
1469 |
]. |
|
1470 |
]. |
|
1471 |
]. |
|
1472 |
(shiftV == 0 and:[shiftH == 0]) ifTrue:[ |
|
1473 |
^ image |
|
1474 |
]. |
|
1475 |
||
2086 | 1476 |
w := image width. |
1477 |
h := image height. |
|
1478 |
||
1479 |
newImage := image copy. |
|
1480 |
||
1481 |
srcX := srcY := dstX := dstY := 0. |
|
1482 |
shiftH < 0 ifTrue:[ |
|
1483 |
srcX := shiftH negated |
|
1484 |
] ifFalse:[ |
|
1485 |
dstX := shiftH |
|
1486 |
]. |
|
1487 |
shiftV < 0 ifTrue:[ |
|
1488 |
srcY := shiftV negated |
|
1489 |
] ifFalse:[ |
|
1490 |
dstY := shiftV |
|
1491 |
]. |
|
1492 |
||
1493 |
newImage copyFrom:image x:srcX y:srcY toX:dstX y:dstY width:w-shiftH abs height:h-shiftV abs. |
|
1494 |
||
2489 | 1495 |
doWrap ifTrue:[ |
1496 |
srcX := srcY := dstX := dstY := 0. |
|
1497 |
||
1498 |
"/ already simplified - see above |
|
1499 |
shiftH ~~ 0 ifTrue:[ |
|
1500 |
"/ shiftV known to be 0 |
|
1501 |
shiftH < 0 ifTrue:[ |
|
1502 |
dstX := w-1-shiftH negated |
|
1503 |
] ifFalse:[ |
|
1504 |
srcX := w-1-shiftH |
|
1505 |
]. |
|
1506 |
w := shiftH abs. |
|
1507 |
] ifFalse:[ |
|
1508 |
"/ shiftH known to be 0 |
|
1509 |
shiftV < 0 ifTrue:[ |
|
1510 |
dstY := h-1-shiftV negated |
|
1511 |
] ifFalse:[ |
|
1512 |
srcY := h-1-shiftV |
|
1513 |
]. |
|
1514 |
h := shiftV abs. |
|
1515 |
]. |
|
1516 |
newImage copyFrom:image x:srcX y:srcY toX:dstX y:dstY width:w height:h. |
|
1517 |
^ newImage |
|
1518 |
]. |
|
1519 |
||
1520 |
^ newImage. |
|
2086 | 1521 |
|
1522 |
"Created: / 7.9.1998 / 13:00:16 / cg" |
|
1523 |
"Modified: / 7.9.1998 / 14:15:32 / cg" |
|
1524 |
! |
|
1525 |
||
1858 | 1526 |
specialOperationAt: aPoint |
1527 |
"special operation on a rectangular area" |
|
1528 |
||
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1529 |
|choosenBox imageBox| |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1530 |
|
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1531 |
choosenBox := self dragRectangleStartingAt: aPoint emphasis: #filledBox. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1532 |
choosenBox isNil ifTrue:[ ^ self ]. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1533 |
|
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1534 |
imageBox := choosenBox origin//magnification extent: (choosenBox extent//magnification). |
1858 | 1535 |
|
1536 |
(self performSpecialOperationOn:imageBox withColor:self selectedColor) ifFalse:[ |
|
1537 |
^ self |
|
1538 |
]. |
|
1539 |
||
1540 |
image restored. |
|
1861 | 1541 |
self invalidate. "/ : (choosedBox expandedBy: 1). |
1542 |
||
1543 |
"/ self redraw: (choosedBox expandedBy: 1). |
|
1858 | 1544 |
|
1545 |
"/ "/ cg: what a kludge - please change to use a valueHolder, |
|
1546 |
"/ "/ which gets the information ... |
|
1547 |
"/ masterApplication imagePreView redraw: (imageBox expandedBy: 1). |
|
1548 |
||
1549 |
"/ cg: still a kludge - but less ugly |
|
1550 |
self changed:#subImageIn with:(imageBox expandedBy: 1). |
|
1551 |
||
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1552 |
self setModified. |
1858 | 1553 |
! |
1554 |
||
636 | 1555 |
undo |
1556 |
||
1693 | 1557 |
undoImages notEmpty ifTrue:[ |
1374 | 1558 |
windowGroup withExecuteCursorDo:[ |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1559 |
self clearModified. |
1374 | 1560 |
self image: undoImages removeLast. |
1693 | 1561 |
self changed:#image. |
1374 | 1562 |
] |
636 | 1563 |
] |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
1564 |
|
1693 | 1565 |
"Modified: / 10.2.2000 / 23:21:24 / cg" |
627 | 1566 |
! ! |
1567 |
||
2839 | 1568 |
!ImageEditView methodsFor:'image manipulation'! |
1569 |
||
1570 |
brightenImage |
|
1571 |
self makeUndo. |
|
1572 |
self image: (image copy lightened). |
|
1573 |
self setModified. |
|
1574 |
! |
|
1575 |
||
1576 |
darkenImage |
|
1577 |
self makeUndo. |
|
1578 |
self image: (image copy darkened). |
|
1579 |
self setModified. |
|
1580 |
! |
|
1581 |
||
1582 |
flipHorizontal |
|
1583 |
||
1584 |
self makeUndo. |
|
1585 |
self image: image copy flipHorizontal. |
|
1586 |
self setModified. |
|
1587 |
! |
|
1588 |
||
1589 |
flipVertical |
|
1590 |
||
1591 |
self makeUndo. |
|
1592 |
self image: image copy flipVertical. |
|
1593 |
self setModified. |
|
1594 |
! |
|
1595 |
||
1596 |
makeBorderedImageX:newX y:newY width:newWidth height:newHeight |
|
1597 |
|newImage oldWidth oldHeight| |
|
1598 |
||
1599 |
oldWidth := image width. |
|
1600 |
oldHeight := image height. |
|
1601 |
||
1602 |
newImage := image class width:newWidth height:newHeight depth:image depth. |
|
1603 |
newImage photometric:image photometric. |
|
1604 |
newImage colorMap:image colorMap copy. |
|
1605 |
newImage bits:(ByteArray new:(newImage bytesPerRow * newHeight)). |
|
1606 |
||
2842 | 1607 |
image mask notNil ifTrue:[ |
2839 | 1608 |
|newMaskImage| |
1609 |
||
1610 |
newMaskImage := Depth1Image width:newWidth height:newHeight. |
|
1611 |
newMaskImage photometric: image mask photometric. |
|
1612 |
newMaskImage colorMap: image mask colorMap copy. |
|
1613 |
newMaskImage bits:(ByteArray new: newMaskImage bytesPerRow * newHeight). |
|
1614 |
newImage mask: newMaskImage |
|
1615 |
]. |
|
1616 |
||
1617 |
newImage copyFrom:image x:0 y:0 toX:newX y:newY width:oldWidth height:oldHeight. |
|
1618 |
self makeUndo. |
|
1619 |
self image:newImage. |
|
1620 |
self setModified. |
|
1621 |
||
1622 |
"Created: / 7.9.1998 / 13:00:16 / cg" |
|
1623 |
"Modified: / 7.9.1998 / 14:15:32 / cg" |
|
1624 |
! |
|
1625 |
||
1626 |
makeBrighter |
|
1627 |
^ self makeNewColorMapByMapping:[:clr | clr lightened]. |
|
1628 |
! |
|
1629 |
||
1630 |
makeDarker |
|
1631 |
^ self makeNewColorMapByMapping:[:clr | clr darkened]. |
|
1632 |
! |
|
1633 |
||
2841 | 1634 |
makeGrayScaleImage |
2839 | 1635 |
^ self makeNewColorMapByMapping:[:clr | Color brightness:(clr brightness)]. |
1636 |
! |
|
1637 |
||
1638 |
makeInverse |
|
1639 |
^ self makeNewColorMapByMapping:[:clr | |
|
1640 |
Color red:(100-clr red) green:(100-clr green) blue:(100-clr blue)]. |
|
1641 |
! |
|
1642 |
||
1643 |
negativeImage |
|
1644 |
||
1645 |
self makeUndo. |
|
1646 |
self image: (image copy bits:(image bits invert)). |
|
1647 |
self setModified. |
|
1648 |
! |
|
1649 |
||
1650 |
reduceColorResolutionBy:numBits |
|
1651 |
|newImage| |
|
1652 |
||
1653 |
numBits > 7 ifTrue:[ |
|
1654 |
self warn:'Max. number of bits to strip off is 7.'. |
|
1655 |
^ false |
|
1656 |
]. |
|
1657 |
newImage := image withColorResolutionReducedBy:numBits. |
|
1658 |
newImage isNil ifTrue:[ |
|
1659 |
self warn:'Could not reduce color resolution.'. |
|
1660 |
^ false. |
|
1661 |
]. |
|
1662 |
||
1663 |
self makeUndo. |
|
1664 |
self image:newImage. |
|
1665 |
self setModified. |
|
1666 |
^ true |
|
1667 |
! |
|
1668 |
||
1669 |
resizeImageTo:newSize |
|
1670 |
||
1671 |
|newImage newMaskImage| |
|
1672 |
||
1673 |
newImage := image class width: newSize x height: newSize y depth: image depth. |
|
1674 |
newImage photometric:image photometric. |
|
1675 |
newImage colorMap:image colorMap copy. |
|
1676 |
newImage bits: (ByteArray new: newImage bytesPerRow * newSize y). |
|
1677 |
||
1678 |
image mask notNil ifTrue:[ |
|
1679 |
newMaskImage := Depth1Image width: newSize x height: newSize y. |
|
1680 |
newMaskImage photometric: image mask photometric. |
|
1681 |
newMaskImage colorMap: image mask colorMap copy. |
|
1682 |
newMaskImage bits:(ByteArray new: newMaskImage bytesPerRow * newSize y). |
|
1683 |
newImage mask: newMaskImage |
|
1684 |
]. |
|
1685 |
||
1686 |
newImage copyFrom:image x:0 y:0 toX:0 y:0 width: (image width min:newSize x) height: (image height min:newSize y). |
|
1687 |
self makeUndo. |
|
1688 |
self image: newImage. |
|
1689 |
self setModified. |
|
1690 |
! |
|
1691 |
||
1692 |
rotateImageBy:rotation |
|
1693 |
"rotate by (degrees)" |
|
1694 |
||
1695 |
Object errorSignal handle:[:ex| |
|
1696 |
self warn: 'Image rotation failed!!\' withCRs, 'Increaing the image depth could help.' |
|
1697 |
] do:[ |
|
1698 |
self makeUndo. |
|
1699 |
self image: (image hardRotated: rotation). |
|
1700 |
self setModified. |
|
1701 |
] |
|
1702 |
||
1703 |
"Modified: / 29.7.1998 / 18:21:14 / cg" |
|
1704 |
! ! |
|
1705 |
||
2511 | 1706 |
!ImageEditView methodsFor:'image-dragging & info'! |
1707 |
||
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1708 |
dragRectangleStartingAt:aPointIn emphasis:emphasis |
2511 | 1709 |
"drag a rectangle (filled or unfilled)" |
1710 |
||
1711 |
|currentPoint currentExtent firstPoint lastCurrentPoint gridCorrection |
|
1712 |
mp lastMp p whichQuarter scrollX scrollY aPoint| |
|
1713 |
||
1714 |
aPoint := aPointIn. |
|
1715 |
firstPoint := currentPoint := lastCurrentPoint := aPoint//magnification*magnification. |
|
1716 |
magnification >= GridMagnificationLimit ifFalse: [gridCorrection := 0] ifTrue: [gridCorrection := 1]. |
|
1717 |
||
1718 |
[device anyButtonPressed] whileTrue: [ |
|
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1719 |
(self sensor hasKeyEventFor:nil) ifTrue:[ |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1720 |
self invalidate. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1721 |
^ nil. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1722 |
]. |
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1723 |
|
2511 | 1724 |
mp := self sensor mousePoint. |
1725 |
mp = lastMp ifTrue:[ |
|
1726 |
Delay waitForSeconds:0.05 |
|
1727 |
] ifFalse:[ |
|
1728 |
lastMp := mp. |
|
1729 |
mp := device translatePoint:mp fromView:nil toView:self. |
|
1730 |
"/ mp is a device coordinate here ... |
|
1731 |
scrollX := 0. |
|
1732 |
mp x > width ifTrue:[ |
|
1733 |
scrollX := mp x - width. |
|
1734 |
] ifFalse:[ |
|
1735 |
mp x < 0 ifTrue:[ |
|
1736 |
scrollX := mp x. |
|
1737 |
] |
|
1738 |
]. |
|
1739 |
scrollY := 0. |
|
1740 |
mp y > height ifTrue:[ |
|
1741 |
scrollY := mp y - height. |
|
1742 |
] ifFalse:[ |
|
1743 |
mp y < 0 ifTrue:[ |
|
1744 |
scrollY := mp y. |
|
1745 |
] |
|
1746 |
]. |
|
1747 |
(scrollX + scrollY) ~~ 0 ifTrue:[ |
|
1748 |
self scrollTo:(self viewOrigin + (scrollX @ scrollY)). |
|
1749 |
lastMp := nil. |
|
1750 |
]. |
|
1751 |
||
1752 |
mp := mp + self viewOrigin. |
|
1753 |
"/ mp is now a logical coordinate. |
|
1754 |
||
1755 |
currentPoint := (0@0) max: (image extent * magnification min: (p := mp)). |
|
1756 |
currentPoint := currentPoint//magnification*magnification. |
|
1757 |
currentExtent := (firstPoint - currentPoint) abs. |
|
1758 |
whichQuarter := (firstPoint x - currentPoint x) > 0 |
|
1759 |
ifTrue: [(firstPoint y - currentPoint y) > 0 ifTrue: ["4"1@1] ifFalse: ["3"1@0]] |
|
1760 |
ifFalse: [(firstPoint y - currentPoint y) > 0 ifTrue: ["1"0@1] ifFalse: ["2"0@0]]. |
|
1761 |
||
1762 |
self drawCursorAt: p withLabel: |
|
1763 |
((firstPoint//magnification - whichQuarter + 1) printString, |
|
1764 |
' to: ', |
|
1765 |
(currentPoint//magnification + whichQuarter) printString), |
|
1766 |
' (extent: ', |
|
1767 |
(currentExtent//magnification) printString, ')'. |
|
1768 |
||
1769 |
currentPoint ~= lastCurrentPoint ifTrue:[ |
|
1770 |
emphasis = #inverseFilledBox ifTrue: [ |
|
1771 |
self redraw: ((firstPoint min: lastCurrentPoint) - 1 extent: (firstPoint - lastCurrentPoint) abs + 2). |
|
2838
8525a35121d2
changeHLS fixed dfor depth24-images;
Claus Gittinger <cg@exept.de>
parents:
2824
diff
changeset
|
1772 |
self xoring: [ self fillRectangle: ((firstPoint min: currentPoint) + margin extent: currentExtent - gridCorrection) ] |
2511 | 1773 |
]. |
1774 |
emphasis = #box |
|
1775 |
ifTrue:[ |
|
1776 |
|origin extent lineWidthY lineWidthX| |
|
1777 |
origin := (firstPoint min: lastCurrentPoint) - 1. |
|
1778 |
extent := (firstPoint - lastCurrentPoint) abs + 2. |
|
1779 |
lineWidthY := extent y min: (magnification y + 2). |
|
1780 |
lineWidthX := extent x min: (magnification x + 2). |
|
1781 |
self redraw: (origin extent: (extent x@lineWidthY)). |
|
1782 |
self redraw: ((origin x@(origin y + extent y - lineWidthY)) extent: (extent x@lineWidthY)). |
|
1783 |
self redraw: ((origin x@(origin y + lineWidthY)) extent: (lineWidthX@(0 max: (extent y - (lineWidthY * 2))))). |
|
1784 |
self redraw: (((origin x + extent x - lineWidthX)@(origin y + lineWidthY)) extent: (lineWidthX@(extent y - (lineWidthY * 2)))). |
|
1785 |
self selectedColor ~= Color noColor |
|
1786 |
ifTrue: [self paint: self selectedColor] |
|
1787 |
ifFalse: [self paint: self viewBackground]. |
|
1788 |
origin := (firstPoint min: currentPoint) + margin. |
|
1789 |
extent := currentExtent - gridCorrection. |
|
1790 |
lineWidthY := extent y min: magnification y. |
|
1791 |
lineWidthX := extent x min: magnification x. |
|
1792 |
(lineWidthY > 0 and: [lineWidthX > 0]) |
|
1793 |
ifTrue:[ |
|
1794 |
self fillRectangle: (origin extent: (extent x@lineWidthY)). |
|
1795 |
self fillRectangle: ((origin x@(origin y + extent y - lineWidthY)) extent: (extent x@lineWidthY)). |
|
1796 |
self fillRectangle: ((origin x@(origin y + lineWidthY)) extent: (lineWidthX@(0 max: (extent y - (lineWidthY * 2))))). |
|
1797 |
self fillRectangle: (((origin x + extent x - lineWidthX)@(origin y + lineWidthY)) extent: (lineWidthX@(extent y - (lineWidthY * 2)))). |
|
1798 |
] |
|
1799 |
]. |
|
1800 |
emphasis = #filledBox |
|
1801 |
ifTrue:[ |
|
1802 |
self redraw: ((firstPoint min: lastCurrentPoint) - 1 extent: (firstPoint - lastCurrentPoint) abs + 2). |
|
1803 |
self selectedColor ~= Color noColor |
|
1804 |
ifTrue: [self paint: self selectedColor] |
|
1805 |
ifFalse: [self paint: self viewBackground]. |
|
1806 |
self fillRectangle: ((firstPoint min: currentPoint) + margin extent: currentExtent - gridCorrection). |
|
1807 |
]. |
|
1808 |
]. |
|
1809 |
lastCurrentPoint := currentPoint. |
|
1810 |
]. |
|
1811 |
]. |
|
1812 |
||
1813 |
^((0@0) max: (firstPoint min: currentPoint)) extent: (firstPoint - currentPoint) abs |
|
1814 |
||
1815 |
"Created: / 21.8.1998 / 20:17:07 / cg" |
|
1816 |
"Modified: / 10.10.2001 / 14:13:08 / cg" |
|
1817 |
! |
|
1818 |
||
1819 |
drawCursorAt:aPoint |
|
1820 |
|clr imgPoint r g b| |
|
1821 |
||
1822 |
image isNil ifTrue: [ |
|
1823 |
self updateImageInfo: self imageInfoString. |
|
1824 |
self cursor:Cursor stop. |
|
1825 |
^ self |
|
1826 |
]. |
|
1827 |
||
1828 |
imgPoint := aPoint // magnification. |
|
1829 |
((imgPoint x between:0 and:(image width-1)) |
|
1830 |
and:[imgPoint y between:0 and: (image height-1)]) |
|
1831 |
ifFalse:[ |
|
1832 |
self updateImageInfo: self imageInfoString. |
|
1833 |
self cursor:Cursor stop. |
|
1834 |
] ifTrue: [ |
|
1835 |
clr := image colorAt:imgPoint. |
|
1836 |
r := clr redByte. |
|
1837 |
g := clr greenByte. |
|
1838 |
b := clr blueByte. |
|
1839 |
self updateImageInfo: imgPoint printString |
|
1840 |
, ' (r:' |
|
1841 |
, r printString |
|
1842 |
, ' g:' , g printString |
|
1843 |
, ' b:' , b printString |
|
1844 |
, ' #' , (r hexPrintString:2) , (g hexPrintString:2) , (b hexPrintString:2) |
|
1845 |
, ' pixel:' , (image pixelAt:imgPoint) printString |
|
1846 |
, ')'. |
|
1847 |
self cursor:Cursor crossHair |
|
1848 |
]. |
|
1849 |
||
1850 |
"Modified: / 29.7.1998 / 18:26:01 / cg" |
|
1851 |
! |
|
1852 |
||
1853 |
drawCursorAt: aPoint withLabel: aLabel |
|
1854 |
||
1855 |
((0@0 extent: image extent * magnification) containsPoint: aPoint) |
|
1856 |
ifFalse:[self cursor:Cursor stop] |
|
1857 |
ifTrue: [self cursor:Cursor crossHair]. |
|
1858 |
self updateImageInfo: aLabel. |
|
1859 |
||
1860 |
"Modified: / 29.7.1998 / 18:26:04 / cg" |
|
1861 |
! |
|
1862 |
||
1863 |
updateActivity: something |
|
1864 |
|msg| |
|
1865 |
||
1866 |
msg := something printString. |
|
1867 |
||
1868 |
"/ cg: new code: |
|
1869 |
activityInfoHolder notNil ifTrue:[ |
|
1870 |
activityInfoHolder value:msg. |
|
1871 |
]. |
|
1872 |
||
1873 |
"Modified: / 29.7.1998 / 18:41:47 / cg" |
|
1874 |
! |
|
1875 |
||
1876 |
updateImageInfo: something |
|
1877 |
|msg coordLabel| |
|
1878 |
||
1879 |
msg := something printString. |
|
1880 |
||
1881 |
"/ cg: new code: |
|
1882 |
imageInfoHolder notNil ifTrue:[ |
|
1883 |
msg ~= imageInfoHolder value ifTrue:[ |
|
1884 |
imageInfoHolder value:msg. |
|
1885 |
]. |
|
1886 |
^ self |
|
1887 |
]. |
|
1888 |
||
1889 |
"/ "/ cg: what a kludge - please change to use a valueHolder, |
|
1890 |
"/ "/ which gets the coordinate ... |
|
1891 |
"/ |
|
1892 |
"/ (masterApplication respondsTo: #coordLabel) |
|
1893 |
"/ ifTrue:[ |
|
1894 |
"/ coordLabel := masterApplication coordLabel. |
|
1895 |
"/ |
|
1896 |
"/ coordLabel label ~= msg |
|
1897 |
"/ ifTrue:[ |
|
1898 |
"/ coordLabel label: msg. |
|
1899 |
"/ "/ coordLabel redraw |
|
1900 |
"/ ] |
|
1901 |
"/ ] |
|
1902 |
||
1903 |
"Modified: / 29.7.1998 / 19:00:21 / cg" |
|
1904 |
! ! |
|
1905 |
||
2818 | 1906 |
!ImageEditView methodsFor:'initialization & release'! |
1327 | 1907 |
|
1908 |
destroy |
|
2440 | 1909 |
ClipboardMagnified := Clipboard := nil. |
1327 | 1910 |
LastMagnification := magnification. |
1911 |
||
1912 |
super destroy |
|
1913 |
! |
|
1 | 1914 |
|
161 | 1915 |
initialize |
1916 |
super initialize. |
|
627 | 1917 |
|
686 | 1918 |
self enableMotionEvents. |
995 | 1919 |
|
1374 | 1920 |
undoImages := List new: MaxUndos. |
2915 | 1921 |
|
1706 | 1922 |
magnification := LastMagnification ? (8@8). |
2747 | 1923 |
modifiedHolder := false asValue. |
627 | 1924 |
mouseKeyColorMode := 1. |
2908
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
1925 |
resourceClass := resourceSelector := nil. |
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
1926 |
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
|
1927 |
drawingPixelHolders := Array with:(nil asValue) with:(nil asValue). "/ left/right mouse colors |
2889 | 1928 |
self editMode:EditModePoint. |
1 | 1929 |
! ! |
1930 |
||
2915 | 1931 |
!ImageEditView methodsFor:'loading & saving'! |
1 | 1932 |
|
1994 | 1933 |
askForFileNameToSave:msg |
1934 |
"ask for a fileName" |
|
1935 |
||
1936 |
|lastFn fn filters| |
|
1937 |
||
1938 |
filters := FileSelectionBrowser saveImageFileNameFilters. |
|
1939 |
lastFn := self image fileName. |
|
1940 |
lastFn isNil ifTrue:[ |
|
1941 |
fn := FileSelectionBrowser |
|
1942 |
request: msg |
|
1943 |
inDirectory: LastSaveDirectory |
|
1944 |
withFileFilters: filters |
|
1945 |
] ifFalse:[ |
|
1946 |
fn := FileSelectionBrowser |
|
1947 |
request: msg |
|
1948 |
fileName: lastFn |
|
1949 |
withFileFilters: filters |
|
1950 |
]. |
|
1951 |
||
1952 |
^ fn |
|
1953 |
! |
|
1954 |
||
724 | 1955 |
loadFromClass |
2915 | 1956 |
|classAndSelector| |
1957 |
||
1958 |
classAndSelector := ResourceSelectionBrowser |
|
1184 | 1959 |
request: 'Load Image From Class' |
1960 |
onSuperclass: nil |
|
2915 | 1961 |
andClass: self resourceClass |
1184 | 1962 |
andSelector: self resourceSelector |
2915 | 1963 |
withResourceTypes: #(image fileImage programImage). |
1964 |
||
1965 |
classAndSelector notNil ifTrue:[ |
|
1966 |
self loadFromClass:(classAndSelector methodClass) andSelector:(classAndSelector methodSelector) |
|
1967 |
]. |
|
161 | 1968 |
! |
1969 |
||
2915 | 1970 |
loadFromClass:aClassOrClassName andSelector: aStringOrSymbol |
1971 |
"support for names will vanish - obsolete left over from tz" |
|
1972 |
||
1973 |
imageReaderClass := nil. |
|
1974 |
self resourceClass: aClassOrClassName. |
|
1975 |
self resourceSelector: aStringOrSymbol. |
|
1976 |
||
1977 |
resourceClass isBehavior ifFalse:[^ nil]. |
|
1978 |
||
1979 |
(resourceClass respondsTo:resourceSelector) ifTrue:[ |
|
1980 |
image := resourceClass perform:resourceSelector. |
|
1981 |
]. |
|
1982 |
||
1983 |
image isNil ifTrue:[^ nil]. |
|
1984 |
||
1985 |
image := image copy. |
|
1986 |
self releaseUndos. |
|
1987 |
self image:image. |
|
1988 |
self clearModified. |
|
1989 |
^ image |
|
2556 | 1990 |
! |
1991 |
||
2915 | 1992 |
loadFromFile: aFileName |
1993 |
|imageFromFile| |
|
1994 |
||
1995 |
aFileName isNil ifTrue: [^nil]. |
|
1996 |
||
1997 |
Object errorSignal handle:[:exeption| |
|
1998 |
self warn: exeption errorString. |
|
1999 |
^nil |
|
2000 |
] do:[ |
|
2001 |
(imageFromFile := Image fromFile: aFileName) notNil |
|
2002 |
ifTrue:[ |
|
2003 |
self releaseUndos. |
|
2004 |
self image: imageFromFile. |
|
2005 |
self clearModified. |
|
2006 |
"/ imageReaderClass := ImageReader allSubclasses |
|
2007 |
"/ detect: [:cls| cls isValidImageFile: aFileName asFilename pathName] |
|
2008 |
"/ ifNone: [self error: 'Unknown image file format!!'] |
|
2009 |
] ifFalse:[ |
|
2010 |
self error: 'Not an image file (or unrecognized format) !!' |
|
2011 |
] |
|
2555 | 2012 |
]. |
2915 | 2013 |
^ imageFromFile |
2014 |
||
2015 |
"Modified: / 29.7.1998 / 18:09:13 / cg" |
|
2016 |
! |
|
2017 |
||
2018 |
loadFromMessage:classAndSelector |
|
2019 |
"switch to the class and selector specified by classAndSelector." |
|
2020 |
||
2021 |
^ self loadFromClass:(classAndSelector methodClass) andSelector:(classAndSelector methodSelector) |
|
2022 |
! |
|
2023 |
||
2024 |
loadfromClass:aClassOrSymbol andSelector: aStringOrSymbol |
|
2025 |
self obsoleteMethodWarning. |
|
2026 |
^ self loadFromClass:aClassOrSymbol andSelector: aStringOrSymbol |
|
624 | 2027 |
! |
2028 |
||
2029 |
save |
|
632 | 2030 |
self saveImageOrMask: #image. |
624 | 2031 |
! |
2032 |
||
2239 | 2033 |
save:image imageOrMask:what |
2034 |
"save the image or the mask only (if what == #mask)" |
|
297 | 2035 |
|
2239 | 2036 |
image isNil ifTrue:[ |
2037 |
Dialog warn: 'No image to save!!'. |
|
2038 |
^ self. |
|
2039 |
]. |
|
2040 |
self save:image imageOrMask:what as:image fileName. |
|
627 | 2041 |
! |
297 | 2042 |
|
2239 | 2043 |
save:image imageOrMask:what as:fileNameArg |
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2044 |
"save the image or the mask only (if what == #mask)" |
628 | 2045 |
|
2240 | 2046 |
|fileName fileNameString| |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2047 |
|
2239 | 2048 |
fileName := fileNameArg asFilename. |
2783 | 2049 |
LastSaveDirectory := fileName directoryName. |
2239 | 2050 |
|
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2051 |
Object errorSignal handle:[:ex| |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2052 |
|msg| |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2053 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2054 |
ex signal == Image fileCreationErrorSignal ifTrue:[ |
1896 | 2055 |
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
|
2056 |
] ifFalse:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2057 |
msg := ex errorString. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2058 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2059 |
Dialog warn:msg. |
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2060 |
] do:[ |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2061 |
Image informationLostQuerySignal handle:[:ex| |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2062 |
"/ should make those warnings visible ... |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2063 |
(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
|
2064 |
ex proceed. |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2065 |
] |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2066 |
] do:[ |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2067 |
windowGroup withCursor:Cursor write do:[ |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2068 |
|suff fn| |
1027
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
2069 |
|
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2070 |
image isNil ifTrue:[ |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2071 |
^ self error: 'No image to save!!' |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2072 |
]. |
632 | 2073 |
|
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2074 |
what = #mask ifTrue:[ |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2075 |
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
|
2076 |
]. |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2077 |
|
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2078 |
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
|
2079 |
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
|
2080 |
imageReaderClass := nil. |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
2081 |
imageReaderClass := MIMETypes imageReaderForSuffix:suff. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2082 |
|
1373
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
2083 |
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
|
2084 |
imageReaderClass := XPMReader. |
2589
10827ba87692
obsolete method calls cleaned up
Claus Gittinger <cg@exept.de>
parents:
2582
diff
changeset
|
2085 |
fileNameString := fileName name , '.xpm'. |
2240 | 2086 |
fileName := fileNameString asFilename. |
2087 |
image fileName:fileNameString. |
|
1373
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
2088 |
Dialog warn:(('Dont know how to write ''.' , suff , '''-files\\Saving in xpm format as ''%1''.') |
2240 | 2089 |
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
|
2090 |
]. |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
2091 |
(imageReaderClass canRepresent:image) ifFalse:[ |
1991 | 2092 |
imageReaderClass == XPMReader ifTrue:[ |
2093 |
Dialog warn:('Saving in ''.' , suff , '''-format is not supported (or image cannot be represented in this format).\\Please try another format.') withCRs. |
|
2094 |
^ self. |
|
2095 |
]. |
|
1373
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
2096 |
imageReaderClass := XPMReader. |
2589
10827ba87692
obsolete method calls cleaned up
Claus Gittinger <cg@exept.de>
parents:
2582
diff
changeset
|
2097 |
fileNameString := fileName name , '.xpm'. |
2240 | 2098 |
fileName := fileNameString asFilename. |
2099 |
image fileName:fileNameString. |
|
2690
53bc9dc52ce4
allow cancel when saving in wrong format
Claus Gittinger <cg@exept.de>
parents:
2680
diff
changeset
|
2100 |
(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
|
2101 |
withCRs bindWith:fileNameString allBold)) ifFalse:[ |
53bc9dc52ce4
allow cancel when saving in wrong format
Claus Gittinger <cg@exept.de>
parents:
2680
diff
changeset
|
2102 |
^ self. |
53bc9dc52ce4
allow cancel when saving in wrong format
Claus Gittinger <cg@exept.de>
parents:
2680
diff
changeset
|
2103 |
]. |
1373
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
2104 |
]. |
2240 | 2105 |
Transcript showCR:('saving as:' , fileName pathName). |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2106 |
|
2824 | 2107 |
what = #image ifTrue: [ |
2108 |
image saveOn:fileName using: imageReaderClass. self clearModified. |
|
2109 |
image fileName:fileNameString. |
|
2110 |
]. |
|
2111 |
what = #mask ifTrue: [ |
|
2112 |
image mask saveOn:fileName using: imageReaderClass |
|
2113 |
]. |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2114 |
|
2240 | 2115 |
fileName exists ifFalse:[ |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2116 |
Dialog warn:'Oops image save failed.' |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2117 |
] |
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2118 |
] |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2119 |
] |
1027
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
2120 |
] |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
2121 |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2122 |
"Modified: / 18.5.1999 / 19:46:54 / cg" |
633 | 2123 |
! |
2124 |
||
2239 | 2125 |
saveAs |
2126 |
self saveImageFileAs |
|
2127 |
! |
|
2128 |
||
2129 |
saveButtonImageToFileAs |
|
2130 |
|fn| |
|
2131 |
||
2132 |
fn := self askForFileNameToSave:'Save Button Image to File'. |
|
2133 |
self saveButtonImageToFileAs:fn |
|
2134 |
||
2135 |
"Modified: / 30.9.1998 / 23:04:11 / cg" |
|
2136 |
! |
|
2137 |
||
2138 |
saveButtonImageToFileAs: aFileName |
|
2139 |
"save the image as if in a button in aFileName" |
|
2140 |
||
2141 |
|button grabbedImage| |
|
2142 |
||
2143 |
aFileName isNil ifTrue: [^nil]. |
|
2144 |
||
2145 |
image isNil ifTrue:[ |
|
2146 |
self warn: 'No image or image mask detected!!'. |
|
2147 |
^ self. |
|
2148 |
]. |
|
2149 |
||
2150 |
button := Button label:image. |
|
2151 |
button openAt:5@5. |
|
2152 |
button waitUntilVisible. |
|
2153 |
||
2154 |
grabbedImage := Image fromView:button. |
|
2155 |
button destroy. |
|
2156 |
||
2157 |
self save:grabbedImage imageOrMask:#image as:aFileName |
|
2158 |
||
2159 |
"/ self saveImageOrMask: #mask |
|
2160 |
! |
|
2161 |
||
2162 |
saveImageFileAs |
|
2163 |
"ask for a fileName and save the image" |
|
2164 |
||
2165 |
|fn| |
|
2166 |
||
2167 |
fn := self askForFileNameToSave:'Save Image To File'. |
|
2168 |
self saveImageFileAs:fn |
|
2169 |
! |
|
2170 |
||
2171 |
saveImageFileAs: aFileName |
|
2172 |
"save the image in aFileName" |
|
2173 |
||
2174 |
aFileName isNil ifTrue: [^nil]. |
|
2175 |
image notNil ifTrue:[ |
|
2176 |
self save:image imageOrMask:#image as:aFileName. |
|
2177 |
] ifFalse:[ |
|
2178 |
self warn: 'No image for saving!!' |
|
2179 |
] |
|
2180 |
||
2181 |
"Modified: / 30.9.1998 / 23:04:55 / cg" |
|
2182 |
! |
|
2183 |
||
2184 |
saveImageMaskFileAs |
|
2185 |
"ask for a fileName and save the mask only" |
|
2186 |
||
2187 |
|fn| |
|
2188 |
||
2189 |
fn := self askForFileNameToSave:'Save Image Mask To File'. |
|
2190 |
self saveImageMaskFileAs:fn |
|
2191 |
||
2192 |
"Modified: / 30.9.1998 / 23:04:11 / cg" |
|
2193 |
! |
|
2194 |
||
2195 |
saveImageMaskFileAs: aFileName |
|
2196 |
"save the mask only in aFileName" |
|
2197 |
||
2198 |
aFileName isNil ifTrue: [^nil]. |
|
2199 |
(image notNil and:[image mask notNil]) ifTrue:[ |
|
2200 |
self save:image imageOrMask:#mask as:aFileName. |
|
2201 |
] ifFalse:[ |
|
2202 |
self warn: 'No image or image mask detected!!' |
|
2203 |
] |
|
2204 |
||
2205 |
"Modified: / 30.9.1998 / 23:06:24 / cg" |
|
2206 |
! |
|
2207 |
||
2208 |
saveImageOrMask:what |
|
2209 |
"save the image or the mask only (if what == #mask)" |
|
2210 |
||
2211 |
self save:image imageOrMask: what |
|
2212 |
! |
|
2213 |
||
633 | 2214 |
saveMethod |
2915 | 2215 |
((resourceSelector trimBlanks isEmptyOrNil) | resourceClass isBehavior not) ifTrue: [ |
2216 |
^ self saveMethodAs. |
|
2914 | 2217 |
]. |
2218 |
||
2219 |
windowGroup withExecuteCursorDo:[ |
|
2220 |
Object errorSignal handle:[:ex| |
|
2221 |
self warn: ex errorString. |
|
2915 | 2222 |
^ false |
2914 | 2223 |
] do: [ |
2224 |
|category imageStoreStream sel mthd imageKey| |
|
822
cace81f0a86b
do not overwrite method categories + toggle between mouse button colors
tz
parents:
796
diff
changeset
|
2225 |
|
2149
04e8367eaf70
code generation moved to CodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents:
2135
diff
changeset
|
2226 |
CodeGeneratorTool |
04e8367eaf70
code generation moved to CodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents:
2135
diff
changeset
|
2227 |
createImageSpecMethodFor:self image |
1882
fbb4a3a869f1
made image-method generator a class method (for reusability)
martin
parents:
1875
diff
changeset
|
2228 |
comment:(ResourceSpecEditor codeGenerationCommentForClass: ImageEditor) |
2915 | 2229 |
in:resourceClass class |
2230 |
selector:resourceSelector. |
|
822
cace81f0a86b
do not overwrite method categories + toggle between mouse button colors
tz
parents:
796
diff
changeset
|
2231 |
|
1901
b4b286ec221f
flush cached icons, when defining a new image-method
Claus Gittinger <cg@exept.de>
parents:
1896
diff
changeset
|
2232 |
"/ flush cache images in the Icon class (kludge) |
b4b286ec221f
flush cached icons, when defining a new image-method
Claus Gittinger <cg@exept.de>
parents:
1896
diff
changeset
|
2233 |
Icon flushCachedIcons. |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
2234 |
self clearModified. |
1901
b4b286ec221f
flush cached icons, when defining a new image-method
Claus Gittinger <cg@exept.de>
parents:
1896
diff
changeset
|
2235 |
|
2915 | 2236 |
LastSaveClass := resourceClass. |
1882
fbb4a3a869f1
made image-method generator a class method (for reusability)
martin
parents:
1875
diff
changeset
|
2237 |
] |
2915 | 2238 |
]. |
2239 |
^ true |
|
1027
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
2240 |
|
1047 | 2241 |
"Modified: / 31.7.1998 / 20:12:54 / cg" |
633 | 2242 |
! |
2243 |
||
2244 |
saveMethodAs |
|
2915 | 2245 |
"ask for method/selector; save the image there. |
2246 |
Return true if saved, false if not" |
|
2247 |
||
2248 |
|className classAndSelector| |
|
1994 | 2249 |
|
2908
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
2250 |
className := self resourceClassName. |
a759fa87d598
some code cleanup (resourceClass was actually its name)
Claus Gittinger <cg@exept.de>
parents:
2889
diff
changeset
|
2251 |
className isEmptyOrNil ifTrue:[ |
2177 | 2252 |
className := LastSaveClass |
1994 | 2253 |
]. |
633 | 2254 |
|
2915 | 2255 |
classAndSelector := ResourceSelectionBrowser |
1994 | 2256 |
request: 'Save Image In Class' |
2257 |
onSuperclass: #Object |
|
2258 |
andClass: className |
|
2259 |
andSelector: self resourceSelector |
|
2915 | 2260 |
withResourceTypes: #(image fileImage programImage). |
2261 |
||
2262 |
classAndSelector isNil ifTrue:[^ false]. |
|
2263 |
||
2264 |
resourceClass := classAndSelector methodClass. |
|
2265 |
resourceSelector := classAndSelector methodSelector. |
|
2266 |
||
2267 |
^ self saveMethod |
|
2268 |
! ! |
|
2269 |
||
2270 |
!ImageEditView methodsFor:'printing'! |
|
2271 |
||
2272 |
||
2273 |
self printWithMagnification:1 |
|
2274 |
! |
|
2275 |
||
2276 |
printMagnified |
|
2277 |
self printWithMagnification:magnification |
|
2278 |
! |
|
2279 |
||
2280 |
printWithMagnification:magnification |
|
2281 |
|stream| |
|
2282 |
||
2283 |
image isNil ifTrue:[^ self]. |
|
2284 |
||
2285 |
Printer supportsPostscript ifFalse:[ |
|
2286 |
^ self warn:'No postscript printer configured !!' |
|
2287 |
]. |
|
2288 |
||
2289 |
stream := Printer newNative. |
|
2290 |
stream isNil ifTrue:[ |
|
2291 |
^ self warn:'Cannot open printer stream !!' |
|
2292 |
]. |
|
2293 |
||
2294 |
self withWaitCursorDo:[ |
|
2295 |
|psgc| |
|
2296 |
||
2297 |
psgc := PSGraphicsContext on:stream. |
|
2298 |
psgc displayForm: (image magnifiedBy: magnification) x:0 y:0. |
|
2299 |
psgc close |
|
2300 |
] |
|
1 | 2301 |
! ! |
2302 |
||
161 | 2303 |
!ImageEditView methodsFor:'queries'! |
5 | 2304 |
|
161 | 2305 |
heightOfContents |
2306 |
||
686 | 2307 |
image isNil ifTrue:[^0]. |
2308 |
^(image height * magnification y) rounded |
|
5 | 2309 |
! |
2310 |
||
995 | 2311 |
imageContainsPastePoint: aPoint |
2312 |
||
2313 |
^image notNil and: |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
2314 |
[Clipboard notNil and: |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
2315 |
[((0@0 corner:(image extent) "- 1" - Clipboard extent) containsPoint: (((aPoint - margin + 1) / magnification) floor))]] |
995 | 2316 |
! |
2317 |
||
627 | 2318 |
imageContainsPoint: aPoint |
632 | 2319 |
|
2320 |
^image notNil and: |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
2321 |
[((0@0 corner:(image extent) - 1) containsPoint: (((aPoint - margin + 1) / magnification) floor))] |
627 | 2322 |
! |
2323 |
||
783 | 2324 |
imageInfoString |
2325 |
||
2326 |
|imageInfoString usedColors| |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2327 |
|
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2328 |
image isNil ifTrue: [imageInfoString := 'No image loaded.'] |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2329 |
ifFalse: [ |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
2330 |
image colorMap isNil ifTrue: [usedColors := '?'] ifFalse: [usedColors := image usedColors size]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
2331 |
imageInfoString := image width printString, 'x' |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
2332 |
, image height printString, 'x' |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
2333 |
, (2 raisedTo: image depth) printString |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
2334 |
, (image mask notNil ifTrue: [' (mask + '] ifFalse: ['(']) |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
2335 |
, usedColors printString |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
2336 |
, ' used colors)']. |
783 | 2337 |
|
2338 |
^imageInfoString |
|
2339 |
! |
|
2340 |
||
161 | 2341 |
widthOfContents |
5 | 2342 |
|
686 | 2343 |
image isNil ifTrue:[^0]. |
2344 |
^(image width * magnification x) rounded |
|
5 | 2345 |
! ! |
2346 |
||
627 | 2347 |
!ImageEditView methodsFor:'release'! |
2348 |
||
995 | 2349 |
releasePasteDrawing |
2085 | 2350 |
self repairDamage. |
2440 | 2351 |
(lastPastePoint notNil and: [ClipboardMagnified notNil]) |
2747 | 2352 |
ifTrue: [ |
2440 | 2353 |
self redraw: ((lastPastePoint"-self viewOrigin") extent: (ClipboardMagnified extent)). |
2085 | 2354 |
"/ self repairDamage. |
995 | 2355 |
]. |
2440 | 2356 |
lastPastePoint := ClipboardMagnified := nil |
995 | 2357 |
! |
2358 |
||
2359 |
releaseUndos |
|
2360 |
undoImages removeAll. |
|
627 | 2361 |
! ! |
2362 |
||
632 | 2363 |
!ImageEditView methodsFor:'testing'! |
2364 |
||
2365 |
checkModified |
|
2747 | 2366 |
modifiedHolder value ifTrue:[ |
2634 | 2367 |
((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
|
2368 |
noText:(resources string:'Cancel'); |
2634 | 2369 |
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
|
2370 |
showAtPointer; |
2747 | 2371 |
accepted |
2372 |
) ifFalse: [^false]. |
|
2373 |
||
2374 |
self modified:false. |
|
632 | 2375 |
]. |
2591
87cab7199c7e
Use 'Discard Changes and Exit' instead of 'Forget it...'
Stefan Vogel <sv@exept.de>
parents:
2590
diff
changeset
|
2376 |
^ true |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
2377 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
2378 |
"Modified: / 29.7.1998 / 18:55:24 / cg" |
632 | 2379 |
! ! |
2380 |
||
255 | 2381 |
!ImageEditView class methodsFor:'documentation'! |
161 | 2382 |
|
2383 |
version |
|
2917 | 2384 |
^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.218 2006-02-14 10:06:11 cg Exp $' |
161 | 2385 |
! ! |
2239 | 2386 |
|
1245 | 2387 |
ImageEditView initialize! |