author | Claus Gittinger <cg@exept.de> |
Tue, 19 Oct 2004 19:09:17 +0200 | |
changeset 2764 | 3302aab746d2 |
parent 2756 | 5a1646996277 |
child 2765 | 5bc0bfbeac33 |
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 |
2747 | 17 |
mouseKeyColorMode undoImages modifiedHolder editMode |
18 |
lastPastePoint imageInfoHolder activityInfoHolder |
|
19 |
pickedColorHolder drawingColors drawingPixels drawingColorHolders |
|
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
20 |
drawingPixelHolders clickInfoCallBack' |
2440 | 21 |
classVariableNames:'Clipboard ClipboardMagnified LastMagnification |
1994 | 22 |
GridMagnificationLimit MaxUndos LastSaveDirectory LastSaveClass' |
1035 | 23 |
poolDictionaries:'' |
1706 | 24 |
category:'Views-Misc' |
1 | 25 |
! |
26 |
||
636 | 27 |
!ImageEditView class methodsFor:'documentation'! |
28 |
||
29 |
copyright |
|
30 |
" |
|
704 | 31 |
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
|
32 |
All Rights Reserved |
636 | 33 |
|
34 |
This software is furnished under a license and may be used |
|
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
41 |
! |
|
42 |
||
43 |
documentation |
|
44 |
" |
|
2747 | 45 |
An ImageEditView is a view which can be used by applications |
46 |
like the Image Editor for editing or inspecting (bitmap-) images. |
|
636 | 47 |
|
48 |
[see also:] |
|
2747 | 49 |
ImageEditor Image |
636 | 50 |
|
51 |
[author:] |
|
2747 | 52 |
Thomas Zwick |
636 | 53 |
" |
54 |
! ! |
|
353 | 55 |
|
1245 | 56 |
!ImageEditView class methodsFor:'initialization'! |
57 |
||
58 |
initialize |
|
59 |
MaxUndos := 5. |
|
1706 | 60 |
GridMagnificationLimit := 8 @ 8. |
1245 | 61 |
|
62 |
" |
|
63 |
self initialize |
|
64 |
" |
|
65 |
! ! |
|
66 |
||
1706 | 67 |
!ImageEditView class methodsFor:'accessing'! |
68 |
||
69 |
gridMagnificationLimit |
|
70 |
^ GridMagnificationLimit |
|
71 |
! |
|
72 |
||
73 |
gridMagnificationLimit:anInteger |
|
74 |
GridMagnificationLimit := anInteger |
|
75 |
! ! |
|
76 |
||
2480 | 77 |
!ImageEditView class methodsFor:'helpers'! |
78 |
||
79 |
copyImageToClipboard:copiedImage |
|
80 |
ClipboardMagnified := nil. |
|
81 |
Clipboard := copiedImage. |
|
82 |
! ! |
|
83 |
||
2634 | 84 |
!ImageEditView class methodsFor:'resources'! |
85 |
||
86 |
classResources |
|
87 |
^ ImageEditor classResources |
|
88 |
! ! |
|
89 |
||
7 | 90 |
!ImageEditView methodsFor:'accessing'! |
91 |
||
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
92 |
activityInfoHolder |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
93 |
"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
|
94 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
95 |
^ activityInfoHolder |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
96 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
97 |
"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
|
98 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
99 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
100 |
activityInfoHolder:something |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
101 |
"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
|
102 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
103 |
activityInfoHolder := something. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
104 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
105 |
"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
|
106 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
107 |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
108 |
clearModified |
2747 | 109 |
self modified:false |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
110 |
! |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
111 |
|
1693 | 112 |
clickInfoCallBack:aTwoArgBlock |
113 |
clickInfoCallBack := aTwoArgBlock |
|
114 |
||
115 |
"Created: / 10.2.2000 / 23:07:14 / cg" |
|
116 |
! |
|
117 |
||
2440 | 118 |
clipBoard |
119 |
^ Clipboard |
|
120 |
! |
|
121 |
||
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
122 |
drawingColors:anArrayTwoColors |
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
123 |
(drawingColorHolders at:1) value:(anArrayTwoColors at:1). |
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
124 |
(drawingColorHolders at:2) value:(anArrayTwoColors at:2). |
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
125 |
! |
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
126 |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
127 |
imageInfoHolder |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
128 |
"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
|
129 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
130 |
^ imageInfoHolder |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
131 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
132 |
"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
|
133 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
134 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
135 |
imageInfoHolder:something |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
136 |
"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
|
137 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
138 |
imageInfoHolder := something. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
139 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
140 |
"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
|
141 |
! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
142 |
|
624 | 143 |
magnification |
144 |
||
145 |
^magnification |
|
146 |
||
255 | 147 |
! |
148 |
||
636 | 149 |
magnification: aPoint |
1037 | 150 |
|oldOrg| |
255 | 151 |
|
627 | 152 |
magnification ~= aPoint |
624 | 153 |
ifTrue: |
154 |
[ |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
155 |
oldOrg := self viewOrigin / magnification. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
156 |
magnification := aPoint asPoint. |
1037 | 157 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
158 |
self scrollTo:(oldOrg * magnification) rounded redraw:false. |
1037 | 159 |
"/ self scrollToTopLeft. |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
160 |
self contentsChanged. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
161 |
self invalidate. |
2440 | 162 |
ClipboardMagnified := nil. |
686 | 163 |
] |
1037 | 164 |
|
165 |
"Modified: / 31.7.1998 / 02:38:47 / cg" |
|
624 | 166 |
! |
255 | 167 |
|
2747 | 168 |
modified:aBoolean |
169 |
modifiedHolder value:aBoolean |
|
170 |
! |
|
171 |
||
172 |
modifiedHolder |
|
173 |
^ modifiedHolder |
|
174 |
! |
|
175 |
||
627 | 176 |
resourceClass |
177 |
||
178 |
^resourceClass |
|
179 |
! |
|
180 |
||
181 |
resourceClass: aClassOrSymbol |
|
182 |
||
686 | 183 |
resourceClass := aClassOrSymbol isClass ifTrue: [aClassOrSymbol name] ifFalse: [aClassOrSymbol asSymbol] |
627 | 184 |
! |
185 |
||
186 |
resourceMessage |
|
187 |
||
188 |
^resourceClass, ' ', resourceSelector |
|
189 |
! |
|
190 |
||
636 | 191 |
resourceMessage: aString |
627 | 192 |
|
636 | 193 |
(aString isString and: [aString trimBlanks size > 0]) |
627 | 194 |
ifTrue: |
195 |
[ |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
196 |
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
|
197 |
resourceSelector := (aString copy reverse readStream upTo: Character space) reverse asSymbol |
627 | 198 |
] |
199 |
ifFalse: |
|
200 |
[ |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
201 |
^nil |
686 | 202 |
] |
627 | 203 |
|
204 |
||
205 |
! |
|
206 |
||
207 |
resourceSelector |
|
208 |
||
209 |
^resourceSelector |
|
210 |
! |
|
211 |
||
212 |
resourceSelector: aStringOrSymbol |
|
213 |
||
214 |
resourceSelector := aStringOrSymbol asSymbol |
|
215 |
! |
|
216 |
||
217 |
selectedColor |
|
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
218 |
^ (drawingColorHolders at:mouseKeyColorMode) value |
1246 | 219 |
! |
220 |
||
221 |
selectedColor: aColor |
|
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
222 |
(drawingColorHolders at:mouseKeyColorMode) value:aColor |
627 | 223 |
! |
224 |
||
1246 | 225 |
selectedColorIndex |
627 | 226 |
|
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
227 |
^ (drawingPixelHolders at:mouseKeyColorMode) value |
1246 | 228 |
! |
229 |
||
230 |
selectedColorIndex: aPixelIndex |
|
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
231 |
(drawingPixelHolders at:mouseKeyColorMode) value: aPixelIndex |
995 | 232 |
! |
233 |
||
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
234 |
setModified |
2747 | 235 |
self modified:true |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
236 |
! |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
237 |
|
995 | 238 |
undoImages |
239 |
||
240 |
^undoImages |
|
627 | 241 |
! ! |
242 |
||
243 |
!ImageEditView methodsFor:'drawing'! |
|
244 |
||
1036 | 245 |
drawFrame |
246 |
||
247 |
self paint:Color black. |
|
248 |
self lineWidth: (magnification x//3 min: 3). |
|
1104 | 249 |
self displayRectangle: ((0@0) extent:(image extent * magnification) + margin). |
1036 | 250 |
self lineWidth:1. |
251 |
! |
|
252 |
||
253 |
drawFramesIn: aRectangle |
|
254 |
||
1706 | 255 |
magnification >= GridMagnificationLimit |
1036 | 256 |
ifTrue: |
257 |
[ |
|
1706 | 258 |
|origin lineStartingPoint lineEndingPoint oldColor| |
259 |
origin := aRectangle origin - 1. |
|
260 |
lineStartingPoint := origin + (0@magnification y). |
|
261 |
lineEndingPoint := lineStartingPoint + (aRectangle width@0). |
|
262 |
oldColor := self paint. |
|
263 |
self xoring: |
|
264 |
[ |
|
265 |
self displayLineFrom: lineStartingPoint to: lineEndingPoint. |
|
266 |
lineStartingPoint x to: lineStartingPoint x + aRectangle width - magnification x by: magnification x do: |
|
267 |
[:x| |
|
268 |
self displayLineFrom: x@(origin y) to: x@(origin y + magnification y) |
|
269 |
]. |
|
270 |
]. |
|
271 |
self paint: oldColor. |
|
1036 | 272 |
] |
273 |
||
274 |
||
275 |
||
276 |
! |
|
277 |
||
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
278 |
drawPasteRectangleAt: aPoint |
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 |
|currentPoint gridCorrection extent org| |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
281 |
|
1706 | 282 |
magnification >= GridMagnificationLimit ifFalse: [gridCorrection := 0] ifTrue: [gridCorrection := 1]. |
1449 | 283 |
currentPoint := aPoint // magnification*magnification + margin. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
284 |
|
2085 | 285 |
self repairDamage. |
286 |
||
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
287 |
currentPoint ~= lastPastePoint ifTrue:[ |
2440 | 288 |
ClipboardMagnified isNil ifTrue:[ |
289 |
ClipboardMagnified := (Clipboard magnifiedBy: magnification) onDevice: device |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
290 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
291 |
|
2440 | 292 |
extent := ClipboardMagnified extent. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
293 |
|
1967 | 294 |
"/ currentPoint := currentPoint - self viewOrigin. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
295 |
|
2085 | 296 |
self redraw: (((lastPastePoint ? currentPoint)"-self viewOrigin") extent: extent). |
297 |
self repairDamage. |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
298 |
|
2085 | 299 |
false " (extent x > 400 or: [extent y > 400])" ifTrue:[ |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
300 |
self xoring: [ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
301 |
self fillRectangle: (currentPoint extent: extent) |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
302 |
] |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
303 |
] ifFalse:[ |
2440 | 304 |
ClipboardMagnified notNil ifTrue:[ |
305 |
self displayDeviceForm: ClipboardMagnified |
|
2089 | 306 |
x: currentPoint x - self viewOrigin x |
307 |
y: currentPoint y - self viewOrigin y. |
|
308 |
]. |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
309 |
editMode == #pasteUnder ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
310 |
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
|
311 |
] |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
312 |
] |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
313 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
314 |
lastPastePoint := currentPoint. |
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:23:33 / 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 |
|
662 | 319 |
fillFramedRectangle: aRectangle |
320 |
||
321 |
self fillRectangle: aRectangle. |
|
322 |
self drawFramesIn: aRectangle |
|
323 |
! |
|
324 |
||
1449 | 325 |
redraw:aRectangle |
2053
5c19fe5b2db3
invalidate rather than redraw
Claus Gittinger <cg@exept.de>
parents:
2034
diff
changeset
|
326 |
self invalidate:(aRectangle origin "+ self viewOrigin" extent:aRectangle extent). |
5c19fe5b2db3
invalidate rather than redraw
Claus Gittinger <cg@exept.de>
parents:
2034
diff
changeset
|
327 |
"/ super redraw:(aRectangle origin + self viewOrigin extent:aRectangle extent). |
1449 | 328 |
|
2053
5c19fe5b2db3
invalidate rather than redraw
Claus Gittinger <cg@exept.de>
parents:
2034
diff
changeset
|
329 |
"Modified: / 15.11.2001 / 16:43:53 / cg" |
1449 | 330 |
! |
331 |
||
627 | 332 |
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
|
333 |
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
|
334 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
335 |
"Modified: / 18.5.1999 / 20:14:03 / cg" |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
336 |
! |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
337 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
338 |
redrawImageX:x y:y width:w height:h unmaskedOnly:unmaskedOnly |
636 | 339 |
|
1037 | 340 |
|ih iw magX magY minX maxX minY maxY |
341 |
color lastColor lastY runW x0 xI yI maskColor mask |
|
1180 | 342 |
sizeOfMaskPoint useNearestColor| |
343 |
||
344 |
useNearestColor := device visualType == #PseudoColor. |
|
627 | 345 |
|
1037 | 346 |
mask := image mask. |
627 | 347 |
ih := image height. |
348 |
iw := image width. |
|
662 | 349 |
magX := magnification x. |
350 |
magY := magnification y. |
|
627 | 351 |
|
662 | 352 |
minX := (x // magX - 1) max: 0. |
725 | 353 |
minX >= iw ifTrue:[minX := (iw - 1) max: 0]. |
662 | 354 |
minY := (y // magY - 1) max: 0. |
725 | 355 |
minY >= ih ifTrue:[minY := (ih - 1) max: 0]. |
662 | 356 |
maxX := (x + w) // magX + 1. |
627 | 357 |
maxX > iw ifTrue:[maxX := iw]. |
662 | 358 |
maxY := (y + h) // magY + 1. |
627 | 359 |
maxY > ih ifTrue:[maxY := ih]. |
360 |
||
361 |
lastY := -1. |
|
362 |
||
363 |
x0 := minX. |
|
364 |
runW := 0. |
|
365 |
maskColor := false. |
|
662 | 366 |
sizeOfMaskPoint := magnification//3. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
367 |
image |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
368 |
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
|
369 |
do:[:xx :yy :color| |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
370 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
371 |
shown ifFalse:[^ self]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
372 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
373 |
yy ~~ lastY ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
374 |
runW ~~ 0 ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
375 |
|origin| |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
376 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
377 |
origin := (x0 * magX + margin)@(lastY * magY + margin). |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
378 |
(unmaskedOnly not or:[maskColor not]) ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
379 |
self fillFramedRectangle: (origin extent: (runW@magY)). |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
380 |
maskColor ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
381 |
self xoring: [self fillRectangle: (origin + sizeOfMaskPoint extent: sizeOfMaskPoint)] |
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 |
runW := 0. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
385 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
386 |
x0 := xx. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
387 |
lastY := yy. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
388 |
]. |
1160 | 389 |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
390 |
color ~= lastColor ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
391 |
runW ~~ 0 ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
392 |
|origin| |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
393 |
origin := (x0 * magX + margin)@(yy * magY + margin). |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
394 |
(unmaskedOnly not or:[maskColor not]) ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
395 |
self fillFramedRectangle: (origin extent: (runW@magY)). |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
396 |
maskColor ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
397 |
self xoring: [self fillRectangle: (origin + sizeOfMaskPoint extent: sizeOfMaskPoint)] |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
398 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
399 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
400 |
runW := 0. |
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 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
403 |
lastColor := color. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
404 |
useNearestColor ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
405 |
lastColor := lastColor nearestOn:device |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
406 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
407 |
self paint:lastColor. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
408 |
mask notNil ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
409 |
maskColor := false. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
410 |
(mask pixelAtX:xx y:yy) == 0 ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
411 |
unmaskedOnly ifFalse:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
412 |
self paint: (lastColor := self viewBackground). |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
413 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
414 |
maskColor := true. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
415 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
416 |
lastColor := nil. |
1160 | 417 |
]. |
418 |
runW := 0. |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
419 |
x0 := xx. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
420 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
421 |
runW := runW + magX |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
422 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
423 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
424 |
runW ~~ 0 ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
425 |
|origin| |
624 | 426 |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
427 |
origin := (x0 * magX + margin)@(lastY * magY + margin). |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
428 |
(unmaskedOnly not or:[maskColor not]) ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
429 |
self fillFramedRectangle: (origin extent: runW@magY). |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
430 |
maskColor ifTrue:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
431 |
self xoring:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
432 |
self fillRectangle: (origin + sizeOfMaskPoint extent: sizeOfMaskPoint) |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
433 |
] |
1180 | 434 |
]. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
435 |
] |
627 | 436 |
]. |
1037 | 437 |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
438 |
"Created: / 18.5.1999 / 20:13:39 / cg" |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
439 |
"Modified: / 18.5.1999 / 20:36:20 / cg" |
627 | 440 |
! |
441 |
||
442 |
redrawX:x y:y width:w height:h |
|
636 | 443 |
|
1967 | 444 |
|ih iw xI yI devImage imgWidth imgHeight| |
627 | 445 |
|
1037 | 446 |
image isNil ifTrue:[^self]. |
662 | 447 |
|
1037 | 448 |
magnification = (1@1) ifTrue: [ |
1510
fd0cd6065dc6
catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
449 |
Object errorSignal handle:[:ex | |
2092 | 450 |
Transcript showCR:'cannot convert image: ', ex description. |
1510
fd0cd6065dc6
catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
451 |
] do:[ |
1763
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
452 |
devImage := image onDevice:device. |
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
453 |
devImage ~~ image ifTrue:[ |
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
454 |
image := devImage. |
1764 | 455 |
self changed:#image. |
1763
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
456 |
]. |
1510
fd0cd6065dc6
catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
457 |
]. |
fd0cd6065dc6
catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
458 |
image device == device ifTrue:[ |
fd0cd6065dc6
catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
459 |
^ super redrawX:x y:y width:w height:h |
fd0cd6065dc6
catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
460 |
]. |
1037 | 461 |
]. |
627 | 462 |
|
1449 | 463 |
self clippingRectangle: (x@y extent:w@h). |
627 | 464 |
|
465 |
self redrawImageX:x y:y width:w height:h. |
|
466 |
||
467 |
"/ right of image ? |
|
468 |
adjust == #center ifTrue: |
|
469 |
[ |
|
1449 | 470 |
xI := (width - ih) // 2 - margin. |
471 |
yI := (height - iw) // 2 - margin. |
|
627 | 472 |
] |
473 |
ifFalse: |
|
474 |
[ |
|
1449 | 475 |
xI := yI := margin |
627 | 476 |
]. |
1967 | 477 |
|
478 |
imgWidth := image width. |
|
479 |
imgHeight := image height. |
|
480 |
||
481 |
(x + w - 1) > (xI + (magnification x * imgWidth)) ifTrue: |
|
627 | 482 |
[ |
1967 | 483 |
self clearRectangleX:(xI + (magnification x * imgWidth)) |
1449 | 484 |
y:y |
1967 | 485 |
width:(x + w - (magnification x * imgWidth) - xI) |
1449 | 486 |
height:h |
627 | 487 |
]. |
1967 | 488 |
(y + h - 1) > (yI + (magnification y * imgHeight)) ifTrue: |
627 | 489 |
[ |
1449 | 490 |
self clearRectangleX:margin |
1967 | 491 |
y:(yI + (magnification y * imgHeight)) |
1449 | 492 |
width:w |
1967 | 493 |
height:(y + h - (magnification y * imgHeight) - yI) |
627 | 494 |
]. |
495 |
self drawFrame. |
|
496 |
self clippingRectangle: nil. |
|
1037 | 497 |
|
498 |
"Modified: / 31.7.1998 / 02:22:45 / cg" |
|
627 | 499 |
! ! |
500 |
||
501 |
!ImageEditView methodsFor:'edit modes'! |
|
502 |
||
503 |
editMode |
|
504 |
||
1106 | 505 |
^editMode |
627 | 506 |
! |
507 |
||
2440 | 508 |
editMode: anEditModeSymbol |
627 | 509 |
|
2440 | 510 |
editMode := anEditModeSymbol |
627 | 511 |
! |
512 |
||
513 |
mouseKeyColorMode |
|
514 |
||
515 |
^mouseKeyColorMode printString |
|
516 |
! |
|
517 |
||
518 |
mouseKeyColorMode:aMode |
|
519 |
||
1106 | 520 |
mouseKeyColorMode := aMode |
627 | 521 |
! ! |
522 |
||
523 |
!ImageEditView methodsFor:'event handling'! |
|
524 |
||
525 |
buttonMotion:state x:x y:y |
|
1246 | 526 |
|
1693 | 527 |
|p| |
528 |
||
2072
abd4e246f393
care for negative pos in buttonMotion (win32 klusge)
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
529 |
(x < 0 or:[y < 0]) ifTrue:[ |
abd4e246f393
care for negative pos in buttonMotion (win32 klusge)
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
530 |
^ self |
abd4e246f393
care for negative pos in buttonMotion (win32 klusge)
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
531 |
]. |
abd4e246f393
care for negative pos in buttonMotion (win32 klusge)
Claus Gittinger <cg@exept.de>
parents:
2053
diff
changeset
|
532 |
|
1693 | 533 |
p := x@y. |
534 |
||
535 |
state ~~ 0 ifTrue:[ |
|
1245 | 536 |
("self selectedColor notNil" true |
1693 | 537 |
and:[(self imageContainsPoint:p) |
538 |
and:[editMode == #point]]) |
|
539 |
ifTrue:[ |
|
540 |
self pointAt:p. |
|
1246 | 541 |
^ self |
542 |
]. |
|
1693 | 543 |
self drawCursorAt:p. |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
544 |
] ifFalse:[ |
2092 | 545 |
"/ Transcript showCR:'m'. |
1693 | 546 |
self drawCursorAt:p. |
2508 | 547 |
self inPasteMode ifTrue: [ |
2092 | 548 |
"/ Transcript show:'p '; showCR:(self imageContainsPastePoint:p). |
1693 | 549 |
("self selectedColor notNil" true and: [self imageContainsPastePoint:p]) |
550 |
ifTrue: [self drawPasteRectangleAt:p] |
|
1245 | 551 |
ifFalse: [self cursor:Cursor stop. self releasePasteDrawing] |
552 |
] |
|
686 | 553 |
] |
1019
e68414752bc9
only change the cursor for myself.
Claus Gittinger <cg@exept.de>
parents:
1013
diff
changeset
|
554 |
|
1693 | 555 |
"Modified: / 10.2.2000 / 22:03:18 / cg" |
624 | 556 |
! |
255 | 557 |
|
627 | 558 |
buttonPress:button x:x y:y |
2277 | 559 |
|p mouseButtonColorToolBar clr masked| |
627 | 560 |
|
1693 | 561 |
p := x@y. |
562 |
||
563 |
self drawCursorAt:p. |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
564 |
|
1246 | 565 |
("self selectedColor notNil" true |
1693 | 566 |
and: [self imageContainsPoint:p]) |
1246 | 567 |
ifTrue:[ |
568 |
self sensor shiftDown ifTrue:[ |
|
2277 | 569 |
(image maskAt:(p // magnification)) == 0 ifTrue:[ |
570 |
masked := true. |
|
571 |
] ifFalse:[ |
|
572 |
masked := false. |
|
573 |
clr := image colorAt:(p // magnification). |
|
574 |
]. |
|
1246 | 575 |
pickedColorHolder notNil ifTrue:[ |
576 |
"/ select the color under the cursor, place it into the |
|
577 |
"/ pickedColorHolder/ |
|
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
578 |
pickedColorHolder value:clr. |
1246 | 579 |
]. |
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
580 |
self selectedColor:clr. |
2277 | 581 |
masked ifTrue:[self selectedColorIndex:nil]. |
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
582 |
self changed:#selectedColor with:clr. |
1246 | 583 |
] ifFalse:[ |
584 |
mouseKeyColorMode := button. |
|
585 |
self makeUndo. |
|
1693 | 586 |
|
587 |
"/ "/ cg: what a kludge - please change to use a valueHolder, |
|
588 |
"/ "/ which gets the information ... |
|
589 |
"/ mouseButtonColorToolBar := masterApplication builder componentAt: #MouseButtonColorToolBar. |
|
590 |
"/ mouseButtonColorToolBar notNil ifTrue:[ |
|
591 |
"/ (mouseButtonColorToolBar itemAt: mouseKeyColorMode) toggleIndication. |
|
592 |
"/ mouseButtonColorToolBar do: [:i| i updateIndicators]. |
|
593 |
"/ ]. |
|
594 |
||
595 |
clickInfoCallBack notNil ifTrue:[ |
|
596 |
"/ still a kludge, but less ugly ... |
|
597 |
clickInfoCallBack value:button value:p |
|
598 |
]. |
|
1246 | 599 |
"/ editMode is something like #point, #rectangle etc. |
1693 | 600 |
self perform: (editMode, 'At:') asSymbol with:p |
1246 | 601 |
] |
686 | 602 |
] |
995 | 603 |
|
1693 | 604 |
"Modified: / 10.2.2000 / 23:11:33 / cg" |
632 | 605 |
! |
606 |
||
994
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
607 |
buttonRelease:button x:x y:y |
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
608 |
|
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
609 |
self drawCursorAt: x@y. |
1246 | 610 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
611 |
("self selectedColor notNil" true and: [self imageContainsPoint: x@y]) |
1246 | 612 |
ifTrue: [ |
1763
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
613 |
image release. |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
614 |
|
1693 | 615 |
"/ "/ cg: what a kludge - please change to use a valueHolder, |
616 |
"/ "/ which gets the information ... |
|
617 |
"/ masterApplication imagePreView invalidate. |
|
618 |
||
619 |
"/ cg: still a kludge - but less ugly |
|
620 |
self changed:#subImageIn with:(image bounds). |
|
994
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
621 |
] |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
622 |
|
1693 | 623 |
"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
|
624 |
! |
5727c2484ecd
bugs fixed in undo/mask and point painting/preview and pasting
tz
parents:
877
diff
changeset
|
625 |
|
2508 | 626 |
inPasteMode |
627 |
^ (editMode startsWith:#paste) |
|
628 |
! |
|
629 |
||
686 | 630 |
pointerLeave:state |
631 |
||
688 | 632 |
super pointerLeave: state. |
686 | 633 |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
634 |
self updateImageInfo: self imageInfoString. |
1019
e68414752bc9
only change the cursor for myself.
Claus Gittinger <cg@exept.de>
parents:
1013
diff
changeset
|
635 |
self cursor:Cursor normal. |
995 | 636 |
|
2508 | 637 |
self inPasteMode ifTrue: [ |
1246 | 638 |
self releasePasteDrawing |
639 |
] |
|
995 | 640 |
|
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
641 |
"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
|
642 |
! ! |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
643 |
|
636 | 644 |
!ImageEditView methodsFor:'image editing'! |
627 | 645 |
|
646 |
boxAt: aPoint |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
647 |
"draw a rectangular outline with the currently selected color" |
627 | 648 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
649 |
|choosedBox imageBox clr| |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
650 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
651 |
(clr := self selectedColor) notNil ifTrue:[ |
1693 | 652 |
choosedBox := self dragRectangleStartingAt: aPoint emphasis: #box. |
653 |
imageBox := choosedBox origin//magnification extent: (choosedBox extent//magnification). |
|
2415 | 654 |
image drawRectangle:imageBox withColor:clr. |
1693 | 655 |
image restored. |
656 |
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
|
657 |
|
1693 | 658 |
"/ "/ cg: what a kludge - please change to use a valueHolder, |
659 |
"/ "/ which gets the information ... |
|
660 |
"/ masterApplication imagePreView redraw: (imageBox expandedBy: 1). |
|
661 |
||
662 |
"/ cg: still a kludge - but less ugly |
|
663 |
self changed:#subImageIn with:(imageBox expandedBy: 1). |
|
664 |
||
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
665 |
self setModified. |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
666 |
]. |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
667 |
|
1693 | 668 |
"Modified: / 10.2.2000 / 23:42:08 / cg" |
632 | 669 |
! |
670 |
||
2756 | 671 |
brightenImage |
672 |
self makeUndo. |
|
673 |
self image: (image copy lightened). |
|
674 |
self setModified. |
|
675 |
! |
|
676 |
||
632 | 677 |
copyAt: aPoint |
2440 | 678 |
|choosenBox r box copiedImage| |
1084
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
679 |
|
1449 | 680 |
choosenBox := self dragRectangleStartingAt: aPoint emphasis: #inverseFilledBox. |
2440 | 681 |
box := choosenBox origin // magnification extent: (choosenBox extent // magnification). |
682 |
copiedImage := image subImageIn: box. |
|
683 |
||
2480 | 684 |
self class copyImageToClipboard:copiedImage. |
2440 | 685 |
|
1449 | 686 |
r := (choosenBox expandedBy:1). |
687 |
self redraw:r |
|
632 | 688 |
|
1084
87c661e6c333
scroll when dragging out of the view in copy-mode.
Claus Gittinger <cg@exept.de>
parents:
1060
diff
changeset
|
689 |
"Modified: / 21.8.1998 / 20:16:41 / cg" |
632 | 690 |
! |
691 |
||
2480 | 692 |
copyImageToClipboard |
693 |
self class copyImageToClipboard:image. |
|
694 |
! |
|
695 |
||
1228 | 696 |
cropLeft:doLeft right:doRight top:doTop bottom:doBottom |
1121 | 697 |
|yMinNew yMaxNew xMinNew xMaxNew |
698 |
pix stillCrobbing xMax yMax x y| |
|
699 |
||
700 |
xMax := image width - 1. |
|
701 |
yMax := image height - 1. |
|
702 |
||
703 |
xMinNew := 0. |
|
704 |
doLeft ifTrue:[ |
|
705 |
pix := image pixelAtX:xMinNew y:0. |
|
706 |
stillCrobbing := true. |
|
707 |
[stillCrobbing] whileTrue:[ |
|
708 |
0 to:yMax do:[:y | |
|
709 |
(image pixelAtX:xMinNew y:y) ~~ pix ifTrue:[ |
|
710 |
stillCrobbing := false |
|
711 |
] |
|
712 |
]. |
|
713 |
stillCrobbing ifTrue:[ |
|
714 |
xMinNew := xMinNew + 1. |
|
715 |
xMinNew >= image width ifTrue:[ |
|
716 |
self warn:'Image is all the same color - no crob.'. |
|
717 |
^ self |
|
718 |
] |
|
719 |
]. |
|
720 |
]. |
|
721 |
]. |
|
722 |
||
723 |
xMaxNew := xMax. |
|
724 |
doRight ifTrue:[ |
|
725 |
stillCrobbing := true. |
|
726 |
pix := image pixelAtX:xMaxNew y:0. |
|
727 |
[stillCrobbing] whileTrue:[ |
|
728 |
0 to:yMax do:[:y | |
|
729 |
(image pixelAtX:xMaxNew y:y) ~~ pix ifTrue:[ |
|
730 |
stillCrobbing := false |
|
731 |
] |
|
732 |
]. |
|
733 |
stillCrobbing ifTrue:[ |
|
734 |
xMaxNew := xMaxNew - 1. |
|
735 |
]. |
|
736 |
]. |
|
737 |
]. |
|
738 |
||
739 |
yMinNew := 0. |
|
740 |
doTop ifTrue:[ |
|
741 |
pix := image pixelAtX:xMinNew y:yMinNew. |
|
742 |
stillCrobbing := true. |
|
743 |
[stillCrobbing] whileTrue:[ |
|
744 |
xMinNew to:xMaxNew do:[:x | |
|
745 |
(image pixelAtX:x y:yMinNew) ~~ pix ifTrue:[ |
|
746 |
stillCrobbing := false |
|
747 |
] |
|
748 |
]. |
|
749 |
stillCrobbing ifTrue:[ |
|
750 |
yMinNew := yMinNew + 1. |
|
751 |
]. |
|
752 |
]. |
|
753 |
]. |
|
754 |
||
755 |
yMaxNew := yMax. |
|
756 |
doRight ifTrue:[ |
|
757 |
stillCrobbing := true. |
|
758 |
pix := image pixelAtX:xMaxNew y:yMaxNew. |
|
759 |
[stillCrobbing] whileTrue:[ |
|
760 |
xMinNew to:xMaxNew do:[:x | |
|
761 |
(image pixelAtX:x y:yMaxNew) ~~ pix ifTrue:[ |
|
762 |
stillCrobbing := false |
|
763 |
] |
|
764 |
]. |
|
765 |
stillCrobbing ifTrue:[ |
|
766 |
yMaxNew := yMaxNew - 1. |
|
767 |
]. |
|
768 |
]. |
|
769 |
]. |
|
770 |
||
771 |
(xMinNew == 0 |
|
772 |
and:[xMaxNew == (image width - 1) |
|
773 |
and:[yMinNew == 0 |
|
774 |
and:[yMaxNew == (image height - 1)]]]) ifTrue:[ |
|
775 |
self warn:'No border found - no crob.'. |
|
776 |
^ self |
|
777 |
]. |
|
778 |
||
779 |
"/ self warn:'extract subImage ' |
|
780 |
"/ , (xMinNew @ yMinNew) printString |
|
781 |
"/ , ' -> ' |
|
782 |
"/ , (xMaxNew @ yMaxNew) printString. |
|
783 |
||
2006 | 784 |
self makeUndo. |
1121 | 785 |
self |
786 |
makeSubImageX:xMinNew y:yMinNew |
|
787 |
width:(xMaxNew - xMinNew + 1) |
|
788 |
height:(yMaxNew - yMinNew + 1) |
|
789 |
||
790 |
"Created: / 7.9.1998 / 14:25:52 / cg" |
|
791 |
"Modified: / 7.9.1998 / 16:35:35 / cg" |
|
792 |
! |
|
793 |
||
2756 | 794 |
darkenImage |
795 |
self makeUndo. |
|
796 |
self image: (image copy darkened). |
|
797 |
self setModified. |
|
798 |
! |
|
799 |
||
632 | 800 |
fillAt: aPoint |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
801 |
"perform a flood-fill with the currently selected color" |
627 | 802 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
803 |
windowGroup withExecuteCursorDo:[ |
1693 | 804 |
|filledPoints clr| |
1002 | 805 |
|
1693 | 806 |
(clr := self selectedColor) notNil ifTrue:[ |
807 |
self updateActivity:'Flood filling - press CTRL-y to abort ...'. |
|
808 |
[ |
|
2349 | 809 |
image floodFillAt: aPoint//magnification withColor:clr. |
1693 | 810 |
image restored. |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
811 |
|
2349 | 812 |
self invalidate. |
1693 | 813 |
self changed:#subImageIn with:(image bounds). |
814 |
||
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
815 |
self setModified. |
1693 | 816 |
] valueOnUnwindDo:[ |
817 |
self updateActivity:'Flood fill aborted.' |
|
818 |
]. |
|
819 |
]. |
|
820 |
self updateActivity:'' |
|
632 | 821 |
] |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
822 |
|
1693 | 823 |
"Modified: / 10.2.2000 / 23:40:58 / cg" |
632 | 824 |
! |
825 |
||
826 |
filledBoxAt: aPoint |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
827 |
"fill a rectangular area with the currently selected color" |
632 | 828 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
829 |
|choosedBox imageBox clr| |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
830 |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
831 |
(clr := self selectedColor) notNil ifTrue:[ |
1693 | 832 |
choosedBox := self dragRectangleStartingAt: aPoint emphasis: #filledBox. |
833 |
imageBox := choosedBox origin//magnification extent: (choosedBox extent//magnification). |
|
834 |
image fillRectangle:imageBox withColor:clr. |
|
835 |
image restored. |
|
836 |
self redraw: (choosedBox expandedBy: 1). |
|
837 |
||
838 |
self changed:#subImageIn with:(imageBox expandedBy: 1). |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
839 |
self setModified. |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
840 |
] |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
841 |
|
1693 | 842 |
"Modified: / 10.2.2000 / 23:37:04 / cg" |
632 | 843 |
! |
844 |
||
636 | 845 |
flipHorizontal |
846 |
||
995 | 847 |
self makeUndo. |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
848 |
self image: image copy flipHorizontal. |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
849 |
self setModified. |
636 | 850 |
! |
851 |
||
852 |
flipVertical |
|
853 |
||
995 | 854 |
self makeUndo. |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
855 |
self image: image copy flipVertical. |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
856 |
self setModified. |
636 | 857 |
! |
858 |
||
1706 | 859 |
magnifyImageTo:newSize |
860 |
self makeUndo. |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
861 |
self image: (image magnifiedBy: newSize/image extent). |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
862 |
self setModified. |
636 | 863 |
! |
864 |
||
1992 | 865 |
makeBorderedImageX:newX y:newY width:newWidth height:newHeight |
866 |
|newImage oldWidth oldHeight| |
|
867 |
||
868 |
oldWidth := image width. |
|
869 |
oldHeight := image height. |
|
870 |
||
871 |
newImage := image class width:newWidth height:newHeight depth:image depth. |
|
872 |
newImage photometric:image photometric. |
|
873 |
newImage colorMap:image colorMap copy. |
|
874 |
newImage bits:(ByteArray new:(newImage bytesPerRow * newHeight)). |
|
875 |
||
876 |
image mask notNil |
|
877 |
ifTrue:[ |
|
878 |
|newMaskImage| |
|
879 |
||
880 |
newMaskImage := Depth1Image width:newWidth height:newHeight. |
|
881 |
newMaskImage photometric: image mask photometric. |
|
882 |
newMaskImage colorMap: image mask colorMap copy. |
|
883 |
newMaskImage bits:(ByteArray new: newMaskImage bytesPerRow * newHeight). |
|
884 |
newImage mask: newMaskImage |
|
885 |
]. |
|
886 |
||
887 |
newImage copyFrom:image x:0 y:0 toX:newX y:newY width:oldWidth height:oldHeight. |
|
888 |
self makeUndo. |
|
889 |
self image:newImage. |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
890 |
self setModified. |
1992 | 891 |
|
892 |
"Created: / 7.9.1998 / 13:00:16 / cg" |
|
893 |
"Modified: / 7.9.1998 / 14:15:32 / cg" |
|
894 |
! |
|
895 |
||
2168 | 896 |
makeBrighter |
897 |
^ self makeNewColorMapByMapping:[:clr | clr lightened]. |
|
898 |
! |
|
899 |
||
900 |
makeDarker |
|
901 |
^ self makeNewColorMapByMapping:[:clr | clr darkened]. |
|
902 |
! |
|
903 |
||
1886 | 904 |
makeGrayScale |
2168 | 905 |
^ self makeNewColorMapByMapping:[:clr | Color brightness:(clr brightness)]. |
906 |
! |
|
907 |
||
908 |
makeInverse |
|
909 |
^ self makeNewColorMapByMapping:[:clr | |
|
910 |
Color red:(100-clr red) green:(100-clr green) blue:(100-clr blue)]. |
|
911 |
! |
|
912 |
||
913 |
makeNewColorMapByMapping:functionOfColor |
|
2566
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
914 |
|xMax yMax map revMap anyChange |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
915 |
newColors newColorArray newImage pixelAction| |
2168 | 916 |
|
1886 | 917 |
anyChange := false. |
918 |
||
919 |
xMax := image width - 1. |
|
920 |
yMax := image height - 1. |
|
921 |
||
922 |
newImage := image class width:image width height:image height depth:image depth. |
|
923 |
newImage photometric:image photometric. |
|
2489 | 924 |
"/ newImage colorMap:(image colorMap copy). |
1886 | 925 |
newImage bits:(ByteArray new:(image bits size)). |
926 |
newImage mask:(image mask copy). |
|
927 |
||
2566
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
928 |
image colorMap notNil ifTrue:[ |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
929 |
newColors := Set new. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
930 |
newColorArray := OrderedCollection new. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
931 |
map := Array new:256. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
932 |
revMap := OrderedCollection new. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
933 |
|
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
934 |
pixelAction := |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
935 |
[:x :y | |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
936 |
|pix n_pix clr n_clr| |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
937 |
|
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
938 |
pix := image pixelAtX:x y:y. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
939 |
(n_pix := map at:pix+1) isNil ifTrue:[ |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
940 |
clr := image colorAtX:x y:y. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
941 |
n_clr := functionOfColor value:clr. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
942 |
(newColors includes:n_clr) ifFalse:[ |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
943 |
newColors add:n_clr. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
944 |
newColorArray add:n_clr. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
945 |
revMap add:pix. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
946 |
map at:pix+1 put:(n_pix := revMap size - 1). |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
947 |
] ifTrue:[ |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
948 |
"/ mhmh - multiple pixels mapped to the same color |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
949 |
n_pix := (newColorArray indexOf:n_clr) - 1. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
950 |
map at:pix+1 put:n_pix. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
951 |
] |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
952 |
]. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
953 |
newImage pixelAtX:x y:y put:n_pix. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
954 |
]. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
955 |
] ifFalse:[ |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
956 |
pixelAction := |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
957 |
[:x :y | |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
958 |
|
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
959 |
|clr n_clr| |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
960 |
|
1886 | 961 |
clr := image colorAtX:x y:y. |
2168 | 962 |
n_clr := functionOfColor value:clr. |
2566
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
963 |
newImage colorAtX:x y:y put:n_clr. |
1886 | 964 |
]. |
2566
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
965 |
]. |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
966 |
|
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
967 |
0 to:yMax do:[:y | |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
968 |
0 to:xMax do:[:x | |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
969 |
pixelAction value:x value:y |
1886 | 970 |
] |
971 |
]. |
|
972 |
||
2566
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
973 |
image colorMap notNil ifTrue:[ |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
974 |
newImage colorMap:(MappedPalette withColors:newColorArray). |
d0894c5f6d4d
allow image processing of trueColor images
Claus Gittinger <cg@exept.de>
parents:
2556
diff
changeset
|
975 |
]. |
1886 | 976 |
self makeUndo. |
977 |
self image:newImage. |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
978 |
self setModified. |
1886 | 979 |
^ true |
980 |
! |
|
981 |
||
1121 | 982 |
makeSubImageX:oldX y:oldY width:newWidth height:newHeight |
983 |
|newImage| |
|
984 |
||
985 |
newImage := image class width:newWidth height:newHeight depth:image depth. |
|
986 |
newImage photometric:image photometric. |
|
987 |
newImage colorMap:image colorMap copy. |
|
988 |
newImage bits:(ByteArray new:(newImage bytesPerRow * newHeight)). |
|
989 |
||
990 |
image mask notNil |
|
991 |
ifTrue:[ |
|
992 |
|newMaskImage| |
|
993 |
||
994 |
newMaskImage := Depth1Image width:newWidth height:newHeight. |
|
995 |
newMaskImage photometric: image mask photometric. |
|
996 |
newMaskImage colorMap: image mask colorMap copy. |
|
997 |
newMaskImage bits:(ByteArray new: newMaskImage bytesPerRow * newHeight). |
|
998 |
newImage mask: newMaskImage |
|
999 |
]. |
|
1000 |
||
1001 |
newImage copyFrom:image x:oldX y:oldY toX:0 y:0 width:newWidth height:newHeight. |
|
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2534
diff
changeset
|
1002 |
self image:newImage scroll:false. |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1003 |
self setModified. |
1121 | 1004 |
|
1005 |
"Created: / 7.9.1998 / 13:00:16 / cg" |
|
1006 |
"Modified: / 7.9.1998 / 14:15:32 / cg" |
|
1007 |
! |
|
1008 |
||
636 | 1009 |
negativeImage |
1010 |
||
995 | 1011 |
self makeUndo. |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1012 |
self image: (image copy bits:(image bits invert)). |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1013 |
self setModified. |
636 | 1014 |
! |
1015 |
||
1016 |
pasteAt: aPoint |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1017 |
"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
|
1018 |
|
2135 | 1019 |
self pasteAt:aPoint mode:nil. |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1020 |
! |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1021 |
|
2135 | 1022 |
pasteAt: aPoint mode:modeSymbol |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1023 |
"paste the image in the clipboard at aPoint" |
636 | 1024 |
|
1986
630db3277f10
support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents:
1980
diff
changeset
|
1025 |
|answer anyColorMissing choosedBox imagePoint imgX imgY copiedImage imageBox newColorMap |
2764 | 1026 |
existingColors newColors allColors currentColorMap newColormap anyColorAdded oldColorMap| |
1888 | 1027 |
|
2440 | 1028 |
Object errorSignal handle:[:ex| |
1246 | 1029 |
ex signal == Image unrepresentableColorSignal ifFalse:[ |
1030 |
ex reject |
|
1031 |
]. |
|
1032 |
self undo. |
|
1033 |
self warn: 'Paste failed !!\Increasing the images depth might help.' withCRs. |
|
1823 | 1034 |
] do: [ |
1246 | 1035 |
windowGroup withExecuteCursorDo:[ |
1036 |
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
|
1037 |
|
1246 | 1038 |
imagePoint := choosedBox origin//magnification. |
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1039 |
|
1246 | 1040 |
copiedImage := Clipboard copy. |
1987 | 1041 |
|
2440 | 1042 |
true "/ image photometric == #palette |
1888 | 1043 |
ifTrue:[ |
1246 | 1044 |
"/ for all colors in the pasted image, |
1045 |
"/ check, if its in the colormap of the |
|
1046 |
"/ target image. |
|
995 | 1047 |
|
2764 | 1048 |
anyColorMissing := anyColorAdded := false. |
1049 |
oldColorMap := image colorMap. |
|
1050 |
oldColorMap notNil ifTrue:[ |
|
1051 |
newColorMap := oldColorMap asOrderedCollection. |
|
1957
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1052 |
copiedImage usedValues do:[:pixel | |
2764 | 1053 |
|pastedColor | |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1054 |
|
1957
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1055 |
pastedColor := copiedImage colorFromValue:pixel. |
2764 | 1056 |
|
1057 |
(newColorMap detect: [:clr| clr = pastedColor] ifNone: nil) isNil |
|
2440 | 1058 |
ifTrue:[ |
2764 | 1059 |
newColorMap size < (1 bitShift:image depth) ifTrue:[ |
1957
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1060 |
"/ add to colormap |
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1061 |
newColorMap add:pastedColor. |
2764 | 1062 |
anyColorAdded := true. |
1957
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1063 |
"/ Transcript showCR:'adding color:' , pastedColor displayString , ' to targets colorMap'. |
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1064 |
] ifFalse:[ |
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1065 |
"/ Transcript showCR:'color:' , pastedColor displayString , ' not found in targets colorMap'. |
1987 | 1066 |
"/ copiedImage colorMap notNil ifTrue:[ |
1067 |
"/ copiedImage colorMap at: pixel+1 put: Color black. |
|
1068 |
"/ ]. |
|
1957
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1069 |
anyColorMissing := true. |
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1070 |
] |
1246 | 1071 |
] |
1957
9a4347986d96
paste with non-colormap image (i.e. truecolor).
Claus Gittinger <cg@exept.de>
parents:
1903
diff
changeset
|
1072 |
]. |
1246 | 1073 |
]. |
2764 | 1074 |
|
1888 | 1075 |
anyColorMissing ifTrue:[ |
1076 |
answer := Dialog |
|
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1077 |
confirmWithCancel:'Some color(s) cannot be represented (colorMap full).\Use nearest or compute colorMap ?' withCRs |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1078 |
labels:#( 'Cancel' 'New ColorMap' 'Use Nearest' ) |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1079 |
values:#( nil new nearest) |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1080 |
default:3. |
1888 | 1081 |
|
1082 |
answer isNil ifTrue:[^ self]. |
|
1986
630db3277f10
support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents:
1980
diff
changeset
|
1083 |
|
630db3277f10
support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents:
1980
diff
changeset
|
1084 |
currentColorMap := image colorMap. |
1987 | 1085 |
imgX := imagePoint x. |
1086 |
imgY := imagePoint y. |
|
1986
630db3277f10
support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents:
1980
diff
changeset
|
1087 |
|
1888 | 1088 |
answer == #nearest ifTrue:[ |
1089 |
0 to:copiedImage height-1 do:[:y | |
|
1090 |
0 to:copiedImage width-1 do:[:x | |
|
1091 |
|clr n_clr| |
|
1092 |
||
1987 | 1093 |
(copiedImage maskAtX:x y:y) == 0 ifTrue:[ |
1094 |
image mask isNil ifTrue:[ |
|
1095 |
image createMask. |
|
1096 |
]. |
|
1097 |
image maskAtX:imgX+x y:imgY+y put:0. |
|
1098 |
] ifFalse:[ |
|
2582 | 1099 |
clr := copiedImage colorAtX:x y:y. |
1987 | 1100 |
n_clr := clr nearestIn:currentColorMap. |
2582 | 1101 |
image colorAtX:imgX+x y:imgY+y put:n_clr |
1987 | 1102 |
] |
1888 | 1103 |
] |
1104 |
]. |
|
1987 | 1105 |
image restored. |
1106 |
self redraw: (imageBox := (imagePoint * magnification extent: (Clipboard extent * magnification)) expandedBy: 1@1). |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1107 |
self setModified. |
1987 | 1108 |
^ self. |
2135 | 1109 |
]. |
1110 |
answer == #new ifTrue:[ |
|
1111 |
existingColors := image usedValues asIdentitySet. |
|
1112 |
newColors := copiedImage usedValues. |
|
1113 |
allColors := existingColors addAll:newColors. |
|
1114 |
allColors size > (1 bitShift:image depth) ifTrue:[ |
|
1115 |
self warn:'Sorry: too many colors - unimplemented function'. |
|
1116 |
self undo. |
|
1986
630db3277f10
support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents:
1980
diff
changeset
|
1117 |
^ self. |
630db3277f10
support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents:
1980
diff
changeset
|
1118 |
]. |
2135 | 1119 |
|
1120 |
newColormap := OrderedCollection new. |
|
1121 |
newColormap addAll:image usedColors. |
|
1122 |
newColormap addAll:copiedImage usedColors. |
|
1123 |
"/ translate image to use new colorMap... |
|
1124 |
||
1125 |
"/ translate image to use new colors ... |
|
1126 |
0 to:image height-1 do:[:y | |
|
1127 |
0 to:image width-1 do:[:x | |
|
1128 |
|clr n_idx| |
|
1129 |
||
1130 |
(image maskAtX:x y:y) == 1 ifTrue:[ |
|
2582 | 1131 |
clr := image colorAtX:x y:y. |
2135 | 1132 |
n_idx := newColormap indexOf:clr. |
1133 |
image pixelAtX:x y:y put:n_idx-1. |
|
1134 |
] |
|
1135 |
] |
|
1136 |
]. |
|
1137 |
image colorMap:newColormap. |
|
1138 |
currentColorMap := newColormap. |
|
1139 |
||
1140 |
"/ paste new image... |
|
1141 |
0 to:copiedImage height-1 do:[:y | |
|
1142 |
0 to:copiedImage width-1 do:[:x | |
|
1143 |
|clr idx| |
|
1144 |
||
1145 |
(copiedImage maskAtX:x y:y) == 1 |
|
1146 |
ifTrue:[ |
|
2582 | 1147 |
clr := copiedImage colorAtX:x y:y. |
2135 | 1148 |
idx := currentColorMap indexOf:clr. |
1149 |
idx == 0 ifTrue:[ |
|
1150 |
currentColorMap add:clr. |
|
1151 |
idx := currentColorMap size. |
|
1152 |
idx > (1 bitShift:image depth) ifTrue:[ |
|
1153 |
self warn:'Sorry: too many colors'. |
|
1154 |
self undo. |
|
1155 |
^ self. |
|
1156 |
]. |
|
1157 |
]. |
|
1158 |
image pixelAtX:imgX+x y:imgY+y put:idx-1. |
|
1159 |
image maskAtX:imgX+x y:imgY+y put:1. |
|
1160 |
] |
|
1161 |
] |
|
1162 |
]. |
|
1163 |
image restored. |
|
1164 |
self redraw: (imageBox := (imagePoint * magnification extent: (Clipboard extent * magnification)) expandedBy: 1@1). |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1165 |
self setModified. |
1888 | 1166 |
^ self. |
1167 |
]. |
|
2135 | 1168 |
self warn:'Sorry: unimplemented function'. |
1169 |
self undo. |
|
1170 |
^ self. |
|
1888 | 1171 |
]. |
2764 | 1172 |
anyColorAdded ifTrue:[ |
2490
62230519175a
slowly getting rid of the Colormap class
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1173 |
image colorMap:(MappedPalette withColors:newColorMap). |
1246 | 1174 |
]. |
1175 |
]. |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1176 |
|
1246 | 1177 |
copiedImage := image class fromImage: copiedImage. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1178 |
(newColorMap isNil |
2135 | 1179 |
and:[modeSymbol isNil |
1987 | 1180 |
and:[copiedImage mask isNil] ]) ifTrue:[ |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1181 |
"/ use images copy functionality |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1182 |
"/ however, this copies the mask as well, |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1183 |
"/ which is not useful here |
1246 | 1184 |
image copyFrom: copiedImage x:0 y:0 toX: imagePoint x y: imagePoint y width: copiedImage width height: copiedImage height. |
1185 |
] ifFalse:[ |
|
1186 |
imgX := imagePoint x. |
|
1187 |
imgY := imagePoint y. |
|
1028
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
1188 |
|
1246 | 1189 |
0 to:copiedImage height-1 do:[:y | |
1190 |
0 to:copiedImage width-1 do:[:x | |
|
1191 |
|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
|
1192 |
|
1246 | 1193 |
dstX := imgX + x. |
1194 |
dstY := imgY + y. |
|
1195 |
wasMasked := (image maskAtX:dstX y:dstY) == 0. |
|
1196 |
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
|
1197 |
|
1246 | 1198 |
"/ with modeUnder, |
1199 |
"/ only replace, if its either unmasked, |
|
1200 |
"/ or the current drawing color. |
|
2135 | 1201 |
(modeSymbol isNil |
1246 | 1202 |
or:[wasMasked |
2135 | 1203 |
or:[modeSymbol == #withMask]]) |
1246 | 1204 |
ifTrue:[ |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1205 |
newMasked ifFalse:[ |
2764 | 1206 |
image colorAtX:dstX y:dstY put:(copiedImage colorAtX:x y:y). |
1823 | 1207 |
wasMasked ifTrue:[ |
1986
630db3277f10
support pasing 24bit rgb image into an 8-bit palette image
Claus Gittinger <cg@exept.de>
parents:
1980
diff
changeset
|
1208 |
image maskAtX:dstX y:dstY put:1 |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1209 |
]. |
1823 | 1210 |
] ifTrue:[ |
1211 |
wasMasked ifFalse:[ |
|
2135 | 1212 |
modeSymbol == #withMask ifTrue:[ |
1213 |
image maskAtX:dstX y:dstY put:0 |
|
1214 |
] |
|
1823 | 1215 |
] |
1216 |
]. |
|
1987 | 1217 |
]. |
1218 |
||
1246 | 1219 |
] |
1220 |
]. |
|
1221 |
]. |
|
1222 |
image restored. |
|
1223 |
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
|
1224 |
"/ masterApplication imagePreView redraw: (imageBox expandedBy: 1). |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1225 |
self setModified. |
1246 | 1226 |
] |
1028
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
1227 |
] |
4dfe1c6cbc48
fixed paste-drag display (when scrolled)
Claus Gittinger <cg@exept.de>
parents:
1027
diff
changeset
|
1228 |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1229 |
"Modified: / 18.5.1999 / 20:40:37 / cg" |
636 | 1230 |
! |
1231 |
||
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1232 |
pasteUnderAt: aPoint |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1233 |
"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
|
1234 |
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
|
1235 |
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
|
1236 |
|
2135 | 1237 |
self pasteAt:aPoint mode:#under. |
1238 |
! |
|
1239 |
||
1240 |
pasteWithMaskAt: aPoint |
|
1241 |
"paste the image in the clipboard at aPoint. |
|
1242 |
In this mode, both the mask and the image pixel are pasted" |
|
1243 |
||
1244 |
||
1245 |
self pasteAt:aPoint mode:#withMask. |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1246 |
! |
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
1247 |
|
1858 | 1248 |
performSpecialOperationOn:imageBox withColor:clr |
2680 | 1249 |
|operation x0 y0 x1 y1 pixelAction requiredColors missingColors answer| |
1858 | 1250 |
|
1251 |
operation := Dialog |
|
2680 | 1252 |
choose:(resources string:'Which Operation:') |
1253 |
fromList:(resources array:#( |
|
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1254 |
'slightly brightened' |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1255 |
'slightly darkened' |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1256 |
'brightened' |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1257 |
'darkened' |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1258 |
'-' |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1259 |
'greyed' |
1858 | 1260 |
'grey pattern' |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1261 |
'-' |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1262 |
'reversed' |
2680 | 1263 |
)) |
2177 | 1264 |
values:#(slightlyBrightened slightlyDarkened brightened darkened nil greyed greyPattern nil reversed) |
1858 | 1265 |
lines:6 |
1266 |
cancel:nil. |
|
1267 |
||
1268 |
self invalidate. |
|
1269 |
self windowGroup processExposeEvents. |
|
1270 |
||
1271 |
operation isNil ifTrue:[^ false]. |
|
1272 |
||
1273 |
x0 := imageBox left. |
|
1274 |
y0 := imageBox top. |
|
1861 | 1275 |
x1 := imageBox right - 1. |
1276 |
y1 := imageBox bottom -1 . |
|
1858 | 1277 |
|
2177 | 1278 |
operation == #slightlyBrightened ifTrue:[ |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1279 |
pixelAction := [:x :y :clr | clr slightlyLightened]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1280 |
]. |
2177 | 1281 |
operation == #slightlyDarkened ifTrue:[ |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1282 |
pixelAction := [:x :y :clr | clr slightlyDarkened]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1283 |
]. |
2177 | 1284 |
operation == #brightened ifTrue:[ |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1285 |
pixelAction := [:x :y :clr | clr lightened]. |
1858 | 1286 |
]. |
2177 | 1287 |
operation == #darkened ifTrue:[ |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1288 |
pixelAction := [:x :y :clr | clr darkened]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1289 |
]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1290 |
operation == #reversed ifTrue:[ |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1291 |
pixelAction := [:x :y :clr | Color red:(100-clr red) green:(100-clr green) blue:(100-clr blue) ]. |
1858 | 1292 |
]. |
2177 | 1293 |
operation == #greyed ifTrue:[ |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1294 |
pixelAction := [:x :y :clr | clr blendWith:Color grey]. |
1858 | 1295 |
]. |
1296 |
operation == #greyPattern ifTrue:[ |
|
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1297 |
pixelAction := [:x :y :clr | Color grey]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1298 |
]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1299 |
pixelAction isNil ifTrue:[self halt. ^ false]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1300 |
|
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1301 |
"/ compute required colors ... |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1302 |
requiredColors := Set new. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1303 |
self image |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1304 |
colorsFromX:x0 y:y0 toX:x1 y:y1 |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1305 |
do:[:x :y :clr | |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1306 |
requiredColors add:(pixelAction value:x value:y value:clr) |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1307 |
]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1308 |
|
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1309 |
missingColors := requiredColors select:[:clr | (image colorMap includes:clr) not]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1310 |
|
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1311 |
missingColors notEmpty ifTrue:[ |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1312 |
answer := Dialog |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1313 |
confirmWithCancel:'Some color(s) cannot be represented in the images colorMap.\Use nearest or compute colorMap ?' withCRs |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1314 |
labels:#( 'Cancel' 'Add to ColorMap' 'Use Nearest') |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1315 |
values:#( nil add nearest) |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1316 |
default:3. |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1317 |
answer isNil ifTrue:[^ false]. |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1318 |
answer == #add ifTrue:[ |
2680 | 1319 |
missingColors size + image colorMap size > (2 raisedTo:image depth) ifTrue:[ |
1320 |
self warn:'Missing colors cannot be added to images colormap.'. |
|
1321 |
^ false |
|
1322 |
]. |
|
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1323 |
missingColors do:[:eachColor | |
2680 | 1324 |
image colorMap add:eachColor |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1325 |
]. |
2680 | 1326 |
answer := #nearest. |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1327 |
]. |
1858 | 1328 |
]. |
1329 |
||
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1330 |
"/ now, do it |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1331 |
self image |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1332 |
colorsFromX:x0 y:y0 toX:x1 y:y1 |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1333 |
do:[:x :y :clr | |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1334 |
|newClr| |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1335 |
|
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1336 |
newClr := pixelAction value:x value:y value:clr. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1337 |
answer == #nearest ifTrue:[ |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1338 |
newClr := newClr nearestIn:image colorMap |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1339 |
]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1340 |
self image colorAtX:x y:y put:newClr |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1341 |
]. |
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1342 |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1343 |
self setModified. |
2172
737d8733fb01
brightemed, darkened, reverse etc. added to operations.
Claus Gittinger <cg@exept.de>
parents:
2168
diff
changeset
|
1344 |
^ true. |
1858 | 1345 |
! |
1346 |
||
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
1347 |
pointAt:aPoint |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1348 |
"draw a single pixel with the currently selected color" |
636 | 1349 |
|
1246 | 1350 |
|imagePoint clr pix| |
796 | 1351 |
|
1246 | 1352 |
imagePoint := aPoint // magnification. |
1277 | 1353 |
(clr := self selectedColor) isNil ifTrue:[ |
1354 |
pix := self selectedColorIndex |
|
1246 | 1355 |
]. |
2277 | 1356 |
|
1246 | 1357 |
pix notNil ifTrue:[ |
1277 | 1358 |
image colorMap atImageAndMask:imagePoint putValue:pix. |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1359 |
self setModified. |
1277 | 1360 |
] ifFalse:[ |
2277 | 1361 |
"/ clr notNil ifTrue:[ |
1277 | 1362 |
image atImageAndMask:imagePoint put:clr. |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1363 |
self setModified. |
2277 | 1364 |
"/ ] |
1246 | 1365 |
]. |
1277 | 1366 |
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
|
1367 |
|
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
1368 |
"Modified: / 5.9.1998 / 13:25:29 / cg" |
636 | 1369 |
! |
1370 |
||
1374 | 1371 |
reduceColorResolutionBy:numBits |
2534
39f2ebf77c40
colorreduction code moved to image
Claus Gittinger <cg@exept.de>
parents:
2528
diff
changeset
|
1372 |
|newImage| |
2442
8941d3a736a0
oops - color-resolution had a bug with non-palette images
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1373 |
|
8941d3a736a0
oops - color-resolution had a bug with non-palette images
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1374 |
numBits > 7 ifTrue:[ |
8941d3a736a0
oops - color-resolution had a bug with non-palette images
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1375 |
self warn:'Max. number of bits to strip off is 7.'. |
8941d3a736a0
oops - color-resolution had a bug with non-palette images
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1376 |
^ false |
8941d3a736a0
oops - color-resolution had a bug with non-palette images
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1377 |
]. |
2534
39f2ebf77c40
colorreduction code moved to image
Claus Gittinger <cg@exept.de>
parents:
2528
diff
changeset
|
1378 |
newImage := image withColorResolutionReducedBy:numBits. |
39f2ebf77c40
colorreduction code moved to image
Claus Gittinger <cg@exept.de>
parents:
2528
diff
changeset
|
1379 |
newImage isNil ifTrue:[ |
39f2ebf77c40
colorreduction code moved to image
Claus Gittinger <cg@exept.de>
parents:
2528
diff
changeset
|
1380 |
self warn:'Could not reduce color resolution.'. |
39f2ebf77c40
colorreduction code moved to image
Claus Gittinger <cg@exept.de>
parents:
2528
diff
changeset
|
1381 |
^ false. |
1885
5f85501aaea9
reduce color-resolution fixed
Claus Gittinger <cg@exept.de>
parents:
1882
diff
changeset
|
1382 |
]. |
5f85501aaea9
reduce color-resolution fixed
Claus Gittinger <cg@exept.de>
parents:
1882
diff
changeset
|
1383 |
|
1886 | 1384 |
self makeUndo. |
1385 |
self image:newImage. |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1386 |
self setModified. |
1885
5f85501aaea9
reduce color-resolution fixed
Claus Gittinger <cg@exept.de>
parents:
1882
diff
changeset
|
1387 |
^ true |
1374 | 1388 |
! |
1389 |
||
1706 | 1390 |
resizeImageTo:newSize |
1391 |
||
1392 |
|newImage newMaskImage| |
|
1393 |
||
1394 |
newImage := image class width: newSize x height: newSize y depth: image depth. |
|
1395 |
newImage photometric:image photometric. |
|
1396 |
newImage colorMap:image colorMap copy. |
|
1397 |
newImage bits: (ByteArray new: newImage bytesPerRow * newSize y). |
|
636 | 1398 |
|
1706 | 1399 |
image mask notNil ifTrue:[ |
1400 |
newMaskImage := Depth1Image width: newSize x height: newSize y. |
|
1401 |
newMaskImage photometric: image mask photometric. |
|
1402 |
newMaskImage colorMap: image mask colorMap copy. |
|
1403 |
newMaskImage bits:(ByteArray new: newMaskImage bytesPerRow * newSize y). |
|
1404 |
newImage mask: newMaskImage |
|
1405 |
]. |
|
636 | 1406 |
|
1706 | 1407 |
newImage copyFrom:image x:0 y:0 toX:0 y:0 width: (image width min:newSize x) height: (image height min:newSize y). |
1408 |
self makeUndo. |
|
1409 |
self image: newImage. |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1410 |
self setModified. |
636 | 1411 |
! |
1412 |
||
1706 | 1413 |
rotateImageBy:rotation |
1414 |
"rotate by (degrees)" |
|
636 | 1415 |
|
1706 | 1416 |
Object errorSignal handle:[:ex| |
1417 |
self warn: 'Image rotation failed!!\' withCRs, 'Increaing the image depth could help.' |
|
1418 |
] do:[ |
|
1419 |
self makeUndo. |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1420 |
self image: (image hardRotated: rotation). |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1421 |
self setModified. |
686 | 1422 |
] |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1423 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1424 |
"Modified: / 29.7.1998 / 18:21:14 / cg" |
636 | 1425 |
! |
1426 |
||
2086 | 1427 |
shiftImageHorizontal:shiftH vertical:shiftV |
2489 | 1428 |
self shiftImageHorizontal:shiftH vertical:shiftV wrap:false |
1429 |
! |
|
1430 |
||
1431 |
shiftImageHorizontal:shiftH vertical:shiftV wrap:doWrap |
|
1432 |
"shift the pixels; |
|
1433 |
shift<0 is left-shift/up-shift; shift>0 is right-shift/down-shift; |
|
1434 |
doWrap controls if shifted-out pixels are to be shifted in at the opposite side. |
|
1435 |
i.e.: |
|
1436 |
0123456789 -> 3456789789 (shift: -3) 0123456789 -> 0120123456 (shift:3) |
|
1437 |
or, with wrap: |
|
1438 |
0123456789 -> 3456789012 (shift: -3) 0123456789 -> 7890123456 (shift:3) |
|
1439 |
" |
|
1440 |
||
1441 |
|newImage| |
|
1442 |
||
1443 |
newImage := self shifted:image horizontal:shiftH vertical:shiftV wrap:doWrap. |
|
1444 |
self image:newImage. |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1445 |
self setModified. |
2489 | 1446 |
! |
1447 |
||
1448 |
shifted:image horizontal:shiftH vertical:shiftV wrap:doWrap |
|
1449 |
"shift the pixels; |
|
1450 |
shift<0 is left-shift/up-shift; shift>0 is right-shift/down-shift; |
|
1451 |
doWrap controls if shifted-out pixels are to be shifted in at the opposite side. |
|
1452 |
i.e.: |
|
1453 |
0123456789 -> 3456789789 (shift: -3) 0123456789 -> 0120123456 (shift:3) |
|
1454 |
or, with wrap: |
|
1455 |
0123456789 -> 3456789012 (shift: -3) 0123456789 -> 7890123456 (shift:3) |
|
1456 |
" |
|
1457 |
||
2086 | 1458 |
|w h srcX srcY dstX dstY newImage| |
1459 |
||
2489 | 1460 |
doWrap ifTrue:[ |
1461 |
"/ if wrapping, split into two operations to make wrap-code below simpler. |
|
1462 |
||
1463 |
shiftH ~~ 0 ifTrue:[ |
|
1464 |
shiftV ~~ 0 ifTrue:[ |
|
1465 |
newImage := self shifted:image horizontal:shiftH vertical:0 wrap:doWrap. |
|
1466 |
newImage := self shifted:newImage horizontal:0 vertical:shiftV wrap:doWrap. |
|
1467 |
^ newImage |
|
1468 |
]. |
|
1469 |
]. |
|
1470 |
]. |
|
1471 |
(shiftV == 0 and:[shiftH == 0]) ifTrue:[ |
|
1472 |
^ image |
|
1473 |
]. |
|
1474 |
||
2086 | 1475 |
w := image width. |
1476 |
h := image height. |
|
1477 |
||
1478 |
newImage := image copy. |
|
1479 |
||
1480 |
srcX := srcY := dstX := dstY := 0. |
|
1481 |
shiftH < 0 ifTrue:[ |
|
1482 |
srcX := shiftH negated |
|
1483 |
] ifFalse:[ |
|
1484 |
dstX := shiftH |
|
1485 |
]. |
|
1486 |
shiftV < 0 ifTrue:[ |
|
1487 |
srcY := shiftV negated |
|
1488 |
] ifFalse:[ |
|
1489 |
dstY := shiftV |
|
1490 |
]. |
|
1491 |
||
1492 |
newImage copyFrom:image x:srcX y:srcY toX:dstX y:dstY width:w-shiftH abs height:h-shiftV abs. |
|
1493 |
||
2489 | 1494 |
doWrap ifTrue:[ |
1495 |
srcX := srcY := dstX := dstY := 0. |
|
1496 |
||
1497 |
"/ already simplified - see above |
|
1498 |
shiftH ~~ 0 ifTrue:[ |
|
1499 |
"/ shiftV known to be 0 |
|
1500 |
shiftH < 0 ifTrue:[ |
|
1501 |
dstX := w-1-shiftH negated |
|
1502 |
] ifFalse:[ |
|
1503 |
srcX := w-1-shiftH |
|
1504 |
]. |
|
1505 |
w := shiftH abs. |
|
1506 |
] ifFalse:[ |
|
1507 |
"/ shiftH known to be 0 |
|
1508 |
shiftV < 0 ifTrue:[ |
|
1509 |
dstY := h-1-shiftV negated |
|
1510 |
] ifFalse:[ |
|
1511 |
srcY := h-1-shiftV |
|
1512 |
]. |
|
1513 |
h := shiftV abs. |
|
1514 |
]. |
|
1515 |
newImage copyFrom:image x:srcX y:srcY toX:dstX y:dstY width:w height:h. |
|
1516 |
^ newImage |
|
1517 |
]. |
|
1518 |
||
1519 |
^ newImage. |
|
2086 | 1520 |
|
1521 |
"Created: / 7.9.1998 / 13:00:16 / cg" |
|
1522 |
"Modified: / 7.9.1998 / 14:15:32 / cg" |
|
1523 |
! |
|
1524 |
||
1858 | 1525 |
specialOperationAt: aPoint |
1526 |
"special operation on a rectangular area" |
|
1527 |
||
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1528 |
|choosedBox imageBox| |
1858 | 1529 |
|
1530 |
choosedBox := self dragRectangleStartingAt: aPoint emphasis: #filledBox. |
|
1531 |
imageBox := choosedBox origin//magnification extent: (choosedBox extent//magnification). |
|
1532 |
||
1533 |
(self performSpecialOperationOn:imageBox withColor:self selectedColor) ifFalse:[ |
|
1534 |
^ self |
|
1535 |
]. |
|
1536 |
||
1537 |
image restored. |
|
1861 | 1538 |
self invalidate. "/ : (choosedBox expandedBy: 1). |
1539 |
||
1540 |
"/ self redraw: (choosedBox expandedBy: 1). |
|
1858 | 1541 |
|
1542 |
"/ "/ cg: what a kludge - please change to use a valueHolder, |
|
1543 |
"/ "/ which gets the information ... |
|
1544 |
"/ masterApplication imagePreView redraw: (imageBox expandedBy: 1). |
|
1545 |
||
1546 |
"/ cg: still a kludge - but less ugly |
|
1547 |
self changed:#subImageIn with:(imageBox expandedBy: 1). |
|
1548 |
||
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1549 |
self setModified. |
1858 | 1550 |
! |
1551 |
||
636 | 1552 |
undo |
1553 |
||
1693 | 1554 |
undoImages notEmpty ifTrue:[ |
1374 | 1555 |
windowGroup withExecuteCursorDo:[ |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1556 |
self clearModified. |
1374 | 1557 |
self image: undoImages removeLast. |
1693 | 1558 |
self changed:#image. |
1374 | 1559 |
] |
636 | 1560 |
] |
1038
6c0bb03e88a1
no need to invalidate after assign of new image.
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
1561 |
|
1693 | 1562 |
"Modified: / 10.2.2000 / 23:21:24 / cg" |
627 | 1563 |
! ! |
1564 |
||
1565 |
!ImageEditView methodsFor:'image setting'! |
|
1566 |
||
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2534
diff
changeset
|
1567 |
image:anImage scroll:doScroll |
1256 | 1568 |
|retVal fileName| |
627 | 1569 |
|
1256 | 1570 |
anImage isImage ifTrue:[ |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1571 |
true "(image isNil or: [self checkModified])" ifTrue: [ |
1256 | 1572 |
image notNil ifTrue: [ |
1573 |
fileName := image fileName. |
|
1574 |
anImage fileName isNil ifTrue: [anImage fileName: fileName]. |
|
1575 |
]. |
|
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2534
diff
changeset
|
1576 |
super image:anImage scroll:doScroll. |
1256 | 1577 |
retVal := self. |
1578 |
]. |
|
1579 |
] ifFalse: [ |
|
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2534
diff
changeset
|
1580 |
super image:nil scroll:true. |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1581 |
]. |
1763
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1706
diff
changeset
|
1582 |
self changed:#image. |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1583 |
self setModified. |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1584 |
self updateImageInfo: self imageInfoString. |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1585 |
^ retVal |
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1586 |
|
1693 | 1587 |
"Modified: / 10.2.2000 / 23:33:12 / cg" |
627 | 1588 |
! |
1589 |
||
1590 |
loadFromFile: aFileName |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1591 |
|imageFromFile| |
624 | 1592 |
|
676 | 1593 |
aFileName isNil ifTrue: [^nil]. |
1774 | 1594 |
|
1595 |
Object errorSignal handle:[:exeption| |
|
1596 |
self warn: exeption errorString. |
|
1597 |
^nil |
|
1598 |
] do:[ |
|
1599 |
(imageFromFile := Image fromFile: aFileName) notNil |
|
1600 |
ifTrue:[ |
|
1601 |
self releaseUndos. |
|
1602 |
self image: imageFromFile. |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1603 |
self clearModified. |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1604 |
"/ imageReaderClass := ImageReader allSubclasses |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1605 |
"/ detect: [:cls| cls isValidImageFile: aFileName asFilename pathName] |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1606 |
"/ ifNone: [self error: 'Unknown image file format!!'] |
1774 | 1607 |
] ifFalse:[ |
1608 |
self error: 'Not an image file (or unrecognized format) !!' |
|
1609 |
] |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1610 |
]. |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1611 |
^ imageFromFile |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1612 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
1613 |
"Modified: / 29.7.1998 / 18:09:13 / cg" |
624 | 1614 |
! |
255 | 1615 |
|
633 | 1616 |
loadFromMessage: aMessage |
1617 |
||
1781 | 1618 |
(self resourceMessage: aMessage) isNil ifTrue:[ |
1619 |
^ nil |
|
633 | 1620 |
]. |
624 | 1621 |
|
633 | 1622 |
^self loadfromClass: resourceClass andSelector: resourceSelector |
1623 |
||
1624 |
||
1625 |
! |
|
1626 |
||
1627 |
loadfromClass: aClassOrSymbol andSelector: aStringOrSymbol |
|
678 | 1628 |
|aClass| |
1629 |
||
627 | 1630 |
imageReaderClass := nil. |
1631 |
self resourceClass: aClassOrSymbol. |
|
1632 |
self resourceSelector: aStringOrSymbol. |
|
678 | 1633 |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1634 |
(aClass := Smalltalk at: resourceClass) isBehavior ifTrue:[ |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1635 |
(aClass class implements: resourceSelector) ifTrue:[ |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1636 |
image := aClass perform: resourceSelector. |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1637 |
] ifFalse:[ |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1638 |
(aClass implements: resourceSelector) ifTrue:[ |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1639 |
image := aClass basicNew perform: resourceSelector |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1640 |
] |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1641 |
]. |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1642 |
image notNil ifTrue:[ |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1643 |
image := image copy. |
2030
3f5e2b7ec36a
partial support for image-specs on the instance side
Claus Gittinger <cg@exept.de>
parents:
2021
diff
changeset
|
1644 |
self releaseUndos. |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1645 |
self image: image. |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1646 |
self clearModified. |
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
1647 |
^ image |
2030
3f5e2b7ec36a
partial support for image-specs on the instance side
Claus Gittinger <cg@exept.de>
parents:
2021
diff
changeset
|
1648 |
]. |
3f5e2b7ec36a
partial support for image-specs on the instance side
Claus Gittinger <cg@exept.de>
parents:
2021
diff
changeset
|
1649 |
]. |
3f5e2b7ec36a
partial support for image-specs on the instance side
Claus Gittinger <cg@exept.de>
parents:
2021
diff
changeset
|
1650 |
^ nil |
161 | 1651 |
! ! |
1652 |
||
2511 | 1653 |
!ImageEditView methodsFor:'image-dragging & info'! |
1654 |
||
1655 |
dragRectangleStartingAt: aPointIn emphasis: emphasis |
|
1656 |
"drag a rectangle (filled or unfilled)" |
|
1657 |
||
1658 |
|currentPoint currentExtent firstPoint lastCurrentPoint gridCorrection |
|
1659 |
mp lastMp p whichQuarter scrollX scrollY aPoint| |
|
1660 |
||
1661 |
aPoint := aPointIn. |
|
1662 |
firstPoint := currentPoint := lastCurrentPoint := aPoint//magnification*magnification. |
|
1663 |
magnification >= GridMagnificationLimit ifFalse: [gridCorrection := 0] ifTrue: [gridCorrection := 1]. |
|
1664 |
||
1665 |
[device anyButtonPressed] whileTrue: [ |
|
1666 |
mp := self sensor mousePoint. |
|
1667 |
mp = lastMp ifTrue:[ |
|
1668 |
Delay waitForSeconds:0.05 |
|
1669 |
] ifFalse:[ |
|
1670 |
lastMp := mp. |
|
1671 |
mp := device translatePoint:mp fromView:nil toView:self. |
|
1672 |
"/ mp is a device coordinate here ... |
|
1673 |
scrollX := 0. |
|
1674 |
mp x > width ifTrue:[ |
|
1675 |
scrollX := mp x - width. |
|
1676 |
] ifFalse:[ |
|
1677 |
mp x < 0 ifTrue:[ |
|
1678 |
scrollX := mp x. |
|
1679 |
] |
|
1680 |
]. |
|
1681 |
scrollY := 0. |
|
1682 |
mp y > height ifTrue:[ |
|
1683 |
scrollY := mp y - height. |
|
1684 |
] ifFalse:[ |
|
1685 |
mp y < 0 ifTrue:[ |
|
1686 |
scrollY := mp y. |
|
1687 |
] |
|
1688 |
]. |
|
1689 |
(scrollX + scrollY) ~~ 0 ifTrue:[ |
|
1690 |
self scrollTo:(self viewOrigin + (scrollX @ scrollY)). |
|
1691 |
lastMp := nil. |
|
1692 |
]. |
|
1693 |
||
1694 |
mp := mp + self viewOrigin. |
|
1695 |
"/ mp is now a logical coordinate. |
|
1696 |
||
1697 |
currentPoint := (0@0) max: (image extent * magnification min: (p := mp)). |
|
1698 |
currentPoint := currentPoint//magnification*magnification. |
|
1699 |
currentExtent := (firstPoint - currentPoint) abs. |
|
1700 |
whichQuarter := (firstPoint x - currentPoint x) > 0 |
|
1701 |
ifTrue: [(firstPoint y - currentPoint y) > 0 ifTrue: ["4"1@1] ifFalse: ["3"1@0]] |
|
1702 |
ifFalse: [(firstPoint y - currentPoint y) > 0 ifTrue: ["1"0@1] ifFalse: ["2"0@0]]. |
|
1703 |
||
1704 |
self drawCursorAt: p withLabel: |
|
1705 |
((firstPoint//magnification - whichQuarter + 1) printString, |
|
1706 |
' to: ', |
|
1707 |
(currentPoint//magnification + whichQuarter) printString), |
|
1708 |
' (extent: ', |
|
1709 |
(currentExtent//magnification) printString, ')'. |
|
1710 |
||
1711 |
currentPoint ~= lastCurrentPoint ifTrue:[ |
|
1712 |
emphasis = #inverseFilledBox ifTrue: [ |
|
1713 |
self redraw: ((firstPoint min: lastCurrentPoint) - 1 extent: (firstPoint - lastCurrentPoint) abs + 2). |
|
1714 |
self xoring: [self fillRectangle: ((firstPoint min: currentPoint) + margin extent: currentExtent - gridCorrection)] |
|
1715 |
]. |
|
1716 |
emphasis = #box |
|
1717 |
ifTrue:[ |
|
1718 |
|origin extent lineWidthY lineWidthX| |
|
1719 |
origin := (firstPoint min: lastCurrentPoint) - 1. |
|
1720 |
extent := (firstPoint - lastCurrentPoint) abs + 2. |
|
1721 |
lineWidthY := extent y min: (magnification y + 2). |
|
1722 |
lineWidthX := extent x min: (magnification x + 2). |
|
1723 |
self redraw: (origin extent: (extent x@lineWidthY)). |
|
1724 |
self redraw: ((origin x@(origin y + extent y - lineWidthY)) extent: (extent x@lineWidthY)). |
|
1725 |
self redraw: ((origin x@(origin y + lineWidthY)) extent: (lineWidthX@(0 max: (extent y - (lineWidthY * 2))))). |
|
1726 |
self redraw: (((origin x + extent x - lineWidthX)@(origin y + lineWidthY)) extent: (lineWidthX@(extent y - (lineWidthY * 2)))). |
|
1727 |
self selectedColor ~= Color noColor |
|
1728 |
ifTrue: [self paint: self selectedColor] |
|
1729 |
ifFalse: [self paint: self viewBackground]. |
|
1730 |
origin := (firstPoint min: currentPoint) + margin. |
|
1731 |
extent := currentExtent - gridCorrection. |
|
1732 |
lineWidthY := extent y min: magnification y. |
|
1733 |
lineWidthX := extent x min: magnification x. |
|
1734 |
(lineWidthY > 0 and: [lineWidthX > 0]) |
|
1735 |
ifTrue:[ |
|
1736 |
self fillRectangle: (origin extent: (extent x@lineWidthY)). |
|
1737 |
self fillRectangle: ((origin x@(origin y + extent y - lineWidthY)) extent: (extent x@lineWidthY)). |
|
1738 |
self fillRectangle: ((origin x@(origin y + lineWidthY)) extent: (lineWidthX@(0 max: (extent y - (lineWidthY * 2))))). |
|
1739 |
self fillRectangle: (((origin x + extent x - lineWidthX)@(origin y + lineWidthY)) extent: (lineWidthX@(extent y - (lineWidthY * 2)))). |
|
1740 |
] |
|
1741 |
]. |
|
1742 |
emphasis = #filledBox |
|
1743 |
ifTrue:[ |
|
1744 |
self redraw: ((firstPoint min: lastCurrentPoint) - 1 extent: (firstPoint - lastCurrentPoint) abs + 2). |
|
1745 |
self selectedColor ~= Color noColor |
|
1746 |
ifTrue: [self paint: self selectedColor] |
|
1747 |
ifFalse: [self paint: self viewBackground]. |
|
1748 |
self fillRectangle: ((firstPoint min: currentPoint) + margin extent: currentExtent - gridCorrection). |
|
1749 |
]. |
|
1750 |
]. |
|
1751 |
lastCurrentPoint := currentPoint. |
|
1752 |
]. |
|
1753 |
]. |
|
1754 |
||
1755 |
^((0@0) max: (firstPoint min: currentPoint)) extent: (firstPoint - currentPoint) abs |
|
1756 |
||
1757 |
"Created: / 21.8.1998 / 20:17:07 / cg" |
|
1758 |
"Modified: / 10.10.2001 / 14:13:08 / cg" |
|
1759 |
! |
|
1760 |
||
1761 |
drawCursorAt:aPoint |
|
1762 |
|clr imgPoint r g b| |
|
1763 |
||
1764 |
image isNil ifTrue: [ |
|
1765 |
self updateImageInfo: self imageInfoString. |
|
1766 |
self cursor:Cursor stop. |
|
1767 |
^ self |
|
1768 |
]. |
|
1769 |
||
1770 |
imgPoint := aPoint // magnification. |
|
1771 |
((imgPoint x between:0 and:(image width-1)) |
|
1772 |
and:[imgPoint y between:0 and: (image height-1)]) |
|
1773 |
ifFalse:[ |
|
1774 |
self updateImageInfo: self imageInfoString. |
|
1775 |
self cursor:Cursor stop. |
|
1776 |
] ifTrue: [ |
|
1777 |
clr := image colorAt:imgPoint. |
|
1778 |
r := clr redByte. |
|
1779 |
g := clr greenByte. |
|
1780 |
b := clr blueByte. |
|
1781 |
self updateImageInfo: imgPoint printString |
|
1782 |
, ' (r:' |
|
1783 |
, r printString |
|
1784 |
, ' g:' , g printString |
|
1785 |
, ' b:' , b printString |
|
1786 |
, ' #' , (r hexPrintString:2) , (g hexPrintString:2) , (b hexPrintString:2) |
|
1787 |
, ' pixel:' , (image pixelAt:imgPoint) printString |
|
1788 |
, ')'. |
|
1789 |
self cursor:Cursor crossHair |
|
1790 |
]. |
|
1791 |
||
1792 |
"Modified: / 29.7.1998 / 18:26:01 / cg" |
|
1793 |
! |
|
1794 |
||
1795 |
drawCursorAt: aPoint withLabel: aLabel |
|
1796 |
||
1797 |
((0@0 extent: image extent * magnification) containsPoint: aPoint) |
|
1798 |
ifFalse:[self cursor:Cursor stop] |
|
1799 |
ifTrue: [self cursor:Cursor crossHair]. |
|
1800 |
self updateImageInfo: aLabel. |
|
1801 |
||
1802 |
"Modified: / 29.7.1998 / 18:26:04 / cg" |
|
1803 |
! |
|
1804 |
||
1805 |
updateActivity: something |
|
1806 |
|msg| |
|
1807 |
||
1808 |
msg := something printString. |
|
1809 |
||
1810 |
"/ cg: new code: |
|
1811 |
activityInfoHolder notNil ifTrue:[ |
|
1812 |
activityInfoHolder value:msg. |
|
1813 |
]. |
|
1814 |
||
1815 |
"Modified: / 29.7.1998 / 18:41:47 / cg" |
|
1816 |
! |
|
1817 |
||
1818 |
updateImageInfo: something |
|
1819 |
|msg coordLabel| |
|
1820 |
||
1821 |
msg := something printString. |
|
1822 |
||
1823 |
"/ cg: new code: |
|
1824 |
imageInfoHolder notNil ifTrue:[ |
|
1825 |
msg ~= imageInfoHolder value ifTrue:[ |
|
1826 |
imageInfoHolder value:msg. |
|
1827 |
]. |
|
1828 |
^ self |
|
1829 |
]. |
|
1830 |
||
1831 |
"/ "/ cg: what a kludge - please change to use a valueHolder, |
|
1832 |
"/ "/ which gets the coordinate ... |
|
1833 |
"/ |
|
1834 |
"/ (masterApplication respondsTo: #coordLabel) |
|
1835 |
"/ ifTrue:[ |
|
1836 |
"/ coordLabel := masterApplication coordLabel. |
|
1837 |
"/ |
|
1838 |
"/ coordLabel label ~= msg |
|
1839 |
"/ ifTrue:[ |
|
1840 |
"/ coordLabel label: msg. |
|
1841 |
"/ "/ coordLabel redraw |
|
1842 |
"/ ] |
|
1843 |
"/ ] |
|
1844 |
||
1845 |
"Modified: / 29.7.1998 / 19:00:21 / cg" |
|
1846 |
! ! |
|
1847 |
||
1327 | 1848 |
!ImageEditView methodsFor:'initialize / release'! |
1849 |
||
1850 |
destroy |
|
2440 | 1851 |
ClipboardMagnified := Clipboard := nil. |
1327 | 1852 |
LastMagnification := magnification. |
1853 |
||
1854 |
super destroy |
|
1855 |
! |
|
1 | 1856 |
|
161 | 1857 |
initialize |
624 | 1858 |
|
161 | 1859 |
super initialize. |
627 | 1860 |
|
686 | 1861 |
self enableMotionEvents. |
995 | 1862 |
|
1374 | 1863 |
undoImages := List new: MaxUndos. |
1706 | 1864 |
magnification := LastMagnification ? (8@8). |
2747 | 1865 |
modifiedHolder := false asValue. |
627 | 1866 |
mouseKeyColorMode := 1. |
995 | 1867 |
resourceClass := resourceSelector := ''. |
2009
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
1868 |
drawingColorHolders := Array with:(nil asValue) with:(nil asValue). "/ left/right mouse colors |
4f556ff9fec5
pick with SHIFT-click in the mag-view
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
1869 |
drawingPixelHolders := Array with:(nil asValue) with:(nil asValue). "/ left/right mouse colors |
1106 | 1870 |
editMode := #point. |
1 | 1871 |
! ! |
1872 |
||
636 | 1873 |
!ImageEditView methodsFor:'printing & storing'! |
1 | 1874 |
|
1994 | 1875 |
askForFileNameToSave:msg |
1876 |
"ask for a fileName" |
|
1877 |
||
1878 |
|lastFn fn filters| |
|
1879 |
||
1880 |
filters := FileSelectionBrowser saveImageFileNameFilters. |
|
1881 |
lastFn := self image fileName. |
|
1882 |
lastFn isNil ifTrue:[ |
|
1883 |
fn := FileSelectionBrowser |
|
1884 |
request: msg |
|
1885 |
inDirectory: LastSaveDirectory |
|
1886 |
withFileFilters: filters |
|
1887 |
] ifFalse:[ |
|
1888 |
fn := FileSelectionBrowser |
|
1889 |
request: msg |
|
1890 |
fileName: lastFn |
|
1891 |
withFileFilters: filters |
|
1892 |
]. |
|
1893 |
||
1894 |
^ fn |
|
1895 |
! |
|
1896 |
||
724 | 1897 |
loadFromClass |
404 | 1898 |
|
676 | 1899 |
^self loadFromMessage: |
1184 | 1900 |
(ResourceSelectionBrowser |
1901 |
request: 'Load Image From Class' |
|
1902 |
onSuperclass: nil |
|
1903 |
andClass: self resourceClass |
|
1904 |
andSelector: self resourceSelector |
|
1905 |
withResourceTypes: #(image fileImage programImage)) |
|
636 | 1906 |
|
477 | 1907 |
|
161 | 1908 |
! |
1909 |
||
995 | 1910 |
makeUndo |
1911 |
||
1374 | 1912 |
image notNil ifTrue:[ |
1913 |
undoImages size >= MaxUndos ifTrue:[ |
|
1914 |
undoImages removeFirst. |
|
1915 |
]. |
|
1916 |
undoImages add: image copy |
|
995 | 1917 |
] |
1918 |
! |
|
1919 |
||
627 | 1920 |
|
2556 | 1921 |
self printWithMagnification:1 |
1922 |
! |
|
1923 |
||
1924 |
printMagnified |
|
1925 |
self printWithMagnification:magnification |
|
1926 |
! |
|
1927 |
||
1928 |
printWithMagnification:magnification |
|
2555 | 1929 |
|stream| |
1930 |
||
1931 |
image isNil ifTrue:[^ self]. |
|
1932 |
||
1933 |
Printer supportsPostscript ifFalse:[ |
|
1934 |
^ self warn:'No postscript printer configured !!' |
|
1935 |
]. |
|
1936 |
||
1937 |
stream := Printer newNative. |
|
1938 |
stream isNil ifTrue:[ |
|
1939 |
^ self warn:'Cannot open printer stream !!' |
|
1940 |
]. |
|
1941 |
||
1942 |
self withWaitCursorDo:[ |
|
1943 |
|psgc| |
|
1944 |
||
1945 |
psgc := PSGraphicsContext on:stream. |
|
1946 |
psgc displayForm: (image magnifiedBy: magnification) x:0 y:0. |
|
1947 |
psgc close |
|
398
7b7255a4db0d
show a wait cursor while printing
Claus Gittinger <cg@exept.de>
parents:
362
diff
changeset
|
1948 |
] |
624 | 1949 |
! |
1950 |
||
1951 |
save |
|
1952 |
||
632 | 1953 |
self saveImageOrMask: #image. |
1954 |
||
624 | 1955 |
! |
1956 |
||
2239 | 1957 |
save:image imageOrMask:what |
1958 |
"save the image or the mask only (if what == #mask)" |
|
297 | 1959 |
|
2239 | 1960 |
image isNil ifTrue:[ |
1961 |
Dialog warn: 'No image to save!!'. |
|
1962 |
^ self. |
|
1963 |
]. |
|
1964 |
self save:image imageOrMask:what as:image fileName. |
|
627 | 1965 |
! |
297 | 1966 |
|
2239 | 1967 |
save:image imageOrMask:what as:fileNameArg |
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1968 |
"save the image or the mask only (if what == #mask)" |
628 | 1969 |
|
2240 | 1970 |
|fileName fileNameString| |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1971 |
|
2239 | 1972 |
fileName := fileNameArg asFilename. |
1973 |
||
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1974 |
Object errorSignal handle:[:ex| |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1975 |
|msg| |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1976 |
|
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1977 |
ex signal == Image fileCreationErrorSignal ifTrue:[ |
1896 | 1978 |
msg := resources string:'Cannot create file: ''%1''' with:fileName asFilename pathName allBold |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1979 |
] ifFalse:[ |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1980 |
msg := ex errorString. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1981 |
]. |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1982 |
Dialog warn:msg. |
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1983 |
] do:[ |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1984 |
Image informationLostQuerySignal handle:[:ex| |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1985 |
"/ should make those warnings visible ... |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1986 |
(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
|
1987 |
ex proceed. |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1988 |
] |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1989 |
] do:[ |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1990 |
windowGroup withCursor:Cursor write do:[ |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
1991 |
|suff fn| |
1027
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
1992 |
|
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1993 |
image isNil ifTrue:[ |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1994 |
^ self error: 'No image to save!!' |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1995 |
]. |
632 | 1996 |
|
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1997 |
what = #mask ifTrue:[ |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
1998 |
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
|
1999 |
]. |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2000 |
|
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2001 |
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
|
2002 |
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
|
2003 |
imageReaderClass := nil. |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
2004 |
imageReaderClass := MIMETypes imageReaderForSuffix:suff. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2005 |
|
1373
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
2006 |
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
|
2007 |
imageReaderClass := XPMReader. |
2589
10827ba87692
obsolete method calls cleaned up
Claus Gittinger <cg@exept.de>
parents:
2582
diff
changeset
|
2008 |
fileNameString := fileName name , '.xpm'. |
2240 | 2009 |
fileName := fileNameString asFilename. |
2010 |
image fileName:fileNameString. |
|
1373
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
2011 |
Dialog warn:(('Dont know how to write ''.' , suff , '''-files\\Saving in xpm format as ''%1''.') |
2240 | 2012 |
withCRs bindWith:fileNameString allBold). |
1373
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
2013 |
]. |
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
2014 |
(imageReaderClass canRepresent:image) ifFalse:[ |
1991 | 2015 |
imageReaderClass == XPMReader ifTrue:[ |
2016 |
Dialog warn:('Saving in ''.' , suff , '''-format is not supported (or image cannot be represented in this format).\\Please try another format.') withCRs. |
|
2017 |
^ self. |
|
2018 |
]. |
|
1373
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
2019 |
imageReaderClass := XPMReader. |
2589
10827ba87692
obsolete method calls cleaned up
Claus Gittinger <cg@exept.de>
parents:
2582
diff
changeset
|
2020 |
fileNameString := fileName name , '.xpm'. |
2240 | 2021 |
fileName := fileNameString asFilename. |
2022 |
image fileName:fileNameString. |
|
2690
53bc9dc52ce4
allow cancel when saving in wrong format
Claus Gittinger <cg@exept.de>
parents:
2680
diff
changeset
|
2023 |
(Dialog confirm:(('Saving in ''.' , suff , '''-format is not supported (or image cannot be represented in this format).\\Saving in xpm format as ''%1''.') |
53bc9dc52ce4
allow cancel when saving in wrong format
Claus Gittinger <cg@exept.de>
parents:
2680
diff
changeset
|
2024 |
withCRs bindWith:fileNameString allBold)) ifFalse:[ |
53bc9dc52ce4
allow cancel when saving in wrong format
Claus Gittinger <cg@exept.de>
parents:
2680
diff
changeset
|
2025 |
^ self. |
53bc9dc52ce4
allow cancel when saving in wrong format
Claus Gittinger <cg@exept.de>
parents:
2680
diff
changeset
|
2026 |
]. |
1373
c949e9f7757c
give a warning, if saving in the given file-format is not
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
2027 |
]. |
2240 | 2028 |
Transcript showCR:('saving as:' , fileName pathName). |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2029 |
|
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
2030 |
what = #image ifTrue: [ image saveOn:fileName using: imageReaderClass. self clearModified]. |
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2031 |
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
|
2032 |
|
2240 | 2033 |
LastSaveDirectory := fileName directoryName. |
2034 |
fileName exists ifFalse:[ |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2035 |
Dialog warn:'Oops image save failed.' |
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2036 |
] |
1158
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2037 |
] |
9b413954d34d
issue a warning, if information (mask) is
Claus Gittinger <cg@exept.de>
parents:
1121
diff
changeset
|
2038 |
] |
1027
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
2039 |
] |
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
2040 |
|
1380
3b343d2e69ef
fixed copy-paste with masked images.
Claus Gittinger <cg@exept.de>
parents:
1374
diff
changeset
|
2041 |
"Modified: / 18.5.1999 / 19:46:54 / cg" |
633 | 2042 |
! |
2043 |
||
2239 | 2044 |
saveAs |
2045 |
||
2046 |
self saveImageFileAs |
|
2047 |
! |
|
2048 |
||
2049 |
saveButtonImageToFileAs |
|
2050 |
|fn| |
|
2051 |
||
2052 |
fn := self askForFileNameToSave:'Save Button Image to File'. |
|
2053 |
self saveButtonImageToFileAs:fn |
|
2054 |
||
2055 |
"Modified: / 30.9.1998 / 23:04:11 / cg" |
|
2056 |
! |
|
2057 |
||
2058 |
saveButtonImageToFileAs: aFileName |
|
2059 |
"save the image as if in a button in aFileName" |
|
2060 |
||
2061 |
|button grabbedImage| |
|
2062 |
||
2063 |
aFileName isNil ifTrue: [^nil]. |
|
2064 |
||
2065 |
image isNil ifTrue:[ |
|
2066 |
self warn: 'No image or image mask detected!!'. |
|
2067 |
^ self. |
|
2068 |
]. |
|
2069 |
||
2070 |
button := Button label:image. |
|
2071 |
button openAt:5@5. |
|
2072 |
button waitUntilVisible. |
|
2073 |
||
2074 |
grabbedImage := Image fromView:button. |
|
2075 |
button destroy. |
|
2076 |
||
2077 |
self save:grabbedImage imageOrMask:#image as:aFileName |
|
2078 |
||
2079 |
"/ self saveImageOrMask: #mask |
|
2080 |
! |
|
2081 |
||
2082 |
saveImageFileAs |
|
2083 |
"ask for a fileName and save the image" |
|
2084 |
||
2085 |
|fn| |
|
2086 |
||
2087 |
fn := self askForFileNameToSave:'Save Image To File'. |
|
2088 |
self saveImageFileAs:fn |
|
2089 |
! |
|
2090 |
||
2091 |
saveImageFileAs: aFileName |
|
2092 |
"save the image in aFileName" |
|
2093 |
||
2094 |
aFileName isNil ifTrue: [^nil]. |
|
2095 |
image notNil ifTrue:[ |
|
2096 |
self save:image imageOrMask:#image as:aFileName. |
|
2097 |
] ifFalse:[ |
|
2098 |
self warn: 'No image for saving!!' |
|
2099 |
] |
|
2100 |
||
2101 |
"Modified: / 30.9.1998 / 23:04:55 / cg" |
|
2102 |
! |
|
2103 |
||
2104 |
saveImageMaskFileAs |
|
2105 |
"ask for a fileName and save the mask only" |
|
2106 |
||
2107 |
|fn| |
|
2108 |
||
2109 |
fn := self askForFileNameToSave:'Save Image Mask To File'. |
|
2110 |
self saveImageMaskFileAs:fn |
|
2111 |
||
2112 |
"Modified: / 30.9.1998 / 23:04:11 / cg" |
|
2113 |
! |
|
2114 |
||
2115 |
saveImageMaskFileAs: aFileName |
|
2116 |
"save the mask only in aFileName" |
|
2117 |
||
2118 |
aFileName isNil ifTrue: [^nil]. |
|
2119 |
(image notNil and:[image mask notNil]) ifTrue:[ |
|
2120 |
self save:image imageOrMask:#mask as:aFileName. |
|
2121 |
] ifFalse:[ |
|
2122 |
self warn: 'No image or image mask detected!!' |
|
2123 |
] |
|
2124 |
||
2125 |
"Modified: / 30.9.1998 / 23:06:24 / cg" |
|
2126 |
! |
|
2127 |
||
2128 |
saveImageOrMask:what |
|
2129 |
"save the image or the mask only (if what == #mask)" |
|
2130 |
||
2131 |
self save:image imageOrMask: what |
|
2132 |
! |
|
2133 |
||
633 | 2134 |
saveMethod |
1994 | 2135 |
Object errorSignal handle:[:ex| |
1882
fbb4a3a869f1
made image-method generator a class method (for reusability)
martin
parents:
1875
diff
changeset
|
2136 |
self warn: ex errorString. |
fbb4a3a869f1
made image-method generator a class method (for reusability)
martin
parents:
1875
diff
changeset
|
2137 |
^nil |
1994 | 2138 |
] do: [ |
1882
fbb4a3a869f1
made image-method generator a class method (for reusability)
martin
parents:
1875
diff
changeset
|
2139 |
|category imageStoreStream cls sel mthd imageKey| |
822
cace81f0a86b
do not overwrite method categories + toggle between mouse button colors
tz
parents:
796
diff
changeset
|
2140 |
|
1882
fbb4a3a869f1
made image-method generator a class method (for reusability)
martin
parents:
1875
diff
changeset
|
2141 |
windowGroup withExecuteCursorDo:[ |
2321 | 2142 |
(self resourceSelector trimBlanks size = 0) | (cls := Smalltalk at: self resourceClass asSymbol) isClass not |
1882
fbb4a3a869f1
made image-method generator a class method (for reusability)
martin
parents:
1875
diff
changeset
|
2143 |
ifTrue: [^self saveMethodAs]. |
822
cace81f0a86b
do not overwrite method categories + toggle between mouse button colors
tz
parents:
796
diff
changeset
|
2144 |
|
2149
04e8367eaf70
code generation moved to CodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents:
2135
diff
changeset
|
2145 |
CodeGeneratorTool |
04e8367eaf70
code generation moved to CodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents:
2135
diff
changeset
|
2146 |
createImageSpecMethodFor:self image |
1882
fbb4a3a869f1
made image-method generator a class method (for reusability)
martin
parents:
1875
diff
changeset
|
2147 |
comment:(ResourceSpecEditor codeGenerationCommentForClass: ImageEditor) |
2149
04e8367eaf70
code generation moved to CodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents:
2135
diff
changeset
|
2148 |
in:cls class |
1882
fbb4a3a869f1
made image-method generator a class method (for reusability)
martin
parents:
1875
diff
changeset
|
2149 |
selector:self resourceSelector. |
822
cace81f0a86b
do not overwrite method categories + toggle between mouse button colors
tz
parents:
796
diff
changeset
|
2150 |
|
1901
b4b286ec221f
flush cached icons, when defining a new image-method
Claus Gittinger <cg@exept.de>
parents:
1896
diff
changeset
|
2151 |
"/ flush cache images in the Icon class (kludge) |
b4b286ec221f
flush cached icons, when defining a new image-method
Claus Gittinger <cg@exept.de>
parents:
1896
diff
changeset
|
2152 |
Icon flushCachedIcons. |
2590
b811d560e00a
modified flag after edit operations
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
2153 |
self clearModified. |
1901
b4b286ec221f
flush cached icons, when defining a new image-method
Claus Gittinger <cg@exept.de>
parents:
1896
diff
changeset
|
2154 |
|
1994 | 2155 |
LastSaveClass := cls theNonMetaclass name. |
1882
fbb4a3a869f1
made image-method generator a class method (for reusability)
martin
parents:
1875
diff
changeset
|
2156 |
] |
633 | 2157 |
] |
1027
5bffbe90b8e2
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
2158 |
|
1047 | 2159 |
"Modified: / 31.7.1998 / 20:12:54 / cg" |
633 | 2160 |
! |
2161 |
||
2162 |
saveMethodAs |
|
1994 | 2163 |
|className| |
2164 |
||
2165 |
className := self resourceClass. |
|
2166 |
className size == 0 ifTrue:[ |
|
2177 | 2167 |
className := LastSaveClass |
1994 | 2168 |
]. |
633 | 2169 |
|
636 | 2170 |
(self resourceMessage: |
1994 | 2171 |
(ResourceSelectionBrowser |
2172 |
request: 'Save Image In Class' |
|
2173 |
onSuperclass: #Object |
|
2174 |
andClass: className |
|
2175 |
andSelector: self resourceSelector |
|
2176 |
withResourceTypes: #(image fileImage))) notNil |
|
2177 |
ifTrue: [ |
|
2178 |
^ self saveMethod |
|
674 | 2179 |
]. |
633 | 2180 |
^nil |
1 | 2181 |
! ! |
2182 |
||
161 | 2183 |
!ImageEditView methodsFor:'queries'! |
5 | 2184 |
|
161 | 2185 |
heightOfContents |
2186 |
||
686 | 2187 |
image isNil ifTrue:[^0]. |
2188 |
^(image height * magnification y) rounded |
|
5 | 2189 |
! |
2190 |
||
995 | 2191 |
imageContainsPastePoint: aPoint |
2192 |
||
2193 |
^image notNil and: |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
2194 |
[Clipboard notNil and: |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
2195 |
[((0@0 corner:(image extent) "- 1" - Clipboard extent) containsPoint: (((aPoint - margin + 1) / magnification) floor))]] |
995 | 2196 |
! |
2197 |
||
627 | 2198 |
imageContainsPoint: aPoint |
632 | 2199 |
|
2200 |
^image notNil and: |
|
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
2201 |
[((0@0 corner:(image extent) - 1) containsPoint: (((aPoint - margin + 1) / magnification) floor))] |
627 | 2202 |
! |
2203 |
||
783 | 2204 |
imageInfoString |
2205 |
||
2206 |
|imageInfoString usedColors| |
|
1011
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2207 |
|
325d334e93c8
added paste-under (only paste where pixel ~= current selected)
Claus Gittinger <cg@exept.de>
parents:
1006
diff
changeset
|
2208 |
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
|
2209 |
ifFalse: [ |
1116
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
2210 |
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
|
2211 |
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
|
2212 |
, image height printString, 'x' |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
2213 |
, (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
|
2214 |
, (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
|
2215 |
, usedColors printString |
441ff42c1472
fixes to allow 24bit images to be (at least) displayed
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
2216 |
, ' used colors)']. |
783 | 2217 |
|
2218 |
^imageInfoString |
|
2219 |
! |
|
2220 |
||
161 | 2221 |
widthOfContents |
5 | 2222 |
|
686 | 2223 |
image isNil ifTrue:[^0]. |
2224 |
^(image width * magnification x) rounded |
|
5 | 2225 |
! ! |
2226 |
||
627 | 2227 |
!ImageEditView methodsFor:'release'! |
2228 |
||
995 | 2229 |
releasePasteDrawing |
2085 | 2230 |
self repairDamage. |
2440 | 2231 |
(lastPastePoint notNil and: [ClipboardMagnified notNil]) |
2747 | 2232 |
ifTrue: [ |
2440 | 2233 |
self redraw: ((lastPastePoint"-self viewOrigin") extent: (ClipboardMagnified extent)). |
2085 | 2234 |
"/ self repairDamage. |
995 | 2235 |
]. |
2440 | 2236 |
lastPastePoint := ClipboardMagnified := nil |
995 | 2237 |
! |
2238 |
||
2239 |
releaseUndos |
|
2240 |
undoImages removeAll. |
|
627 | 2241 |
! ! |
2242 |
||
632 | 2243 |
!ImageEditView methodsFor:'testing'! |
2244 |
||
2245 |
checkModified |
|
2747 | 2246 |
modifiedHolder value ifTrue:[ |
2634 | 2247 |
((YesNoBox title:(resources string:'Image was not saved. Exit anyway ?')) |
2591
87cab7199c7e
Use 'Discard Changes and Exit' instead of 'Forget it...'
Stefan Vogel <sv@exept.de>
parents:
2590
diff
changeset
|
2248 |
noText:(resources string:'Cancel'); |
2634 | 2249 |
yesText:(resources string:'Exit without Saving'); |
2591
87cab7199c7e
Use 'Discard Changes and Exit' instead of 'Forget it...'
Stefan Vogel <sv@exept.de>
parents:
2590
diff
changeset
|
2250 |
showAtPointer; |
2747 | 2251 |
accepted |
2252 |
) ifFalse: [^false]. |
|
2253 |
||
2254 |
self modified:false. |
|
632 | 2255 |
]. |
2591
87cab7199c7e
Use 'Discard Changes and Exit' instead of 'Forget it...'
Stefan Vogel <sv@exept.de>
parents:
2590
diff
changeset
|
2256 |
^ true |
1031
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
2257 |
|
a5ab5869b2ba
cleaned up the interface to the apps infoPanel
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
2258 |
"Modified: / 29.7.1998 / 18:55:24 / cg" |
632 | 2259 |
! ! |
2260 |
||
255 | 2261 |
!ImageEditView class methodsFor:'documentation'! |
161 | 2262 |
|
2263 |
version |
|
2764 | 2264 |
^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.198 2004-10-19 17:09:17 cg Exp $' |
161 | 2265 |
! ! |
2239 | 2266 |
|
1245 | 2267 |
ImageEditView initialize! |