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