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