author | Claus Gittinger <cg@exept.de> |
Sun, 09 May 1999 16:02:46 +0200 | |
changeset 1373 | c949e9f7757c |
parent 1327 | ab99aad206dc |
child 1374 | 44f511c341c0 |
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 |
" |
|
12 |
||
1 | 13 |
ImageView subclass:#ImageEditView |
1246 | 14 |
instanceVariableNames:'magnification imageReaderClass resourceClass resourceSelector |
15 |
mouseKeyColorMode undoImages modified masterApplication editMode |
|
16 |
lastPastePoint imageInfoHolder activityInfoHolder |
|
17 |
pickedColorHolder drawingColors drawingPixels' |
|
1035 | 18 |
classVariableNames:'Clipboard LastMagnification ClipboardMagnification |
19 |
GridMagnification MaxUndos' |
|
20 |
poolDictionaries:'' |
|
21 |
category:'Views-Misc' |
|
1 | 22 |
! |
23 |
||
636 | 24 |
!ImageEditView class methodsFor:'documentation'! |
25 |
||
26 |
copyright |
|
27 |
" |
|
704 | 28 |
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
|
29 |
All Rights Reserved |
636 | 30 |
|
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
! |
|
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
The ImageEditView is a view class which can be used by applications |
|
43 |
like the Image Editor for modifying or inspecting images. |
|
44 |
||
45 |
[see also:] |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
46 |
ImageEditor Image |
636 | 47 |
|
48 |
[author:] |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
49 |
Thomas Zwick |
636 | 50 |
" |
51 |
! ! |
|
353 | 52 |
|
1245 | 53 |
!ImageEditView class methodsFor:'initialization'! |
54 |
||
55 |
initialize |
|
56 |
MaxUndos := 5. |
|
57 |
GridMagnification := 8 @ 8. |
|
58 |
||
59 |
" |
|
60 |
self initialize |
|
61 |
" |
|
62 |
! ! |
|
63 |
||
7 | 64 |
!ImageEditView methodsFor:'accessing'! |
65 |
||
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
66 |
activityInfoHolder |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
67 |
"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
|
68 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
69 |
^ activityInfoHolder |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
70 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
71 |
"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
|
72 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
73 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
74 |
activityInfoHolder:something |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
75 |
"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
|
76 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
77 |
activityInfoHolder := something. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
78 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
79 |
"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
|
80 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
81 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
82 |
imageInfoHolder |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
83 |
"return the value of the instance variable 'imageInfoHolder' (automatically generated)" |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
84 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
85 |
^ imageInfoHolder |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
86 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
87 |
"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
|
88 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
89 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
90 |
imageInfoHolder:something |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
91 |
"set the value of the instance variable 'imageInfoHolder' (automatically generated)" |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
92 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
93 |
imageInfoHolder := something. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
94 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
95 |
"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
|
96 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
97 |
|
624 | 98 |
magnification |
99 |
||
100 |
^magnification |
|
101 |
||
255 | 102 |
! |
103 |
||
636 | 104 |
magnification: aPoint |
1037 | 105 |
|oldOrg| |
255 | 106 |
|
627 | 107 |
magnification ~= aPoint |
624 | 108 |
ifTrue: |
109 |
[ |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
110 |
oldOrg := self viewOrigin / magnification. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
111 |
magnification := aPoint asPoint. |
1037 | 112 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
113 |
self scrollTo:(oldOrg * magnification) rounded redraw:false. |
1037 | 114 |
"/ self scrollToTopLeft. |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
115 |
self contentsChanged. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
116 |
self invalidate. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
117 |
ClipboardMagnification := nil. |
686 | 118 |
] |
1037 | 119 |
|
120 |
"Modified: / 31.7.1998 / 02:38:47 / cg" |
|
624 | 121 |
! |
255 | 122 |
|
662 | 123 |
masterApplication |
124 |
||
125 |
^masterApplication |
|
126 |
! |
|
127 |
||
128 |
masterApplication: anApplicationModel |
|
129 |
||
130 |
masterApplication := anApplicationModel |
|
131 |
! |
|
132 |
||
627 | 133 |
resourceClass |
134 |
||
135 |
^resourceClass |
|
136 |
! |
|
137 |
||
138 |
resourceClass: aClassOrSymbol |
|
139 |
||
686 | 140 |
resourceClass := aClassOrSymbol isClass ifTrue: [aClassOrSymbol name] ifFalse: [aClassOrSymbol asSymbol] |
627 | 141 |
! |
142 |
||
143 |
resourceMessage |
|
144 |
||
145 |
^resourceClass, ' ', resourceSelector |
|
146 |
! |
|
147 |
||
636 | 148 |
resourceMessage: aString |
627 | 149 |
|
636 | 150 |
(aString isString and: [aString trimBlanks size > 0]) |
627 | 151 |
ifTrue: |
152 |
[ |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
153 |
resourceClass := (aString readStream upTo: Character space) asSymbol. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
154 |
resourceSelector := (aString copy reverse readStream upTo: Character space) reverse asSymbol |
627 | 155 |
] |
156 |
ifFalse: |
|
157 |
[ |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
158 |
^nil |
686 | 159 |
] |
627 | 160 |
|
161 |
||
162 |
! |
|
163 |
||
164 |
resourceSelector |
|
165 |
||
166 |
^resourceSelector |
|
167 |
! |
|
168 |
||
169 |
resourceSelector: aStringOrSymbol |
|
170 |
||
171 |
resourceSelector := aStringOrSymbol asSymbol |
|
172 |
! |
|
173 |
||
840 | 174 |
selectColors |
175 |
||
1246 | 176 |
^drawingColors |
840 | 177 |
! |
178 |
||
179 |
selectColors: anArrayTwoColors |
|
633 | 180 |
|
1246 | 181 |
drawingColors := anArrayTwoColors |
633 | 182 |
! |
183 |
||
627 | 184 |
selectedColor |
185 |
||
1246 | 186 |
^drawingColors at: mouseKeyColorMode |
187 |
! |
|
188 |
||
189 |
selectedColor: aColor |
|
190 |
||
191 |
drawingColors at: mouseKeyColorMode put: aColor |
|
627 | 192 |
! |
193 |
||
1246 | 194 |
selectedColorIndex |
627 | 195 |
|
1246 | 196 |
^ drawingPixels at: mouseKeyColorMode |
197 |
! |
|
198 |
||
199 |
selectedColorIndex: aPixelIndex |
|
200 |
||
201 |
drawingPixels at: mouseKeyColorMode put: aPixelIndex |
|
995 | 202 |
! |
203 |
||
204 |
undoImages |
|
205 |
||
206 |
^undoImages |
|
627 | 207 |
! ! |
208 |
||
209 |
!ImageEditView methodsFor:'drawing'! |
|
210 |
||
1036 | 211 |
drawFrame |
212 |
||
213 |
self paint:Color black. |
|
214 |
self lineWidth: (magnification x//3 min: 3). |
|
1104 | 215 |
self displayRectangle: ((0@0) extent:(image extent * magnification) + margin). |
1036 | 216 |
self lineWidth:1. |
217 |
! |
|
218 |
||
219 |
drawFramesIn: aRectangle |
|
220 |
||
221 |
magnification >= GridMagnification |
|
222 |
ifTrue: |
|
223 |
[ |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
224 |
|origin lineStartingPoint lineEndingPoint oldColor| |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
225 |
origin := aRectangle origin - 1. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
226 |
lineStartingPoint := origin + (0@magnification y). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
227 |
lineEndingPoint := lineStartingPoint + (aRectangle width@0). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
228 |
oldColor := self paint. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
229 |
self xoring: |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
230 |
[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
231 |
self displayLineFrom: lineStartingPoint to: lineEndingPoint. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
232 |
lineStartingPoint x to: lineStartingPoint x + aRectangle width - magnification x by: magnification x do: |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
233 |
[:x| |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
234 |
self displayLineFrom: x@(origin y) to: x@(origin y + magnification y) |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
235 |
]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
236 |
]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
237 |
self paint: oldColor. |
1036 | 238 |
] |
239 |
||
240 |
||
241 |
||
242 |
! |
|
243 |
||
662 | 244 |
fillFramedRectangle: aRectangle |
245 |
||
246 |
self fillRectangle: aRectangle. |
|
247 |
self drawFramesIn: aRectangle |
|
248 |
! |
|
249 |
||
627 | 250 |
redrawImageX:x y:y width:w height:h |
636 | 251 |
|
1037 | 252 |
|ih iw magX magY minX maxX minY maxY |
253 |
color lastColor lastY runW x0 xI yI maskColor mask |
|
1180 | 254 |
sizeOfMaskPoint useNearestColor| |
255 |
||
256 |
useNearestColor := device visualType == #PseudoColor. |
|
627 | 257 |
|
1037 | 258 |
mask := image mask. |
627 | 259 |
ih := image height. |
260 |
iw := image width. |
|
662 | 261 |
magX := magnification x. |
262 |
magY := magnification y. |
|
627 | 263 |
|
662 | 264 |
minX := (x // magX - 1) max: 0. |
725 | 265 |
minX >= iw ifTrue:[minX := (iw - 1) max: 0]. |
662 | 266 |
minY := (y // magY - 1) max: 0. |
725 | 267 |
minY >= ih ifTrue:[minY := (ih - 1) max: 0]. |
662 | 268 |
maxX := (x + w) // magX + 1. |
627 | 269 |
maxX > iw ifTrue:[maxX := iw]. |
662 | 270 |
maxY := (y + h) // magY + 1. |
627 | 271 |
maxY > ih ifTrue:[maxY := ih]. |
272 |
||
273 |
lastY := -1. |
|
274 |
||
275 |
x0 := minX. |
|
276 |
runW := 0. |
|
277 |
maskColor := false. |
|
662 | 278 |
sizeOfMaskPoint := magnification//3. |
279 |
image colorsFromX: minX y: minY toX: maxX-1 y: maxY-1 do: |
|
627 | 280 |
[:xx :yy :color| |
1160 | 281 |
shown ifFalse:[^ self]. |
282 |
||
283 |
yy ~~ lastY |
|
284 |
ifTrue: |
|
285 |
[ |
|
286 |
runW ~~ 0 |
|
287 |
ifTrue: |
|
288 |
[ |
|
289 |
|origin| |
|
290 |
origin := (x0 * magX + margin)@(lastY * magY + margin). |
|
291 |
self fillFramedRectangle: (origin extent: (runW@magY)). |
|
292 |
maskColor ifTrue: |
|
293 |
[ |
|
294 |
self xoring: [self fillRectangle: (origin + sizeOfMaskPoint extent: sizeOfMaskPoint)] |
|
295 |
]. |
|
296 |
runW := 0. |
|
297 |
]. |
|
298 |
x0 := xx. |
|
299 |
lastY := yy. |
|
300 |
]. |
|
624 | 301 |
|
1180 | 302 |
color ~= lastColor |
1160 | 303 |
ifTrue: |
304 |
[ |
|
305 |
runW ~~ 0 |
|
306 |
ifTrue: |
|
307 |
[ |
|
308 |
|origin| |
|
309 |
origin := (x0 * magX + margin)@(yy * magY + margin). |
|
310 |
self fillFramedRectangle: (origin extent: (runW@magY)). |
|
311 |
maskColor ifTrue: |
|
312 |
[ |
|
313 |
self xoring: [self fillRectangle: (origin + sizeOfMaskPoint extent: sizeOfMaskPoint)] |
|
314 |
]. |
|
315 |
runW := 0. |
|
316 |
]. |
|
627 | 317 |
|
1180 | 318 |
lastColor := color. |
319 |
useNearestColor ifTrue:[ |
|
320 |
lastColor := lastColor nearestOn:device |
|
321 |
]. |
|
322 |
self paint:lastColor. |
|
1160 | 323 |
mask notNil ifTrue: |
324 |
[ |
|
325 |
maskColor := false. |
|
326 |
(mask colorAtX:xx y:yy) = Color black ifTrue: |
|
327 |
[ |
|
328 |
self paint: (lastColor := self viewBackground). |
|
329 |
maskColor := true. |
|
330 |
]. |
|
331 |
lastColor := nil. |
|
332 |
]. |
|
333 |
runW := 0. |
|
334 |
x0 := xx. |
|
335 |
]. |
|
336 |
runW := runW + magX |
|
627 | 337 |
]. |
338 |
runW ~~ 0 ifTrue: |
|
339 |
[ |
|
1160 | 340 |
|origin| |
341 |
origin := (x0 * magX + margin)@(lastY * magY + margin). |
|
342 |
self fillFramedRectangle: (origin extent: runW@magY). |
|
343 |
maskColor ifTrue: |
|
344 |
[ |
|
345 |
self xoring: [self fillRectangle: (origin + sizeOfMaskPoint extent: sizeOfMaskPoint)] |
|
346 |
]. |
|
347 |
runW := 0. |
|
627 | 348 |
]. |
1037 | 349 |
|
1180 | 350 |
"Modified: / 8.1.1999 / 22:30:50 / cg" |
627 | 351 |
! |
352 |
||
353 |
redrawX:x y:y width:w height:h |
|
636 | 354 |
|
627 | 355 |
|ih iw xI yI| |
356 |
||
1037 | 357 |
image isNil ifTrue:[^self]. |
662 | 358 |
|
1037 | 359 |
magnification = (1@1) ifTrue: [ |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
360 |
^ super redrawX:x y:y width:w height:h |
1037 | 361 |
]. |
627 | 362 |
|
662 | 363 |
self clippingRectangle: (x@y extent: w@h). |
627 | 364 |
|
365 |
self redrawImageX:x y:y width:w height:h. |
|
366 |
||
367 |
"/ right of image ? |
|
368 |
adjust == #center ifTrue: |
|
369 |
[ |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
370 |
xI := (width - ih) // 2 - margin. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
371 |
yI := (height - iw) // 2 - margin. |
627 | 372 |
] |
373 |
ifFalse: |
|
374 |
[ |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
375 |
xI := yI := margin |
627 | 376 |
]. |
377 |
(x + w - 1) > (xI + (magnification x * image width)) ifTrue: |
|
378 |
[ |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
379 |
self clearRectangleX:(xI + (magnification x * image width)) |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
380 |
y:y |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
381 |
width:(x + w - (magnification x * image width) - xI) |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
382 |
height:h |
627 | 383 |
]. |
384 |
(y + h - 1) > (yI + (magnification y * image height)) ifTrue: |
|
385 |
[ |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
386 |
self clearRectangleX:margin |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
387 |
y:(yI + (magnification y * image height)) |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
388 |
width:w |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
389 |
height:(y + h - (magnification y * image height) - yI) |
627 | 390 |
]. |
391 |
self drawFrame. |
|
392 |
self clippingRectangle: nil. |
|
1037 | 393 |
|
394 |
"Modified: / 31.7.1998 / 02:22:45 / cg" |
|
627 | 395 |
! ! |
396 |
||
397 |
!ImageEditView methodsFor:'edit modes'! |
|
398 |
||
399 |
editMode |
|
400 |
||
1106 | 401 |
^editMode |
627 | 402 |
! |
403 |
||
1106 | 404 |
editMode: anEditMode |
627 | 405 |
|
1106 | 406 |
editMode := anEditMode |
627 | 407 |
! |
408 |
||
409 |
mouseKeyColorMode |
|
410 |
||
411 |
^mouseKeyColorMode printString |
|
412 |
! |
|
413 |
||
414 |
mouseKeyColorMode:aMode |
|
415 |
||
1106 | 416 |
mouseKeyColorMode := aMode |
627 | 417 |
! ! |
418 |
||
419 |
!ImageEditView methodsFor:'event handling'! |
|
420 |
||
421 |
buttonMotion:state x:x y:y |
|
1246 | 422 |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
423 |
state ~~ 0 ifTrue: [ |
1245 | 424 |
("self selectedColor notNil" true |
425 |
and: [(self imageContainsPoint: x@y) |
|
1246 | 426 |
and: [editMode == #point]]) |
427 |
ifTrue: [ |
|
428 |
self pointAt: x@y. |
|
429 |
^ self |
|
430 |
]. |
|
431 |
self drawCursorAt: x@y. |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
432 |
] ifFalse:[ |
1246 | 433 |
self drawCursorAt: x@y. |
434 |
(editMode == #paste or:[editMode == #pasteUnder]) ifTrue: [ |
|
1245 | 435 |
("self selectedColor notNil" true and: [self imageContainsPastePoint: x@y]) |
436 |
ifTrue: [self drawPasteRectangleAt: x@y] |
|
437 |
ifFalse: [self cursor:Cursor stop. self releasePasteDrawing] |
|
438 |
] |
|
686 | 439 |
] |
1019
e68414752bc9
only change the cursor for myself.
Claus Gittinger <cg@exept.de>
parents:
1013
diff
changeset
|
440 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
441 |
"Modified: / 5.9.1998 / 13:28:15 / cg" |
624 | 442 |
! |
255 | 443 |
|
627 | 444 |
buttonPress:button x:x y:y |
1246 | 445 |
|mouseButtonColorToolBar clr| |
627 | 446 |
|
632 | 447 |
self drawCursorAt: x@y. |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
448 |
|
1246 | 449 |
("self selectedColor notNil" true |
450 |
and: [self imageContainsPoint: x@y]) |
|
451 |
ifTrue:[ |
|
452 |
self sensor shiftDown ifTrue:[ |
|
453 |
pickedColorHolder notNil ifTrue:[ |
|
454 |
"/ select the color under the cursor, place it into the |
|
455 |
"/ pickedColorHolder/ |
|
456 |
clr := image colorAt:((x@y)//magnification). |
|
457 |
pickedColorHolder value:clr |
|
458 |
]. |
|
459 |
] ifFalse:[ |
|
460 |
"/ cg: what a kludge - please change to use a valueHolder, |
|
461 |
"/ which gets the information ... |
|
462 |
mouseKeyColorMode := button. |
|
463 |
mouseButtonColorToolBar := masterApplication builder componentAt: #MouseButtonColorToolBar. |
|
464 |
self makeUndo. |
|
465 |
masterApplication valueOfCanUndo value: true. |
|
466 |
(mouseButtonColorToolBar itemAt: mouseKeyColorMode) toggleIndication. |
|
467 |
mouseButtonColorToolBar do: [:i| i updateIndicators]. |
|
468 |
||
469 |
"/ editMode is something like #point, #rectangle etc. |
|
470 |
self perform: (editMode, 'At:') asSymbol with: x@y |
|
471 |
] |
|
686 | 472 |
] |
995 | 473 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
474 |
"Modified: / 5.9.1998 / 13:28:02 / cg" |
632 | 475 |
! |
476 |
||
994
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
477 |
buttonRelease:button x:x y:y |
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
478 |
|
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
479 |
self drawCursorAt: x@y. |
1246 | 480 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
481 |
("self selectedColor notNil" true and: [self imageContainsPoint: x@y]) |
1246 | 482 |
ifTrue: [ |
483 |
image restored. |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
484 |
|
1246 | 485 |
"/ cg: what a kludge - please change to use a valueHolder, |
486 |
"/ which gets the information ... |
|
487 |
masterApplication imagePreView invalidate |
|
994
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
488 |
] |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
489 |
|
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
490 |
"Modified: / 5.9.1998 / 13:20:12 / cg" |
994
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
491 |
! |
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
492 |
|
686 | 493 |
pointerLeave:state |
494 |
||
688 | 495 |
super pointerLeave: state. |
686 | 496 |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
497 |
self updateImageInfo: self imageInfoString. |
1019
e68414752bc9
only change the cursor for myself.
Claus Gittinger <cg@exept.de>
parents:
1013
diff
changeset
|
498 |
self cursor:Cursor normal. |
995 | 499 |
|
1246 | 500 |
(editMode == #paste or:[editMode == #pasteUnder]) ifTrue: [ |
501 |
self releasePasteDrawing |
|
502 |
] |
|
995 | 503 |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
504 |
"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
|
505 |
! ! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
506 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
507 |
!ImageEditView methodsFor:'image - dragging & info'! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
508 |
|
1084
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
509 |
dragRectangleStartingAt: aPoint emphasis: emphasis |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
510 |
"drag a rectangle (filled or unfilled)" |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
511 |
|
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
512 |
|currentPoint currentExtent firstPoint lastCurrentPoint gridCorrection |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
513 |
mp lastMp p whichQuarter scrollX scrollY| |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
514 |
|
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
515 |
firstPoint := currentPoint := lastCurrentPoint := aPoint//magnification*magnification. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
516 |
magnification >= GridMagnification ifFalse: [gridCorrection := 0] ifTrue: [gridCorrection := 1]. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
517 |
|
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
518 |
[device anyButtonPressed] whileTrue: [ |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
519 |
mp := self sensor mousePoint. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
520 |
mp = lastMp ifTrue:[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
521 |
Delay waitForSeconds:0.05 |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
522 |
] ifFalse:[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
523 |
lastMp := mp. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
524 |
mp := device translatePoint:mp from:device rootView id to:self id. |
1084
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
525 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
526 |
scrollX := 0. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
527 |
mp x > width ifTrue:[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
528 |
scrollX := mp x - width. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
529 |
] ifFalse:[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
530 |
mp x < 0 ifTrue:[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
531 |
scrollX := mp x. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
532 |
] |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
533 |
]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
534 |
scrollY := 0. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
535 |
mp y > height ifTrue:[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
536 |
scrollY := mp y - height. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
537 |
] ifFalse:[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
538 |
mp y < 0 ifTrue:[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
539 |
scrollY := mp y. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
540 |
] |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
541 |
]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
542 |
(scrollX + scrollY) ~~ 0 ifTrue:[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
543 |
self scrollTo:(self viewOrigin + (scrollX @ scrollY)). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
544 |
lastMp := nil. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
545 |
]. |
1084
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
546 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
547 |
currentPoint := (0@0) max: (image extent * magnification min: (p := self translation negated + mp)). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
548 |
currentPoint := currentPoint//magnification*magnification. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
549 |
currentExtent := (firstPoint - currentPoint) abs. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
550 |
whichQuarter := (firstPoint x - currentPoint x) > 0 |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
551 |
ifTrue: [(firstPoint y - currentPoint y) > 0 ifTrue: ["4"1@1] ifFalse: ["3"1@0]] |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
552 |
ifFalse: [(firstPoint y - currentPoint y) > 0 ifTrue: ["1"0@1] ifFalse: ["2"0@0]]. |
1084
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
553 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
554 |
self drawCursorAt: p withLabel: |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
555 |
((firstPoint//magnification - whichQuarter + 1) printString, |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
556 |
' to: ', |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
557 |
(currentPoint//magnification + whichQuarter) printString), |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
558 |
' (extent: ', |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
559 |
(currentExtent//magnification) printString, ')'. |
1084
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
560 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
561 |
currentPoint ~= lastCurrentPoint ifTrue: |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
562 |
[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
563 |
emphasis = #inverseFilledBox |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
564 |
ifTrue: |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
565 |
[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
566 |
self redraw: ((firstPoint min: lastCurrentPoint) - 1 extent: (firstPoint - lastCurrentPoint) abs + 2). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
567 |
self xoring: [self fillRectangle: ((firstPoint min: currentPoint) + margin extent: currentExtent - gridCorrection)] |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
568 |
]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
569 |
emphasis = #box |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
570 |
ifTrue: |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
571 |
[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
572 |
|origin extent lineWidthY lineWidthX| |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
573 |
origin := (firstPoint min: lastCurrentPoint) - 1. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
574 |
extent := (firstPoint - lastCurrentPoint) abs + 2. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
575 |
lineWidthY := extent y min: (magnification y + 2). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
576 |
lineWidthX := extent x min: (magnification x + 2). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
577 |
self redraw: (origin extent: (extent x@lineWidthY)). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
578 |
self redraw: ((origin x@(origin y + extent y - lineWidthY)) extent: (extent x@lineWidthY)). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
579 |
self redraw: ((origin x@(origin y + lineWidthY)) extent: (lineWidthX@(0 max: (extent y - (lineWidthY * 2))))). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
580 |
self redraw: (((origin x + extent x - lineWidthX)@(origin y + lineWidthY)) extent: (lineWidthX@(extent y - (lineWidthY * 2)))). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
581 |
self selectedColor ~= Color noColor |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
582 |
ifTrue: [self paint: self selectedColor] |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
583 |
ifFalse: [self paint: self viewBackground]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
584 |
origin := (firstPoint min: currentPoint) + margin. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
585 |
extent := currentExtent - gridCorrection. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
586 |
lineWidthY := extent y min: magnification y. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
587 |
lineWidthX := extent x min: magnification x. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
588 |
(lineWidthY > 0 and: [lineWidthX > 0]) |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
589 |
ifTrue: |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
590 |
[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
591 |
self fillRectangle: (origin extent: (extent x@lineWidthY)). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
592 |
self fillRectangle: ((origin x@(origin y + extent y - lineWidthY)) extent: (extent x@lineWidthY)). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
593 |
self fillRectangle: ((origin x@(origin y + lineWidthY)) extent: (lineWidthX@(0 max: (extent y - (lineWidthY * 2))))). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
594 |
self fillRectangle: (((origin x + extent x - lineWidthX)@(origin y + lineWidthY)) extent: (lineWidthX@(extent y - (lineWidthY * 2)))). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
595 |
] |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
596 |
]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
597 |
emphasis = #filledBox |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
598 |
ifTrue: |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
599 |
[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
600 |
self redraw: ((firstPoint min: lastCurrentPoint) - 1 extent: (firstPoint - lastCurrentPoint) abs + 2). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
601 |
self selectedColor ~= Color noColor |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
602 |
ifTrue: [self paint: self selectedColor] |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
603 |
ifFalse: [self paint: self viewBackground]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
604 |
self fillRectangle: ((firstPoint min: currentPoint) + margin extent: currentExtent - gridCorrection). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
605 |
]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
606 |
]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
607 |
lastCurrentPoint := currentPoint. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
608 |
]. |
1084
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
609 |
]. |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
610 |
|
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
611 |
^((0@0) max: (firstPoint min: currentPoint)) extent: (firstPoint - currentPoint) abs |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
612 |
|
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
613 |
"Created: / 21.8.1998 / 20:17:07 / cg" |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
614 |
"Modified: / 21.8.1998 / 20:34:42 / cg" |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
615 |
! |
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
616 |
|
1245 | 617 |
drawCursorAt:aPoint |
618 |
|clr imgPoint| |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
619 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
620 |
image isNil ifTrue: [ |
1245 | 621 |
self updateImageInfo: self imageInfoString. |
622 |
self cursor:Cursor stop. |
|
623 |
^ self |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
624 |
]. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
625 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
626 |
(aPoint x < (image width * magnification) |
1060 | 627 |
and:[aPoint y < (image height * magnification) |
628 |
and:[aPoint x >= 0 |
|
629 |
and:[aPoint y >= 0]]]) |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
630 |
ifFalse:[ |
1245 | 631 |
self updateImageInfo: self imageInfoString. |
632 |
self cursor:Cursor stop. |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
633 |
] ifTrue: [ |
1245 | 634 |
imgPoint := aPoint // magnification. |
635 |
clr := image colorAt:imgPoint. |
|
636 |
self updateImageInfo: imgPoint printString |
|
637 |
, ' (r:' |
|
638 |
, clr redByte printString |
|
639 |
, ' g:' , clr greenByte printString |
|
640 |
, ' b:' , clr blueByte printString |
|
641 |
, ' pixel:' , (image pixelAt:imgPoint) printString |
|
642 |
, ')'. |
|
643 |
self cursor:Cursor crossHair |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
644 |
]. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
645 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
646 |
"Modified: / 29.7.1998 / 18:26:01 / cg" |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
647 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
648 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
649 |
drawCursorAt: aPoint withLabel: aLabel |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
650 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
651 |
((0@0 extent: image extent * magnification) containsPoint: aPoint) |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
652 |
ifFalse:[self cursor:Cursor stop] |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
653 |
ifTrue: [self cursor:Cursor crossHair]. |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
654 |
self updateImageInfo: aLabel. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
655 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
656 |
"Modified: / 29.7.1998 / 18:26:04 / cg" |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
657 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
658 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
659 |
updateActivity: something |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
660 |
|msg| |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
661 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
662 |
msg := something printString. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
663 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
664 |
"/ cg: new code: |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
665 |
activityInfoHolder notNil ifTrue:[ |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
666 |
activityInfoHolder value:msg. |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
667 |
]. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
668 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
669 |
"Modified: / 29.7.1998 / 18:41:47 / cg" |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
670 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
671 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
672 |
updateImageInfo: something |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
673 |
|msg coordLabel| |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
674 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
675 |
msg := something printString. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
676 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
677 |
"/ cg: new code: |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
678 |
imageInfoHolder notNil ifTrue:[ |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
679 |
msg ~= imageInfoHolder value ifTrue:[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
680 |
imageInfoHolder value:msg. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
681 |
]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
682 |
^ self |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
683 |
]. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
684 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
685 |
"/ "/ cg: what a kludge - please change to use a valueHolder, |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
686 |
"/ "/ which gets the coordinate ... |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
687 |
"/ |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
688 |
"/ (masterApplication respondsTo: #coordLabel) |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
689 |
"/ ifTrue:[ |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
690 |
"/ coordLabel := masterApplication coordLabel. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
691 |
"/ |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
692 |
"/ coordLabel label ~= msg |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
693 |
"/ ifTrue:[ |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
694 |
"/ coordLabel label: msg. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
695 |
"/ "/ coordLabel redraw |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
696 |
"/ ] |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
697 |
"/ ] |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
698 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
699 |
"Modified: / 29.7.1998 / 19:00:21 / cg" |
627 | 700 |
! ! |
701 |
||
636 | 702 |
!ImageEditView methodsFor:'image editing'! |
627 | 703 |
|
704 |
boxAt: aPoint |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
705 |
"draw a rectangular outline with the currently selected color" |
627 | 706 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
707 |
|choosedBox imageBox clr| |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
708 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
709 |
(clr := self selectedColor) notNil ifTrue:[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
710 |
choosedBox := self dragRectangleStartingAt: aPoint emphasis: #box. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
711 |
imageBox := choosedBox origin//magnification extent: (choosedBox extent//magnification). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
712 |
image rectangle:imageBox withColor:clr. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
713 |
image restored. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
714 |
self redraw: (choosedBox expandedBy: 1). |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
715 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
716 |
"/ cg: what a kludge - please change to use a valueHolder, |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
717 |
"/ which gets the information ... |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
718 |
masterApplication imagePreView redraw: (imageBox expandedBy: 1). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
719 |
modified := true |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
720 |
]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
721 |
|
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
722 |
"Modified: / 5.9.1998 / 13:29:55 / cg" |
632 | 723 |
! |
724 |
||
1002 | 725 |
changeGridMagnification |
726 |
||
727 |
|box newGridMagnification| |
|
728 |
box := EnterBox new. |
|
729 |
box title:'Grid Magnification:'. |
|
730 |
box okText:'OK'. |
|
731 |
box abortText:'Cancel'. |
|
732 |
box initialText:GridMagnification x printString. |
|
733 |
box showAtPointer. |
|
734 |
(box accepted and: [(newGridMagnification := Number readFromString: box contents onError:[2]) notNil]) |
|
735 |
ifTrue: |
|
736 |
[ |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
737 |
GridMagnification := (99 min: (2 max: newGridMagnification)) asPoint. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
738 |
self invalidate |
1002 | 739 |
] |
740 |
! |
|
741 |
||
632 | 742 |
copyAt: aPoint |
743 |
||
744 |
|choosedBox| |
|
1084
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
745 |
|
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
746 |
choosedBox := self dragRectangleStartingAt: aPoint emphasis: #inverseFilledBox. |
995 | 747 |
ClipboardMagnification := nil. |
632 | 748 |
Clipboard := image subImageIn: (choosedBox origin//magnification extent: (choosedBox extent//magnification)). |
1084
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
749 |
self redraw: (choosedBox expandedBy: 1) |
632 | 750 |
|
1084
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
751 |
"Modified: / 21.8.1998 / 20:16:41 / cg" |
632 | 752 |
! |
753 |
||
1228 | 754 |
cropLeft:doLeft right:doRight top:doTop bottom:doBottom |
1121 | 755 |
|yMinNew yMaxNew xMinNew xMaxNew |
756 |
pix stillCrobbing xMax yMax x y| |
|
757 |
||
758 |
xMax := image width - 1. |
|
759 |
yMax := image height - 1. |
|
760 |
||
761 |
xMinNew := 0. |
|
762 |
doLeft ifTrue:[ |
|
763 |
pix := image pixelAtX:xMinNew y:0. |
|
764 |
stillCrobbing := true. |
|
765 |
[stillCrobbing] whileTrue:[ |
|
766 |
0 to:yMax do:[:y | |
|
767 |
(image pixelAtX:xMinNew y:y) ~~ pix ifTrue:[ |
|
768 |
stillCrobbing := false |
|
769 |
] |
|
770 |
]. |
|
771 |
stillCrobbing ifTrue:[ |
|
772 |
xMinNew := xMinNew + 1. |
|
773 |
xMinNew >= image width ifTrue:[ |
|
774 |
self warn:'Image is all the same color - no crob.'. |
|
775 |
^ self |
|
776 |
] |
|
777 |
]. |
|
778 |
]. |
|
779 |
]. |
|
780 |
||
781 |
xMaxNew := xMax. |
|
782 |
doRight ifTrue:[ |
|
783 |
stillCrobbing := true. |
|
784 |
pix := image pixelAtX:xMaxNew y:0. |
|
785 |
[stillCrobbing] whileTrue:[ |
|
786 |
0 to:yMax do:[:y | |
|
787 |
(image pixelAtX:xMaxNew y:y) ~~ pix ifTrue:[ |
|
788 |
stillCrobbing := false |
|
789 |
] |
|
790 |
]. |
|
791 |
stillCrobbing ifTrue:[ |
|
792 |
xMaxNew := xMaxNew - 1. |
|
793 |
]. |
|
794 |
]. |
|
795 |
]. |
|
796 |
||
797 |
yMinNew := 0. |
|
798 |
doTop ifTrue:[ |
|
799 |
pix := image pixelAtX:xMinNew y:yMinNew. |
|
800 |
stillCrobbing := true. |
|
801 |
[stillCrobbing] whileTrue:[ |
|
802 |
xMinNew to:xMaxNew do:[:x | |
|
803 |
(image pixelAtX:x y:yMinNew) ~~ pix ifTrue:[ |
|
804 |
stillCrobbing := false |
|
805 |
] |
|
806 |
]. |
|
807 |
stillCrobbing ifTrue:[ |
|
808 |
yMinNew := yMinNew + 1. |
|
809 |
]. |
|
810 |
]. |
|
811 |
]. |
|
812 |
||
813 |
yMaxNew := yMax. |
|
814 |
doRight ifTrue:[ |
|
815 |
stillCrobbing := true. |
|
816 |
pix := image pixelAtX:xMaxNew y:yMaxNew. |
|
817 |
[stillCrobbing] whileTrue:[ |
|
818 |
xMinNew to:xMaxNew do:[:x | |
|
819 |
(image pixelAtX:x y:yMaxNew) ~~ pix ifTrue:[ |
|
820 |
stillCrobbing := false |
|
821 |
] |
|
822 |
]. |
|
823 |
stillCrobbing ifTrue:[ |
|
824 |
yMaxNew := yMaxNew - 1. |
|
825 |
]. |
|
826 |
]. |
|
827 |
]. |
|
828 |
||
829 |
(xMinNew == 0 |
|
830 |
and:[xMaxNew == (image width - 1) |
|
831 |
and:[yMinNew == 0 |
|
832 |
and:[yMaxNew == (image height - 1)]]]) ifTrue:[ |
|
833 |
self warn:'No border found - no crob.'. |
|
834 |
^ self |
|
835 |
]. |
|
836 |
||
837 |
"/ self warn:'extract subImage ' |
|
838 |
"/ , (xMinNew @ yMinNew) printString |
|
839 |
"/ , ' -> ' |
|
840 |
"/ , (xMaxNew @ yMaxNew) printString. |
|
841 |
||
842 |
self |
|
843 |
makeSubImageX:xMinNew y:yMinNew |
|
844 |
width:(xMaxNew - xMinNew + 1) |
|
845 |
height:(yMaxNew - yMinNew + 1) |
|
846 |
||
847 |
"Created: / 7.9.1998 / 14:25:52 / cg" |
|
848 |
"Modified: / 7.9.1998 / 16:35:35 / cg" |
|
849 |
! |
|
850 |
||
1035 | 851 |
drawPasteRectangleAt: aPoint |
852 |
||
853 |
|currentPoint gridCorrection extent| |
|
854 |
||
855 |
magnification >= GridMagnification ifFalse: [gridCorrection := 0] ifTrue: [gridCorrection := 1]. |
|
856 |
currentPoint := aPoint//magnification*magnification + margin. |
|
857 |
||
858 |
currentPoint ~= lastPastePoint |
|
859 |
ifTrue: |
|
860 |
[ |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
861 |
ClipboardMagnification isNil ifTrue: [ClipboardMagnification := (Clipboard magnifiedBy: magnification) onDevice: device]. |
1035 | 862 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
863 |
extent := ClipboardMagnification extent. |
1035 | 864 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
865 |
currentPoint := currentPoint - self viewOrigin. |
1035 | 866 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
867 |
self redraw: ((lastPastePoint ? currentPoint) extent: extent). |
1035 | 868 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
869 |
(extent x > 200 or: [extent y > 200]) |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
870 |
ifTrue: |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
871 |
[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
872 |
self xoring: [self fillRectangle: (currentPoint extent: extent)] |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
873 |
] |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
874 |
ifFalse: |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
875 |
[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
876 |
self displayDeviceForm: ClipboardMagnification x: currentPoint x y: currentPoint y |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
877 |
] |
1035 | 878 |
]. |
879 |
lastPastePoint := currentPoint. |
|
880 |
||
881 |
"Modified: / 29.7.1998 / 02:18:11 / cg" |
|
882 |
! |
|
883 |
||
632 | 884 |
fillAt: aPoint |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
885 |
"perform a flood-fill with the currently selected color" |
627 | 886 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
887 |
windowGroup withExecuteCursorDo:[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
888 |
|filledPoints clr| |
1002 | 889 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
890 |
(clr := self selectedColor) notNil ifTrue:[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
891 |
self updateActivity:'Flood filling - press CTRL-y to abort ...'. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
892 |
[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
893 |
filledPoints := image floodFillAt: aPoint//magnification withColor:clr. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
894 |
image restored. |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
895 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
896 |
"/ animation effect ... |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
897 |
filledPoints size < 300 |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
898 |
ifTrue: [ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
899 |
filledPoints do: [:p| self redraw: ((p * magnification extent: magnification) expandedBy: 1)] |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
900 |
] ifFalse: [ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
901 |
self invalidate |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
902 |
]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
903 |
"/ cg: what a kludge - please change to use a valueHolder, |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
904 |
"/ which gets the information ... |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
905 |
masterApplication imagePreView invalidate. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
906 |
modified := true |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
907 |
] valueOnUnwindDo:[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
908 |
self updateActivity:'Flood fill aborted.' |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
909 |
]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
910 |
]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
911 |
self updateActivity:'' |
632 | 912 |
] |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
913 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
914 |
"Modified: / 5.9.1998 / 13:28:24 / cg" |
632 | 915 |
! |
916 |
||
917 |
filledBoxAt: aPoint |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
918 |
"fill a rectangular area with the currently selected color" |
632 | 919 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
920 |
|choosedBox imageBox clr| |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
921 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
922 |
(clr := self selectedColor) notNil ifTrue:[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
923 |
choosedBox := self dragRectangleStartingAt: aPoint emphasis: #filledBox. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
924 |
imageBox := choosedBox origin//magnification extent: (choosedBox extent//magnification). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
925 |
image fillRectangle:imageBox withColor:clr. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
926 |
image restored. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
927 |
self redraw: (choosedBox expandedBy: 1). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
928 |
"/ cg: what a kludge - please change to use a valueHolder, |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
929 |
"/ which gets the information ... |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
930 |
masterApplication imagePreView redraw: (imageBox expandedBy: 1). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
931 |
modified := true |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
932 |
] |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
933 |
|
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
934 |
"Modified: / 5.9.1998 / 13:25:44 / cg" |
632 | 935 |
! |
936 |
||
636 | 937 |
flipHorizontal |
938 |
||
995 | 939 |
self makeUndo. |
725 | 940 |
self image: image copy flipHorizontal |
636 | 941 |
|
942 |
! |
|
943 |
||
944 |
flipVertical |
|
945 |
||
995 | 946 |
self makeUndo. |
725 | 947 |
self image: image copy flipVertical |
636 | 948 |
|
949 |
! |
|
950 |
||
951 |
magnifyImage |
|
952 |
||
953 |
|box newSize| |
|
954 |
box := EnterBox new. |
|
955 |
box title:'Image new size:'. |
|
956 |
box okText:'OK'. |
|
957 |
box abortText:'Cancel'. |
|
958 |
box initialText:image extent printString. |
|
959 |
box showAtPointer. |
|
960 |
(box accepted and: [(newSize := Object readFromString: box contents onError:nil) notNil]) |
|
961 |
ifTrue: |
|
962 |
[ |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
963 |
self makeUndo. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
964 |
self image: (image magnifiedBy: newSize/image extent) |
686 | 965 |
] |
636 | 966 |
! |
967 |
||
1121 | 968 |
makeSubImageX:oldX y:oldY width:newWidth height:newHeight |
969 |
|newImage| |
|
970 |
||
971 |
newImage := image class width:newWidth height:newHeight depth:image depth. |
|
972 |
newImage photometric:image photometric. |
|
973 |
newImage colorMap:image colorMap copy. |
|
974 |
newImage bits:(ByteArray new:(newImage bytesPerRow * newHeight)). |
|
975 |
||
976 |
image mask notNil |
|
977 |
ifTrue:[ |
|
978 |
|newMaskImage| |
|
979 |
||
980 |
newMaskImage := Depth1Image width:newWidth height:newHeight. |
|
981 |
newMaskImage photometric: image mask photometric. |
|
982 |
newMaskImage colorMap: image mask colorMap copy. |
|
983 |
newMaskImage bits:(ByteArray new: newMaskImage bytesPerRow * newHeight). |
|
984 |
newImage mask: newMaskImage |
|
985 |
]. |
|
986 |
||
987 |
newImage copyFrom:image x:oldX y:oldY toX:0 y:0 width:newWidth height:newHeight. |
|
988 |
self makeUndo. |
|
989 |
self image: newImage. |
|
990 |
||
991 |
"Created: / 7.9.1998 / 13:00:16 / cg" |
|
992 |
"Modified: / 7.9.1998 / 14:15:32 / cg" |
|
993 |
! |
|
994 |
||
636 | 995 |
negativeImage |
996 |
||
995 | 997 |
self makeUndo. |
725 | 998 |
self image: image copy negative |
636 | 999 |
! |
1000 |
||
1001 |
pasteAt: aPoint |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1002 |
"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
|
1003 |
|
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1004 |
self pasteAt:aPoint modeUnder:false. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1005 |
! |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1006 |
|
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1007 |
pasteAt: aPoint modeUnder:modeUnder |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1008 |
"paste the image in the clipboard at aPoint" |
636 | 1009 |
|
995 | 1010 |
ClipboardMagnification isNil ifTrue: [^self]. |
1011 |
||
636 | 1012 |
Object errorSignal handle: |
1013 |
[:ex| |
|
1246 | 1014 |
ex signal == Image unrepresentableColorSignal ifFalse:[ |
1015 |
ex reject |
|
1016 |
]. |
|
1017 |
self undo. |
|
1018 |
self warn: 'Paste failed !!\Increasing the images depth might help.' withCRs. |
|
636 | 1019 |
] |
1020 |
do: |
|
1021 |
[ |
|
1246 | 1022 |
windowGroup withExecuteCursorDo:[ |
1023 |
|choosedBox imagePoint imgX imgY copiedImage imageBox presentClr newColorMap| |
|
995 | 1024 |
|
1025 |
||
1246 | 1026 |
choosedBox := self dragRectangleStartingAt: aPoint emphasis: #inverseFilledBox. |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1027 |
|
1246 | 1028 |
imagePoint := choosedBox origin//magnification. |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1029 |
|
1246 | 1030 |
copiedImage := Clipboard copy. |
1031 |
image photometric == #palette ifTrue:[ |
|
1032 |
"/ for all colors in the pasted image, |
|
1033 |
"/ check, if its in the colormap of the |
|
1034 |
"/ target image. |
|
995 | 1035 |
|
1246 | 1036 |
copiedImage usedValues do:[:pixel | |
1037 |
|pastedColor oldColorMap| |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1038 |
|
1246 | 1039 |
pastedColor := copiedImage colorFromValue:pixel. |
1040 |
oldColorMap := image colorMap. |
|
1028
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
1041 |
|
1246 | 1042 |
(oldColorMap detect: [:clr| clr = pastedColor] ifNone: nil) isNil |
1043 |
ifTrue: |
|
1044 |
[ |
|
1045 |
oldColorMap size < (1 bitShift:image depth) ifTrue:[ |
|
1046 |
"/ add to colormap |
|
1047 |
newColorMap isNil ifTrue:[ |
|
1048 |
newColorMap := oldColorMap asOrderedCollection. |
|
1049 |
]. |
|
1050 |
newColorMap add:pastedColor. |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1051 |
"/ Transcript showCR:'adding color:' , pastedColor displayString , ' to targets colorMap'. |
1246 | 1052 |
] ifFalse:[ |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1053 |
"/ Transcript showCR:'color:' , pastedColor displayString , ' not found in targets colorMap'. |
1246 | 1054 |
copiedImage colorMap at: pixel+1 put: Color black |
1055 |
] |
|
1056 |
] |
|
1057 |
]. |
|
995 | 1058 |
|
1246 | 1059 |
newColorMap notNil ifTrue:[ |
1060 |
image colorMap:(Colormap fromColors:newColorMap). |
|
1061 |
]. |
|
1062 |
]. |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1063 |
|
1246 | 1064 |
copiedImage := image class fromImage: copiedImage. |
1065 |
(newColorMap isNil and:[modeUnder not]) ifTrue:[ |
|
1066 |
image copyFrom: copiedImage x:0 y:0 toX: imagePoint x y: imagePoint y width: copiedImage width height: copiedImage height. |
|
1067 |
] ifFalse:[ |
|
994
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
1068 |
|
1246 | 1069 |
imgX := imagePoint x. |
1070 |
imgY := imagePoint y. |
|
1028
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
1071 |
|
1246 | 1072 |
0 to:copiedImage height-1 do:[:y | |
1073 |
0 to:copiedImage width-1 do:[:x | |
|
1074 |
|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
|
1075 |
|
1246 | 1076 |
dstX := imgX + x. |
1077 |
dstY := imgY + y. |
|
1078 |
wasMasked := (image maskAtX:dstX y:dstY) == 0. |
|
1079 |
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
|
1080 |
|
1246 | 1081 |
"/ with modeUnder, |
1082 |
"/ only replace, if its either unmasked, |
|
1083 |
"/ or the current drawing color. |
|
1084 |
(modeUnder not |
|
1085 |
or:[wasMasked |
|
1086 |
or:[(oldColor := image colorAtX:dstX y:dstY) = (drawingColors at:1)]]) |
|
1087 |
ifTrue:[ |
|
1088 |
image |
|
1089 |
colorAtX:dstX |
|
1090 |
y:dstY |
|
1091 |
put:(copiedImage colorAtX:x y:y). |
|
1092 |
(wasMasked and:[newMasked not]) ifTrue:[ |
|
1093 |
image mask pixelAtX:dstX y:dstY put:1 |
|
1094 |
]. |
|
1095 |
] |
|
1096 |
] |
|
1097 |
]. |
|
1098 |
]. |
|
1099 |
image restored. |
|
1100 |
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
|
1101 |
"/ masterApplication imagePreView redraw: (imageBox expandedBy: 1). |
1246 | 1102 |
modified := true |
1103 |
] |
|
1028
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
1104 |
] |
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
1105 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1106 |
"Modified: / 5.9.1998 / 13:36:58 / cg" |
636 | 1107 |
! |
1108 |
||
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1109 |
pasteUnderAt: aPoint |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1110 |
"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
|
1111 |
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
|
1112 |
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
|
1113 |
|
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1114 |
self pasteAt:aPoint modeUnder:true. |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1115 |
! |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1116 |
|
636 | 1117 |
pointAt: aPoint |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1118 |
"draw a single pixel with the currently selected color" |
636 | 1119 |
|
1246 | 1120 |
|imagePoint clr pix| |
796 | 1121 |
|
1246 | 1122 |
imagePoint := aPoint // magnification. |
1277 | 1123 |
(clr := self selectedColor) isNil ifTrue:[ |
1124 |
pix := self selectedColorIndex |
|
1246 | 1125 |
]. |
1126 |
pix notNil ifTrue:[ |
|
1277 | 1127 |
image colorMap atImageAndMask:imagePoint putValue:pix. |
1245 | 1128 |
modified := true. |
1277 | 1129 |
] ifFalse:[ |
1130 |
clr notNil ifTrue:[ |
|
1131 |
image atImageAndMask:imagePoint put:clr. |
|
1132 |
modified := true. |
|
1133 |
]. |
|
1246 | 1134 |
]. |
1277 | 1135 |
self invalidate:((imagePoint * magnification extent: magnification) expandedBy: 1). |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1136 |
|
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1137 |
"Modified: / 5.9.1998 / 13:25:29 / cg" |
636 | 1138 |
! |
1139 |
||
1140 |
resizeImage |
|
1141 |
||
1142 |
|box newSize| |
|
1143 |
box := EnterBox new. |
|
1144 |
box title:'Image new size:'. |
|
1145 |
box okText:'OK'. |
|
1146 |
box abortText:'Cancel'. |
|
1147 |
box initialText:image extent printString. |
|
1148 |
box showAtPointer. |
|
1149 |
(box accepted and: [(newSize := Object readFromString: box contents onError:nil) notNil]) |
|
1150 |
ifTrue: |
|
1151 |
[ |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1152 |
|newImage| |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1153 |
newImage := image class width: newSize x height: newSize y depth: image depth. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1154 |
newImage photometric:image photometric. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1155 |
newImage colorMap:image colorMap copy. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1156 |
newImage bits: (ByteArray new: newImage bytesPerRow * newSize y). |
636 | 1157 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1158 |
image mask notNil |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1159 |
ifTrue: |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1160 |
[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1161 |
|newMaskImage| |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1162 |
newMaskImage := Depth1Image width: newSize x height: newSize y. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1163 |
newMaskImage photometric: image mask photometric. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1164 |
newMaskImage colorMap: image mask colorMap copy. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1165 |
newMaskImage bits:(ByteArray new: newMaskImage bytesPerRow * newSize y). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1166 |
newImage mask: newMaskImage |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1167 |
]. |
636 | 1168 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1169 |
newImage copyFrom:image x:0 y:0 toX:0 y:0 width: (image width min:newSize x) height: (image height min:newSize y). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1170 |
self makeUndo. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1171 |
self image: newImage. |
686 | 1172 |
] |
636 | 1173 |
! |
1174 |
||
1175 |
rotateImage |
|
1176 |
||
1177 |
|box rotation| |
|
1178 |
box := EnterBox new. |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1179 |
box title:'Rotate by (degrees, clockwise):'. |
636 | 1180 |
box okText:'OK'. |
1181 |
box abortText:'Cancel'. |
|
1182 |
box initialText: '0'. |
|
1183 |
box showAtPointer. |
|
1184 |
(box accepted and: [(rotation := Object readFromString: box contents onError:nil) notNil]) |
|
1185 |
ifTrue: |
|
1186 |
[ Object errorSignal handle: |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1187 |
[:ex| |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1188 |
self warn: 'Image rotation failed!!\' withCRs, 'Increaing the image depth could help.' |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1189 |
] |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1190 |
do: |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1191 |
[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1192 |
self makeUndo. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1193 |
self image: (image hardRotated: rotation) |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1194 |
] |
686 | 1195 |
] |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1196 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1197 |
"Modified: / 29.7.1998 / 18:21:14 / cg" |
636 | 1198 |
! |
1199 |
||
1200 |
undo |
|
1201 |
||
995 | 1202 |
undoImages notEmpty |
636 | 1203 |
ifTrue: |
725 | 1204 |
[ |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1205 |
windowGroup withExecuteCursorDo:[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1206 |
modified := false. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1207 |
self image: undoImages removeLast. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1208 |
"/ cg: what a kludge - please change to use a valueHolder, |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1209 |
masterApplication notNil ifTrue:[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1210 |
masterApplication listOfColors contents: image colorMap. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1211 |
masterApplication findColorMapMode. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1212 |
undoImages isEmpty ifTrue: [masterApplication valueOfCanUndo value: false]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1213 |
]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1214 |
"/ cg: not needed - image: already does it. |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
1215 |
"/ self invalidate |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1216 |
] |
636 | 1217 |
] |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
1218 |
|
1047 | 1219 |
"Modified: / 31.7.1998 / 20:12:58 / cg" |
627 | 1220 |
! ! |
1221 |
||
1222 |
!ImageEditView methodsFor:'image setting'! |
|
1223 |
||
1224 |
image:anImage |
|
1256 | 1225 |
|retVal fileName| |
627 | 1226 |
|
1256 | 1227 |
anImage isImage ifTrue:[ |
1228 |
(image isNil or: [self checkModified]) ifTrue: [ |
|
1229 |
masterApplication notNil ifTrue: [ |
|
1230 |
undoImages notEmpty ifTrue: [masterApplication valueOfCanUndo value: true]. |
|
1231 |
masterApplication imagePreView image: anImage |
|
1232 |
]. |
|
1233 |
image notNil ifTrue: [ |
|
1234 |
fileName := image fileName. |
|
1235 |
anImage fileName isNil ifTrue: [anImage fileName: fileName]. |
|
1236 |
]. |
|
1237 |
super image: anImage. |
|
1238 |
retVal := self. |
|
1239 |
]. |
|
1240 |
] ifFalse: [ |
|
1241 |
super image: nil. |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1242 |
]. |
1025
4470f3ad349f
update the image label, when a new image is assigned.
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
1243 |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1244 |
self updateImageInfo: self imageInfoString. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1245 |
^ retVal |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1246 |
|
1256 | 1247 |
"Modified: / 16.3.1999 / 21:45:13 / cg" |
627 | 1248 |
! |
1249 |
||
1250 |
loadFromFile: aFileName |
|
624 | 1251 |
|
676 | 1252 |
aFileName isNil ifTrue: [^nil]. |
624 | 1253 |
Object errorSignal handle: |
1254 |
[:exeption| |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1255 |
modified := false. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1256 |
self warn: exeption errorString. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1257 |
^nil |
624 | 1258 |
] |
1259 |
do: |
|
676 | 1260 |
[ |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1261 |
|imageFromFile| |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1262 |
(imageFromFile := Image fromFile: aFileName) notNil |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1263 |
ifTrue: |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1264 |
[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1265 |
self releaseUndos. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1266 |
self image: imageFromFile. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1267 |
imageReaderClass := ImageReader allSubclasses |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1268 |
detect: [:cls| cls isValidImageFile: aFileName] |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1269 |
ifNone: [self error: 'Unknown image file format!!'] |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1270 |
] |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1271 |
ifFalse: |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1272 |
[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1273 |
self error: 'Not an image file (or unrecognized format) !!' |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1274 |
] |
676 | 1275 |
] |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1276 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1277 |
"Modified: / 29.7.1998 / 18:09:13 / cg" |
624 | 1278 |
! |
255 | 1279 |
|
633 | 1280 |
loadFromMessage: aMessage |
1281 |
||
1282 |
(self resourceMessage: aMessage) isNil |
|
1283 |
ifTrue: |
|
1284 |
[ |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1285 |
^nil |
633 | 1286 |
]. |
624 | 1287 |
|
633 | 1288 |
^self loadfromClass: resourceClass andSelector: resourceSelector |
1289 |
||
1290 |
||
1291 |
! |
|
1292 |
||
1293 |
loadfromClass: aClassOrSymbol andSelector: aStringOrSymbol |
|
1294 |
||
678 | 1295 |
|aClass| |
1296 |
||
627 | 1297 |
imageReaderClass := nil. |
1298 |
self resourceClass: aClassOrSymbol. |
|
1299 |
self resourceSelector: aStringOrSymbol. |
|
678 | 1300 |
|
1301 |
((aClass := Smalltalk at: resourceClass) isClass and: |
|
1302 |
[aClass class implements: resourceSelector]) |
|
624 | 1303 |
ifTrue: |
1304 |
[ |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1305 |
self releaseUndos. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1306 |
^self image: (aClass perform: resourceSelector) copy |
674 | 1307 |
] |
1308 |
ifFalse: |
|
1309 |
[ |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1310 |
modified := false. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1311 |
^nil |
674 | 1312 |
] |
1313 |
||
161 | 1314 |
! ! |
1315 |
||
1327 | 1316 |
!ImageEditView methodsFor:'initialize / release'! |
1317 |
||
1318 |
destroy |
|
1319 |
||
1320 |
ClipboardMagnification := Clipboard := nil. |
|
1321 |
LastMagnification := magnification. |
|
1322 |
||
1323 |
super destroy |
|
1324 |
||
1325 |
! |
|
1 | 1326 |
|
161 | 1327 |
initialize |
624 | 1328 |
|
161 | 1329 |
super initialize. |
627 | 1330 |
|
686 | 1331 |
self enableMotionEvents. |
995 | 1332 |
|
1333 |
undoImages := OrderedCollection new: MaxUndos. |
|
1003 | 1334 |
magnification := LastMagnification ? GridMagnification. |
995 | 1335 |
modified := false. |
627 | 1336 |
mouseKeyColorMode := 1. |
995 | 1337 |
resourceClass := resourceSelector := ''. |
1246 | 1338 |
drawingColors := Array with: nil with: nil. "/ left/right mouse colors |
1339 |
drawingPixels := Array with: nil with: nil. "/ left/right mouse colors |
|
1106 | 1340 |
editMode := #point. |
1036 | 1341 |
|
1 | 1342 |
! ! |
1343 |
||
636 | 1344 |
!ImageEditView methodsFor:'printing & storing'! |
1 | 1345 |
|
724 | 1346 |
loadFromClass |
404 | 1347 |
|
676 | 1348 |
^self loadFromMessage: |
1184 | 1349 |
(ResourceSelectionBrowser |
1350 |
request: 'Load Image From Class' |
|
1351 |
onSuperclass: nil |
|
1352 |
andClass: self resourceClass |
|
1353 |
andSelector: self resourceSelector |
|
1354 |
withResourceTypes: #(image fileImage programImage)) |
|
636 | 1355 |
|
477 | 1356 |
|
161 | 1357 |
! |
1358 |
||
995 | 1359 |
makeUndo |
1360 |
||
1361 |
image notNil |
|
1362 |
ifTrue: |
|
1363 |
[ |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1364 |
MaxUndos <= undoImages size |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1365 |
ifTrue: [undoImages contents: (undoImages copyFrom: 2 to: MaxUndos)]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1366 |
undoImages add: image copy |
995 | 1367 |
] |
1368 |
! |
|
1369 |
||
627 | 1370 |
|
624 | 1371 |
|
686 | 1372 |
image notNil |
1373 |
ifTrue: |
|
636 | 1374 |
[ |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1375 |
|stream| |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1376 |
Printer supportsPostscript ifFalse: |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1377 |
[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1378 |
^self warn:'No postscript printer detected!!' |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1379 |
]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1380 |
stream := Printer newNative. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1381 |
stream isNil ifTrue: |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1382 |
[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1383 |
^self warn:'Cannot open printer stream!!' |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1384 |
]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1385 |
self withWaitCursorDo: |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1386 |
[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1387 |
|psgc| |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1388 |
psgc := PSGraphicsContext on:stream. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1389 |
psgc displayForm: (image magnifiedBy: magnification) x:0 y:0. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1390 |
psgc close |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1391 |
] |
398
7b7255a4db0d
show a wait cursor while printing
Claus Gittinger <cg@exept.de>
parents:
362
diff
changeset
|
1392 |
] |
624 | 1393 |
! |
1394 |
||
1395 |
save |
|
1396 |
||
632 | 1397 |
self saveImageOrMask: #image. |
1398 |
||
624 | 1399 |
! |
1400 |
||
297 | 1401 |
saveAs |
1402 |
||
627 | 1403 |
self saveImageFileAs |
297 | 1404 |
! |
1405 |
||
627 | 1406 |
saveImageFileAs |
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1407 |
"ask for a fileName and save the image" |
627 | 1408 |
|
633 | 1409 |
self saveImageFileAs: |
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1410 |
(FileSelectionBrowser |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1411 |
request: 'Save Image To File' |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1412 |
fileName: self image fileName |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1413 |
withFileFilters: FileSelectionBrowser saveImageFileNameFilters) |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1414 |
|
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1415 |
"Modified: / 30.9.1998 / 23:05:19 / cg" |
627 | 1416 |
! |
297 | 1417 |
|
627 | 1418 |
saveImageFileAs: aFileName |
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1419 |
"save the image in aFileName" |
297 | 1420 |
|
633 | 1421 |
aFileName isNil ifTrue: [^nil]. |
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1422 |
image notNil ifTrue:[ |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1423 |
image fileName: aFileName. |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1424 |
self saveImageOrMask: #image |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1425 |
] ifFalse:[ |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1426 |
self warn: 'No image or file name for saving detected!!' |
632 | 1427 |
] |
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1428 |
|
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1429 |
"Modified: / 30.9.1998 / 23:04:55 / cg" |
632 | 1430 |
! |
1431 |
||
1432 |
saveImageMaskFileAs |
|
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1433 |
"ask for a fileName and save the mask only" |
632 | 1434 |
|
633 | 1435 |
self saveImageMaskFileAs: |
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1436 |
(FileSelectionBrowser |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1437 |
request: 'Save Image Mask To File' |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1438 |
fileName: self image fileName |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1439 |
withFileFilters: FileSelectionBrowser saveImageFileNameFilters) |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1440 |
|
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1441 |
"Modified: / 30.9.1998 / 23:04:11 / cg" |
632 | 1442 |
! |
1443 |
||
1444 |
saveImageMaskFileAs: aFileName |
|
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1445 |
"save the mask only in aFileName" |
632 | 1446 |
|
633 | 1447 |
aFileName isNil ifTrue: [^nil]. |
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1448 |
(image notNil and:[image mask notNil]) ifTrue:[ |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1449 |
image mask fileName:aFileName. |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1450 |
self saveImageOrMask: #mask |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1451 |
] ifFalse:[ |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1452 |
self warn: 'No image or image mask detected!!' |
627 | 1453 |
] |
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1454 |
|
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1455 |
"Modified: / 30.9.1998 / 23:06:24 / cg" |
628 | 1456 |
! |
1457 |
||
632 | 1458 |
saveImageOrMask: what |
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1459 |
"save the image or the mask only (if what == #mask)" |
628 | 1460 |
|
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1461 |
Object errorSignal handle:[:ex| |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1462 |
self warn: ex errorString. |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1463 |
] do:[ |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1464 |
Image informationLostQuerySignal handle:[:ex| |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1465 |
"/ should make those warnings visible ... |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1466 |
(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
|
1467 |
ex proceed. |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1468 |
] |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1469 |
] do:[ |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1470 |
windowGroup withCursor:Cursor write do:[ |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1471 |
|fileName suff| |
1027
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1472 |
|
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1473 |
image isNil ifTrue:[ |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1474 |
^ self error: 'No image to save!!' |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1475 |
]. |
632 | 1476 |
|
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1477 |
what = #image ifTrue:[ |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1478 |
(fileName := image fileName) isNil ifTrue: [^self error: 'No file name for image detected!!']. |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1479 |
]. |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1480 |
what = #mask ifTrue:[ |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1481 |
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
|
1482 |
(fileName := image mask fileName) isNil ifTrue: [^self error: 'No file name for image mask detected!!']. |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1483 |
]. |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1484 |
fileName := fileName asFilename. |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1485 |
|
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1486 |
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
|
1487 |
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
|
1488 |
imageReaderClass := nil. |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1489 |
imageReaderClass := MIMETypes imageReaderForSuffix:suff. |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1490 |
"/ (suff = 'tiff' or:[suff = 'tif']) ifTrue: [ |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1491 |
"/ imageReaderClass := TIFFReader |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1492 |
"/ ] ifFalse:[ |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1493 |
"/ suff = 'xpm' ifTrue: [ |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1494 |
"/ imageReaderClass := XPMReader |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1495 |
"/ ] ifFalse:[ |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1496 |
"/ suff = 'xbm' ifTrue: [ |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1497 |
"/ imageReaderClass := XBMReader |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1498 |
"/ ] ifFalse:[ |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1499 |
"/ suff = 'gif' ifTrue: [ |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1500 |
"/ imageReaderClass := GIFReader |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1501 |
"/ ] ifFalse:[ |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1502 |
"/ (suff = 'jpg' or:[suff = 'jpeg']) ifTrue: [ |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1503 |
"/ imageReaderClass := JPEGReader |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1504 |
"/ ]. |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1505 |
"/ ] |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1506 |
"/ ] |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1507 |
"/ ] |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1508 |
"/ ]. |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1509 |
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
|
1510 |
imageReaderClass := XPMReader. |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1511 |
image fileName:(image fileName, '.xpm'). |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1512 |
Dialog warn:(('Dont know how to write ''.' , suff , '''-files\\Saving in xpm format as ''%1''.') |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1513 |
withCRs bindWith:image fileName asText allBold). |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1514 |
]. |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1515 |
(imageReaderClass canRepresent:image) ifFalse:[ |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1516 |
imageReaderClass := XPMReader. |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1517 |
image fileName:(image fileName, '.xpm'). |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1518 |
Dialog warn:(('Saving in ''.' , suff , '''-format is not supported\\Saving in xpm format as ''%1''.') |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1519 |
withCRs bindWith:image fileName asText allBold). |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1520 |
]. |
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1521 |
what = #image ifTrue: [image saveOn: image fileName using: imageReaderClass. modified := false]. |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1522 |
what = #mask ifTrue: [image mask saveOn: image mask fileName using: imageReaderClass]. |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1523 |
] |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1524 |
] |
1027
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1525 |
] |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1526 |
|
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1527 |
"Modified: / 30.9.1998 / 23:19:39 / cg" |
633 | 1528 |
! |
1529 |
||
1530 |
saveMethod |
|
1531 |
||
1532 |
Object errorSignal handle: |
|
1533 |
[:ex| |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1534 |
self warn: ex errorString. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1535 |
^nil |
633 | 1536 |
] |
1537 |
do: |
|
1538 |
[ |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1539 |
|category imageStoreStream cls sel mthd imageKey| |
822
cace81f0a86b
do not overwrite method categories + toggle between mouse button colors
tz
parents:
796
diff
changeset
|
1540 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1541 |
windowGroup withExecuteCursorDo:[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1542 |
(self resourceSelector trimBlanks size = 0) | (cls := Smalltalk at: self resourceClass) isClass not |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1543 |
ifTrue: [^self saveMethodAs]. |
822
cace81f0a86b
do not overwrite method categories + toggle between mouse button colors
tz
parents:
796
diff
changeset
|
1544 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1545 |
self image storeOn: (imageStoreStream := WriteStream on: ''). |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1546 |
sel := self resourceSelector. |
1027
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1547 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1548 |
"/ if that method already exists, do not overwrite the category |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1549 |
category := 'image specs'. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1550 |
(mthd := cls class compiledMethodAt:sel) notNil ifTrue:[ |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1551 |
category := mthd category. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1552 |
]. |
822
cace81f0a86b
do not overwrite method categories + toggle between mouse button colors
tz
parents:
796
diff
changeset
|
1553 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1554 |
imageKey := (cls name, ' ', sel) asSymbol. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1555 |
Icon constantNamed: imageKey put:nil. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1556 |
ByteCodeCompiler |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1557 |
compile: ((sel, |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1558 |
'\', (ResourceSpecEditor codeGenerationCommentForClass: ImageEditor), |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1559 |
'\\' , |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1560 |
' "\', |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1561 |
' self ' , self resourceSelector , ' inspect\', |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1562 |
' ImageEditor openOnClass:self andSelector:#', self resourceSelector, |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1563 |
'\ "', |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1564 |
'\\', |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1565 |
' <resource: #image>', |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1566 |
'\\', |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1567 |
' ^Icon\') withCRs, |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1568 |
' constantNamed:#''', imageKey, '''\' withCRs, |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1569 |
' ifAbsentPut:[', imageStoreStream contents, ']') |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1570 |
forClass: cls class inCategory: category. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1571 |
modified := false. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1572 |
] |
633 | 1573 |
] |
1027
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1574 |
|
1047 | 1575 |
"Modified: / 31.7.1998 / 20:12:54 / cg" |
633 | 1576 |
! |
1577 |
||
1578 |
saveMethodAs |
|
1579 |
||
636 | 1580 |
(self resourceMessage: |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1581 |
(ResourceSelectionBrowser |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1582 |
request: 'Save Image In Class' |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1583 |
onSuperclass: #Object |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1584 |
andClass: self resourceClass |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1585 |
andSelector: self resourceSelector |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1586 |
withResourceTypes: #(image fileImage))) notNil |
633 | 1587 |
ifTrue: |
674 | 1588 |
[ |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1589 |
^self saveMethod |
674 | 1590 |
]. |
633 | 1591 |
^nil |
1 | 1592 |
! ! |
1593 |
||
161 | 1594 |
!ImageEditView methodsFor:'queries'! |
5 | 1595 |
|
161 | 1596 |
heightOfContents |
1597 |
||
686 | 1598 |
image isNil ifTrue:[^0]. |
1599 |
^(image height * magnification y) rounded |
|
5 | 1600 |
! |
1601 |
||
995 | 1602 |
imageContainsPastePoint: aPoint |
1603 |
||
1604 |
^image notNil and: |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1605 |
[Clipboard notNil and: |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1606 |
[((0@0 corner:(image extent) "- 1" - Clipboard extent) containsPoint: (((aPoint - margin + 1) / magnification) floor))]] |
995 | 1607 |
! |
1608 |
||
627 | 1609 |
imageContainsPoint: aPoint |
632 | 1610 |
|
1611 |
^image notNil and: |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1612 |
[((0@0 corner:(image extent) - 1) containsPoint: (((aPoint - margin + 1) / magnification) floor))] |
627 | 1613 |
! |
1614 |
||
783 | 1615 |
imageInfoString |
1616 |
||
1617 |
|imageInfoString usedColors| |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1618 |
|
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1619 |
image isNil ifTrue: [imageInfoString := 'No image loaded.'] |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1620 |
ifFalse: [ |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1621 |
image colorMap isNil ifTrue: [usedColors := '?'] ifFalse: [usedColors := image usedColors size]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1622 |
imageInfoString := image width printString, 'x' |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1623 |
, image height printString, 'x' |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1624 |
, (2 raisedTo: image depth) printString |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1625 |
, (image mask notNil ifTrue: [' (mask + '] ifFalse: ['(']) |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1626 |
, usedColors printString |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1627 |
, ' used colors)']. |
783 | 1628 |
|
1629 |
^imageInfoString |
|
1630 |
! |
|
1631 |
||
161 | 1632 |
widthOfContents |
5 | 1633 |
|
686 | 1634 |
image isNil ifTrue:[^0]. |
1635 |
^(image width * magnification x) rounded |
|
5 | 1636 |
! ! |
1637 |
||
627 | 1638 |
!ImageEditView methodsFor:'release'! |
1639 |
||
995 | 1640 |
releasePasteDrawing |
1641 |
||
1642 |
(lastPastePoint notNil and: [ClipboardMagnification notNil]) |
|
1643 |
ifTrue: |
|
1644 |
[ |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1645 |
self redraw: (lastPastePoint extent: (ClipboardMagnification extent)). |
995 | 1646 |
]. |
1647 |
lastPastePoint := ClipboardMagnification := nil |
|
1648 |
! |
|
1649 |
||
1650 |
releaseUndos |
|
1651 |
||
1652 |
undoImages removeAll. |
|
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
1653 |
"/ cg: what a kludge - please change to use a valueHolder, |
1261 | 1654 |
masterApplication notNil ifTrue:[ |
1655 |
masterApplication valueOfCanUndo value: false. |
|
1656 |
]. |
|
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
1657 |
|
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
1658 |
"Modified: / 31.7.1998 / 02:47:21 / cg" |
627 | 1659 |
! ! |
1660 |
||
632 | 1661 |
!ImageEditView methodsFor:'testing'! |
1662 |
||
1663 |
checkModified |
|
1664 |
||
1665 |
modified |
|
1666 |
ifTrue: |
|
1667 |
[ |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1668 |
((YesNoBox title:(resources string:'Image was modified !!')) |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1669 |
noText:(resources string:'Cancel'); |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1670 |
yesText:(resources string:'Forget it and proceed'); |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1671 |
showAtPointer; |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1672 |
accepted) ifFalse: [^false]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1673 |
modified := false |
632 | 1674 |
]. |
1675 |
^true |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1676 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1677 |
"Modified: / 29.7.1998 / 18:55:24 / cg" |
632 | 1678 |
! ! |
1679 |
||
255 | 1680 |
!ImageEditView class methodsFor:'documentation'! |
161 | 1681 |
|
1682 |
version |
|
1373
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
1683 |
^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.117 1999-05-09 14:02:46 cg Exp $' |
161 | 1684 |
! ! |
1245 | 1685 |
ImageEditView initialize! |