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