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