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