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