author | Claus Gittinger <cg@exept.de> |
Wed, 16 Oct 1996 01:57:42 +0200 | |
changeset 255 | 1dfa8deddaef |
parent 251 | a6e8eb4d7922 |
child 256 | 4684c0a52203 |
permissions | -rw-r--r-- |
1 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
26 | 3 |
All Rights Reserved |
1 | 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 |
||
13 |
ImageView subclass:#ImageEditView |
|
161 | 14 |
instanceVariableNames:'magnification colors magnifiedImage colorPanel' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Views-Misc' |
|
1 | 18 |
! |
19 |
||
255 | 20 |
!ImageEditView class methodsFor:'documentation'! |
64 | 21 |
|
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
25 |
All Rights Reserved |
|
26 |
||
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
36 |
documentation |
|
37 |
" |
|
38 |
This View will eventually be able to edit bitmap images. |
|
39 |
For now, it is not. |
|
40 |
" |
|
1 | 41 |
! ! |
42 |
||
7 | 43 |
!ImageEditView methodsFor:'accessing'! |
44 |
||
45 |
image:anImage |
|
46 |
magnification := 1@1. |
|
47 |
magnifiedImage := nil. |
|
48 |
super image:anImage |
|
255 | 49 |
! |
50 |
||
51 |
magnification:aMagnificationPoint |
|
52 |
|nPixel savedImage| |
|
53 |
||
54 |
magnification ~= aMagnificationPoint ifTrue:[ |
|
55 |
"show wait cursor; although magnification is fast, dithering may take a while" |
|
56 |
self cursor:Cursor wait. |
|
57 |
||
58 |
(device visualType == #PseudoColor) ifTrue:[ |
|
59 |
"release kept colors" |
|
60 |
colors := IdentitySet new. |
|
61 |
]. |
|
62 |
||
63 |
magnification := aMagnificationPoint asPoint. |
|
64 |
||
65 |
"use a magnified image, if its size wont be too big" |
|
66 |
magnifiedImage := nil. |
|
67 |
||
68 |
"avoid slow scroll" |
|
69 |
savedImage := image. |
|
70 |
image := nil. |
|
71 |
self scrollToTopLeft. |
|
72 |
image := savedImage. |
|
73 |
||
74 |
magnification ~= (1@1) ifTrue:[ |
|
75 |
nPixel := image width * image height * magnification x * magnification y. |
|
76 |
nPixel <= (2000 * 2000) ifTrue:[ |
|
77 |
Transcript showCR:'magnifying ..'; endEntry. |
|
78 |
magnifiedImage := image magnifiedBy:magnification |
|
79 |
]. |
|
80 |
]. |
|
81 |
||
82 |
self contentsChanged. |
|
83 |
self invalidate. |
|
84 |
self cursor:Cursor normal |
|
85 |
] |
|
86 |
||
87 |
"Modified: 5.7.1996 / 17:44:29 / stefan" |
|
88 |
"Modified: 11.7.1996 / 21:03:06 / cg" |
|
7 | 89 |
! ! |
90 |
||
1 | 91 |
!ImageEditView methodsFor:'drawing'! |
92 |
||
210
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
93 |
redrawX:x y:y width:w height:h |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
94 |
|area ih iw dotW dotH minX maxX minY maxY color last lastY runW x0 oldClip| |
1 | 95 |
|
96 |
image isNil ifTrue:[^ self]. |
|
97 |
||
210
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
98 |
"/ area := Rectangle left:x top:y width:w height:h. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
99 |
"/ oldClip := self clippingRectangleOrNil. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
100 |
"/ self clippingRectangle:area. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
101 |
|
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
102 |
(magnification = (1@1)) ifTrue:[ |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
103 |
super redrawX:x y:y width:w height:h. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
104 |
"/ self clippingRectangle:oldClip. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
105 |
^ self |
1 | 106 |
]. |
210
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
107 |
|
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
108 |
"/ self clear. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
109 |
|
1 | 110 |
magnifiedImage notNil ifTrue:[ |
203 | 111 |
magnifiedImage := magnifiedImage on:device. |
205
96f80d06fe5a
oops - care for d1 images colors
Claus Gittinger <cg@exept.de>
parents:
204
diff
changeset
|
112 |
|
204 | 113 |
magnifiedImage depth == 1 ifTrue:[ |
205
96f80d06fe5a
oops - care for d1 images colors
Claus Gittinger <cg@exept.de>
parents:
204
diff
changeset
|
114 |
self paint:(magnifiedImage colorFromValue:1) |
96f80d06fe5a
oops - care for d1 images colors
Claus Gittinger <cg@exept.de>
parents:
204
diff
changeset
|
115 |
on:(magnifiedImage colorFromValue:0). |
210
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
116 |
] ifFalse:[ |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
117 |
self paint:Black on:White. |
204 | 118 |
]. |
119 |
||
203 | 120 |
self function:#copy. |
204 | 121 |
self displayOpaqueForm:magnifiedImage x:margin y:margin. |
210
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
122 |
"/ self clippingRectangle:oldClip. |
203 | 123 |
^ self |
1 | 124 |
]. |
125 |
||
210
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
126 |
"/ self clear. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
127 |
ih := image height. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
128 |
iw := image width. |
1 | 129 |
dotW := magnification x. |
130 |
dotH := magnification y. |
|
210
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
131 |
|
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
132 |
minX := x // dotW. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
133 |
minY := y // dotW. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
134 |
maxX := (x + w) // dotW + 1. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
135 |
maxX > iw ifTrue:[ |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
136 |
maxX := iw |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
137 |
]. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
138 |
maxY := (y + h) // dotH + 1. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
139 |
maxY > ih ifTrue:[ |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
140 |
maxY := ih |
1 | 141 |
]. |
142 |
||
210
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
143 |
lastY := -1. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
144 |
|
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
145 |
x0 := minX. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
146 |
runW := 0. |
204 | 147 |
|
210
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
148 |
image colorsFromX:minX y:minY toX:maxX-1 y:maxY-1 do:[:x :y :color | |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
149 |
y ~~ lastY ifTrue:[ |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
150 |
runW ~~ 0 ifTrue:[ |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
151 |
self fillRectangleX:(x0 * dotW + margin) |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
152 |
y:(lastY * dotH + margin) |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
153 |
width:runW height:dotH. |
203 | 154 |
runW := 0. |
155 |
]. |
|
210
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
156 |
x0 := x. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
157 |
lastY := y. |
204 | 158 |
]. |
1 | 159 |
|
210
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
160 |
color ~~ last ifTrue:[ |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
161 |
runW ~~ 0 ifTrue:[ |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
162 |
self fillRectangleX:(x0 * dotW + margin) |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
163 |
y:(y * dotH + margin) |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
164 |
width:runW height:dotH. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
165 |
runW := 0. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
166 |
]. |
204 | 167 |
|
210
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
168 |
"/ keep colors - otherwise they might get collected & changed |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
169 |
colors notNil ifTrue:[colors add:color]. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
170 |
self paint:color. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
171 |
last := color. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
172 |
runW := 0. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
173 |
x0 := x. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
174 |
]. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
175 |
runW := runW + dotW |
191 | 176 |
]. |
177 |
||
210
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
178 |
runW ~~ 0 ifTrue:[ |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
179 |
self fillRectangleX:(x0 * dotW + margin) |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
180 |
y:(lastY * dotH + margin) |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
181 |
width:runW height:dotH. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
182 |
runW := 0. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
183 |
]. |
191 | 184 |
|
210
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
185 |
"/ self clippingRectangle:oldClip |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
186 |
|
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
187 |
"Modified: 11.7.1996 / 21:13:53 / cg" |
1 | 188 |
! ! |
189 |
||
161 | 190 |
!ImageEditView methodsFor:'event handling'! |
191 |
||
192 |
buttonMotion:state x:x y:y |
|
193 |
self showColorAtX:x y:y. |
|
194 |
! |
|
195 |
||
167
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
196 |
buttonMultiPress:button x:x y:y |
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
197 |
button == 1 ifTrue:[ |
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
198 |
|clr| |
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
199 |
clr := self getColorAtX:x y:y. |
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
200 |
clr inspect. |
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
201 |
]. |
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
202 |
super buttonMultiPress:button x:x y:y |
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
203 |
|
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
204 |
"Created: 8.5.1996 / 00:18:06 / stefan" |
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
205 |
! |
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
206 |
|
161 | 207 |
buttonPress:button x:x y:y |
208 |
button == 1 ifTrue:[ |
|
209 |
self showColorAtX:x y:y. |
|
210 |
^ self |
|
211 |
]. |
|
212 |
super buttonPress:button x:x y:y |
|
213 |
! |
|
214 |
||
167
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
215 |
getColorAtX:x y:y |
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
216 |
|pi| |
161 | 217 |
|
218 |
pi := (x @ y) - margin. |
|
219 |
pi := pi // magnification. |
|
220 |
((0@0 corner:image extent) containsPoint:pi) ifTrue:[ |
|
167
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
221 |
^ image at:pi. |
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
222 |
]. |
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
223 |
^ nil |
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
224 |
|
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
225 |
"Created: 8.5.1996 / 00:15:55 / stefan" |
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
226 |
! |
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
227 |
|
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
228 |
showColorAtX:x y:y |
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
229 |
|clr| |
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
230 |
|
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
231 |
clr := self getColorAtX:x y:y. |
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
232 |
clr notNil ifTrue:[ |
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
233 |
colorPanel notNil ifTrue:[ |
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
234 |
colorPanel setColor:clr. |
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
235 |
] ifFalse:[ |
184 | 236 |
Transcript showCR:clr displayString |
167
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
237 |
] |
161 | 238 |
] |
167
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
239 |
|
0d6d90115420
Doubleclick on pixel opens colorInspector.
Stefan Vogel <sv@exept.de>
parents:
161
diff
changeset
|
240 |
"Modified: 8.5.1996 / 00:20:45 / stefan" |
161 | 241 |
! ! |
242 |
||
243 |
!ImageEditView methodsFor:'image processing'! |
|
244 |
||
245 |
blurr |
|
246 |
self performImageOperation:#blurr withArguments:nil |
|
247 |
! |
|
248 |
||
249 |
flipHorizontal |
|
250 |
self performImageOperation:#flipHorizontal withArguments:nil |
|
251 |
! |
|
252 |
||
253 |
flipVertical |
|
254 |
self performImageOperation:#flipVertical withArguments:nil |
|
255 |
! |
|
256 |
||
257 |
performImageOperation:operation withArguments:args |
|
258 |
|oldMag| |
|
259 |
||
260 |
windowGroup withCursor:Cursor wait do:[ |
|
210
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
261 |
oldMag := magnification. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
262 |
magnifiedImage := nil. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
263 |
magnification := 1@1. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
264 |
image perform:operation withArguments:args. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
265 |
(oldMag isNil or:[oldMag = magnification]) ifTrue:[ |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
266 |
self invalidate |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
267 |
] ifFalse:[ |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
268 |
self magnification:oldMag. |
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
269 |
] |
161 | 270 |
] |
210
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
271 |
|
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
272 |
"Modified: 11.7.1996 / 21:03:10 / cg" |
161 | 273 |
! ! |
274 |
||
1 | 275 |
!ImageEditView methodsFor:'initialization'! |
276 |
||
161 | 277 |
initialize |
278 |
super initialize. |
|
279 |
magnification := 1@1. |
|
280 |
colors := nil |
|
281 |
! |
|
282 |
||
1 | 283 |
initializeMiddleButtonMenu |
5 | 284 |
|m| |
285 |
||
286 |
m := (PopUpMenu |
|
26 | 287 |
labels:(resources array: |
288 |
#('save as ...' |
|
289 |
'-' |
|
290 |
'magnification' |
|
291 |
"/ 'colors' |
|
292 |
'effects' |
|
293 |
)) |
|
294 |
selectors:#(saveAs |
|
295 |
nil |
|
296 |
changeMagnification |
|
297 |
"/ showColors |
|
298 |
effects |
|
299 |
) |
|
300 |
receiver:self |
|
301 |
for:self). |
|
5 | 302 |
self middleButtonMenu:m. |
303 |
||
304 |
m subMenuAt:#effects put:( |
|
26 | 305 |
PopUpMenu labels:(resources array:#( |
306 |
'flip - vertical' |
|
307 |
'flip - horizontal' |
|
11 | 308 |
" |
26 | 309 |
'-' |
310 |
'blurr' |
|
11 | 311 |
" |
26 | 312 |
)) |
313 |
selectors:#( |
|
314 |
flipVertical |
|
315 |
flipHorizontal |
|
11 | 316 |
" |
26 | 317 |
nil |
318 |
blurr |
|
11 | 319 |
" |
26 | 320 |
) |
321 |
receiver:self |
|
322 |
for:self |
|
5 | 323 |
|
324 |
). |
|
1 | 325 |
|
26 | 326 |
" |
327 |
ImageEditView openOn:'bitmaps/SBrowser.xbm' |
|
328 |
ImageEditView openOn:'bitmaps/garfield.gif' |
|
329 |
" |
|
1 | 330 |
! ! |
331 |
||
161 | 332 |
!ImageEditView methodsFor:'menu actions'! |
333 |
||
334 |
changeMagnification |
|
335 |
|b| |
|
1 | 336 |
|
161 | 337 |
b := EnterBox new. |
338 |
b title:'magnification (magX @ magY)'. |
|
339 |
b okText:'apply'. |
|
340 |
b abortText:'abort'. |
|
341 |
b action:[:string | self magnification:(Object readFromString:string)]. |
|
342 |
b initialText:(magnification printString). |
|
343 |
b showAtPointer |
|
344 |
! |
|
345 |
||
346 |
saveAs |
|
347 |
"save contents into a file |
|
348 |
- ask user for filename using a fileSelectionBox." |
|
349 |
||
251 | 350 |
|fileName i txt| |
351 |
||
352 |
||
353 |
magnifiedImage notNil ifTrue:[ |
|
354 |
i := magnifiedImage. |
|
355 |
txt := 'save magnified image in:' |
|
356 |
] ifFalse:[ |
|
357 |
i := image. |
|
358 |
txt := 'save image in:' |
|
359 |
]. |
|
161 | 360 |
|
361 |
fileName := Dialog |
|
251 | 362 |
requestFileName:(resources string:txt) |
363 |
default:'' |
|
364 |
ok:(resources string:'save') |
|
365 |
abort:(resources string:'abort') |
|
366 |
pattern:'*.tiff'. |
|
161 | 367 |
|
368 |
fileName notNil ifTrue:[ |
|
251 | 369 |
i saveOn:fileName |
161 | 370 |
]. |
251 | 371 |
|
372 |
"Modified: 10.10.1996 / 18:11:00 / cg" |
|
1 | 373 |
! |
374 |
||
161 | 375 |
showColors |
376 |
colorPanel isNil ifTrue:[ |
|
377 |
colorPanel := ColorPanel new |
|
1 | 378 |
]. |
161 | 379 |
colorPanel shown ifFalse:[ |
380 |
colorPanel realize |
|
381 |
] |
|
1 | 382 |
! ! |
383 |
||
161 | 384 |
!ImageEditView methodsFor:'queries'! |
5 | 385 |
|
161 | 386 |
heightOfContents |
387 |
"return the images height" |
|
388 |
||
389 |
image isNil ifTrue:[^ 0]. |
|
390 |
^ (image height * magnification y) rounded |
|
5 | 391 |
! |
392 |
||
161 | 393 |
widthOfContents |
394 |
"return the images width" |
|
5 | 395 |
|
161 | 396 |
image isNil ifTrue:[^ 0]. |
397 |
^ (image width * magnification x) rounded |
|
5 | 398 |
! ! |
399 |
||
1 | 400 |
!ImageEditView methodsFor:'release'! |
401 |
||
402 |
destroy |
|
403 |
colors := nil. |
|
404 |
magnifiedImage := nil. |
|
405 |
colorPanel notNil ifTrue:[ |
|
26 | 406 |
colorPanel destroy. |
407 |
colorPanel := nil. |
|
1 | 408 |
]. |
409 |
super destroy. |
|
410 |
! ! |
|
161 | 411 |
|
255 | 412 |
!ImageEditView class methodsFor:'documentation'! |
161 | 413 |
|
414 |
version |
|
255 | 415 |
^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.28 1996-10-15 23:57:42 cg Exp $' |
161 | 416 |
! ! |