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