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