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