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