author | Claus Gittinger <cg@exept.de> |
Wed, 16 Feb 2000 11:19:25 +0100 | |
changeset 1353 | 701e41f8ff9f |
parent 1345 | 218b7fcff239 |
child 1376 | ce3cf26e201e |
permissions | -rw-r--r-- |
400 | 1 |
" |
767 | 2 |
COPYRIGHT (c) 1997-1998 by eXept Software AG |
400 | 3 |
All Rights Reserved |
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 |
|
405 | 7 |
inclusion of the above copyright notice. This software may not |
400 | 8 |
be provided or otherwise made available to, or used by, any |
405 | 9 |
other person. No title to or ownership of the software is |
400 | 10 |
hereby transferred. |
11 |
" |
|
12 |
||
13 |
ToolApplicationModel subclass:#ImageEditor |
|
975 | 14 |
instanceVariableNames:'imageEditView colorMapMode editMode mouseKeyColorMode |
15 |
selectedColorIndex postOpenAction' |
|
1353 | 16 |
classVariableNames:'LastDirectory' |
929 | 17 |
poolDictionaries:'' |
18 |
category:'Interface-UIPainter' |
|
400 | 19 |
! |
20 |
||
21 |
!ImageEditor class methodsFor:'documentation'! |
|
22 |
||
23 |
copyright |
|
24 |
" |
|
767 | 25 |
COPYRIGHT (c) 1997-1998 by eXept Software AG |
400 | 26 |
All Rights Reserved |
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
405 | 30 |
inclusion of the above copyright notice. This software may not |
400 | 31 |
be provided or otherwise made available to, or used by, any |
405 | 32 |
other person. No title to or ownership of the software is |
400 | 33 |
hereby transferred. |
34 |
" |
|
35 |
! |
|
36 |
||
37 |
documentation |
|
38 |
" |
|
737 | 39 |
Image Editor allows you to create, design, modify or just inspect images. |
400 | 40 |
|
41 |
[start with:] |
|
42 |
ImageEditor open |
|
941 | 43 |
ImageEditor openOnClass:Icon andSelector:#startIcon |
400 | 44 |
|
45 |
[see also:] |
|
46 |
ImageEditView Image |
|
47 |
||
48 |
[author:] |
|
544 | 49 |
Thomas Zwick, eXept Software AG |
400 | 50 |
" |
51 |
! ! |
|
52 |
||
53 |
!ImageEditor class methodsFor:'instance creation'! |
|
54 |
||
55 |
openModalOnClass: aClass andSelector: aSelector |
|
900 | 56 |
"opens modal a Image Editor on aClass and aSelector" |
767 | 57 |
" |
58 |
self openModalOnClass: self andSelector: #leftMouseKeyIcon |
|
59 |
" |
|
400 | 60 |
|
767 | 61 |
|imageEditor imageEditView className resourceClassName resourceSelector| |
62 |
||
400 | 63 |
imageEditor := self new. |
767 | 64 |
|
900 | 65 |
aClass isClass ifTrue: [className := aClass name]. |
66 |
aClass isString ifTrue: [className := aClass]. |
|
903 | 67 |
aClass isNil ifTrue: [className := '']. |
400 | 68 |
|
688 | 69 |
imageEditor postOpenAction: [imageEditView := imageEditor imageEditView. imageEditor loadFromOrPrepareForMessage: className, ' ', aSelector]. |
400 | 70 |
imageEditor openModal. |
71 |
||
688 | 72 |
resourceClassName := imageEditView resourceClass. |
767 | 73 |
resourceSelector := imageEditView resourceSelector. |
415 | 74 |
|
815 | 75 |
((className asString ~= resourceClassName) |
76 |
or:[aSelector asString ~= resourceSelector]) |
|
415 | 77 |
ifTrue: [^resourceClassName, ' ', resourceSelector] |
78 |
ifFalse:[^nil] |
|
400 | 79 |
! |
80 |
||
81 |
openOnClass: aClass andSelector: aSelector |
|
900 | 82 |
"opens a Image Editor on aClass and aSelector" |
767 | 83 |
" |
84 |
self openOnClass: self andSelector: #leftMouseKeyIcon |
|
85 |
" |
|
400 | 86 |
|
1057 | 87 |
|editor| |
88 |
||
89 |
editor := self new. |
|
90 |
editor allButOpen. |
|
91 |
editor loadFromMessage: aClass name, ' ', aSelector. |
|
92 |
editor openWindow |
|
93 |
||
94 |
"Modified: / 16.3.1999 / 21:33:49 / cg" |
|
400 | 95 |
! |
96 |
||
767 | 97 |
openOnFile: aFileName |
900 | 98 |
"opens a Image Editor on aFileName" |
767 | 99 |
" |
100 |
self openOnFile: 'bitmaps/SmalltalkX.xbm' |
|
101 |
" |
|
400 | 102 |
|
1057 | 103 |
|editor| |
104 |
||
105 |
editor := self new. |
|
106 |
editor allButOpen. |
|
107 |
editor loadFromFile: aFileName. |
|
108 |
editor openWindow |
|
109 |
||
110 |
"Modified: / 16.3.1999 / 21:33:25 / cg" |
|
400 | 111 |
! |
112 |
||
767 | 113 |
openOnImage: anImage |
900 | 114 |
"opens a Image Editor on anImage" |
767 | 115 |
" |
895 | 116 |
self openOnImage: Icon startIcon |
767 | 117 |
" |
400 | 118 |
|
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
119 |
|editor| |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
120 |
|
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
121 |
editor := self new. |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
122 |
editor allButOpen. |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
123 |
editor loadFromImage: anImage. |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
124 |
editor openWindow |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
125 |
|
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
126 |
"Modified: / 11.3.1999 / 16:18:33 / cg" |
400 | 127 |
! ! |
128 |
||
129 |
!ImageEditor class methodsFor:'accessing'! |
|
130 |
||
131 |
listOfColorMaps |
|
767 | 132 |
"returns the list of default color maps for a new image" |
400 | 133 |
|
134 |
|colorMap| |
|
898 | 135 |
|
400 | 136 |
(colorMap := OrderedCollection new) |
137 |
add: Color black; |
|
138 |
add: Color white; |
|
139 |
add: Color red; |
|
140 |
add: Color green; |
|
141 |
add: Color blue; |
|
142 |
add: Color cyan; |
|
143 |
add: Color yellow; |
|
144 |
add: Color magenta; |
|
898 | 145 |
add: (Color redByte: 127 greenByte: 0 blueByte: 0); |
146 |
add: (Color redByte: 0 greenByte: 127 blueByte: 0); |
|
147 |
add: (Color redByte: 0 greenByte: 0 blueByte: 127); |
|
148 |
add: (Color redByte: 0 greenByte: 127 blueByte: 127); |
|
149 |
add: (Color redByte: 127 greenByte: 127 blueByte: 0); |
|
150 |
add: (Color redByte: 127 greenByte: 0 blueByte: 127); |
|
151 |
add: (Color redByte: 127 greenByte: 127 blueByte: 127); |
|
152 |
add: (Color redByte: 170 greenByte: 170 blueByte: 170). |
|
153 |
||
400 | 154 |
0 to: 5 do: |
155 |
[:r| |
|
156 |
0 to: 5 do: |
|
157 |
[:g| |
|
158 |
0 to: 5 do: |
|
159 |
[:b| |
|
898 | 160 |
colorMap add: (Color redByte: (r*255//5) ceiling greenByte: (g*255//5) ceiling blueByte: (b*255//5) ceiling) |
400 | 161 |
] |
162 |
] |
|
163 |
]. |
|
164 |
||
165 |
1 to: 25 do: |
|
166 |
[:g| |
|
898 | 167 |
colorMap add: (Color redByte: (g*255//26) ceiling greenByte: (g*255//26) ceiling blueByte: (g*255//26) ceiling) |
400 | 168 |
]. |
169 |
||
170 |
^Dictionary new |
|
171 |
at: '8-plane' put: colorMap; |
|
172 |
at: '8-plane + mask' put: colorMap; |
|
173 |
at: '4-plane' put: (colorMap copyFrom: 1 to: 16); |
|
174 |
at: '4-plane + mask' put: (colorMap copyFrom: 1 to: 16); |
|
175 |
at: '2-plane' put: (colorMap copyFrom: 1 to: 4); |
|
176 |
at: '2-plane + mask' put: (colorMap copyFrom: 1 to: 4); |
|
177 |
at: '1-plane' put: (colorMap copyFrom: 1 to: 2); |
|
178 |
at: '1-plane + mask' put: (colorMap copyFrom: 1 to: 2); |
|
179 |
yourself |
|
180 |
! |
|
181 |
||
182 |
listOfDefaultSizes |
|
767 | 183 |
"returns the list of default sizes for a new image" |
400 | 184 |
|
932
7111238cda23
fixed dimension of new-image dialog.
Claus Gittinger <cg@exept.de>
parents:
930
diff
changeset
|
185 |
^#('8x8' '16x16' '22x22' '32x32' '48x48' '64x64') |
7111238cda23
fixed dimension of new-image dialog.
Claus Gittinger <cg@exept.de>
parents:
930
diff
changeset
|
186 |
|
7111238cda23
fixed dimension of new-image dialog.
Claus Gittinger <cg@exept.de>
parents:
930
diff
changeset
|
187 |
"Modified: / 31.7.1998 / 01:57:34 / cg" |
400 | 188 |
! ! |
189 |
||
460 | 190 |
!ImageEditor class methodsFor:'help specs'! |
191 |
||
192 |
helpSpec |
|
737 | 193 |
"This resource specification was automatically generated |
194 |
by the UIHelpTool of ST/X." |
|
195 |
||
196 |
"Do not manually edit this!! If it is corrupted, |
|
197 |
the UIHelpTool may not be able to read the specification." |
|
460 | 198 |
|
199 |
" |
|
737 | 200 |
UIHelpTool openOnClass:ImageEditor |
460 | 201 |
" |
202 |
||
737 | 203 |
<resource: #help> |
204 |
||
205 |
^super helpSpec addPairsFrom:#( |
|
460 | 206 |
|
207 |
#colorMap |
|
929 | 208 |
'ColorMap functions.' |
209 |
||
210 |
#colorMap1 |
|
211 |
'Convert to depth-1 image.' |
|
212 |
||
986 | 213 |
#colorMap1M |
214 |
'Convert to depth-1 image plus mask.' |
|
215 |
||
929 | 216 |
#colorMap2 |
217 |
'Convert to depth-2 image.' |
|
218 |
||
986 | 219 |
#colorMap2M |
220 |
'Convert to depth-2 image plus mask.' |
|
221 |
||
929 | 222 |
#colorMap4 |
223 |
'Convert to depth-4 image.' |
|
224 |
||
986 | 225 |
#colorMap4M |
226 |
'Convert to depth-4 image plus mask.' |
|
227 |
||
929 | 228 |
#colorMap8 |
229 |
'Convert to depth-8 image.' |
|
230 |
||
231 |
#colorMap8M |
|
232 |
'Convert to depth-8 image plus mask.' |
|
233 |
||
986 | 234 |
#colorMapTable |
235 |
'Shows a list of used colors of the image.' |
|
236 |
||
929 | 237 |
#compressColormap |
238 |
'Remove unneeded entries from the colorMap.' |
|
460 | 239 |
|
1045 | 240 |
#cropAll |
986 | 241 |
'Find and remove all borders.' |
242 |
||
1045 | 243 |
#cropBottom |
986 | 244 |
'Find and remove bottom border.' |
245 |
||
1045 | 246 |
#cropLeft |
986 | 247 |
'Find and remove left border.' |
248 |
||
1045 | 249 |
#cropManual |
986 | 250 |
'Specify border(s) to remove.' |
251 |
||
1045 | 252 |
#cropRight |
986 | 253 |
'Find and remove right border.' |
254 |
||
1045 | 255 |
#cropTop |
986 | 256 |
'Find and remove top border.' |
487 | 257 |
|
460 | 258 |
#drawModeBox |
914 | 259 |
'Switches to box-drawing mode.' |
460 | 260 |
|
261 |
#drawModeCopy |
|
914 | 262 |
'Switches to area-copy mode.' |
460 | 263 |
|
264 |
#drawModeFill |
|
914 | 265 |
'Switches to flood-fill mode.' |
460 | 266 |
|
267 |
#drawModeFilledBox |
|
914 | 268 |
'Switches to filled-box drawing mode.' |
460 | 269 |
|
270 |
#drawModePaste |
|
914 | 271 |
'Switches to paste mode.' |
272 |
||
273 |
#drawModePasteUnder |
|
274 |
'Switches to paste under mode.' |
|
460 | 275 |
|
276 |
#drawModePoint |
|
914 | 277 |
'Switches to point-drawing mode.' |
460 | 278 |
|
279 |
#editFlipHorizontal |
|
914 | 280 |
'Flips the image horizontally.' |
460 | 281 |
|
282 |
#editFlipVertical |
|
914 | 283 |
'Flips the image vertically.' |
460 | 284 |
|
285 |
#editMagnifyImage |
|
914 | 286 |
'Magnify the image.' |
460 | 287 |
|
288 |
#editNegate |
|
914 | 289 |
'Invert the images colors.' |
460 | 290 |
|
291 |
#editResize |
|
914 | 292 |
'Resize the image (preserving the old image).' |
460 | 293 |
|
294 |
#editRotate |
|
914 | 295 |
'Rotate the image.' |
460 | 296 |
|
929 | 297 |
#fileGrabImage |
298 |
'Pick an image from the screen.' |
|
299 |
||
460 | 300 |
#fileLoadFromClass |
929 | 301 |
'Select and load an image from a resource method.' |
460 | 302 |
|
303 |
#fileLoadFromFile |
|
929 | 304 |
'Select and load an image from a file.' |
460 | 305 |
|
306 |
#fileNewImage |
|
914 | 307 |
'Create a new image' |
460 | 308 |
|
309 |
#filePrint |
|
310 |
'Print the image on a postscript printer.' |
|
311 |
||
312 |
#fileSaveAs |
|
914 | 313 |
'Save the image to a file.' |
460 | 314 |
|
315 |
#fileSaveMaskAs |
|
914 | 316 |
'Save the mask of the image to a file.' |
460 | 317 |
|
318 |
#fileSaveMethod |
|
914 | 319 |
'Save the image as resource method in the current class and selector.' |
460 | 320 |
|
321 |
#fileSaveMethodAs |
|
914 | 322 |
'Save the image as resource method in a class.' |
460 | 323 |
|
487 | 324 |
#magnificationNumber |
914 | 325 |
'Shows the current magnification.' |
487 | 326 |
|
327 |
#magnifyImageDown |
|
914 | 328 |
'Decrease magnification.' |
487 | 329 |
|
330 |
#magnifyImageUp |
|
914 | 331 |
'Increase magnification.' |
487 | 332 |
|
333 |
#mouseKeyColorMode |
|
914 | 334 |
'Toggles between left and right mouse button color.' |
487 | 335 |
|
336 |
#previewView |
|
914 | 337 |
'Shows a preview of the image.' |
487 | 338 |
|
905 | 339 |
#settingsGridMagnification |
914 | 340 |
'Change the grid magnification of the edit view.' |
905 | 341 |
|
460 | 342 |
) |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
343 |
|
986 | 344 |
"Modified: / 7.9.1998 / 18:20:26 / cg" |
460 | 345 |
! ! |
346 |
||
737 | 347 |
!ImageEditor class methodsFor:'image specs'! |
348 |
||
349 |
leftMouseKeyIcon |
|
350 |
"This resource specification was automatically generated |
|
351 |
by the ImageEditor of ST/X." |
|
352 |
||
353 |
"Do not manually edit this!! If it is corrupted, |
|
354 |
the ImageEditor may not be able to read the specification." |
|
355 |
||
356 |
" |
|
357 |
ImageEditor openOnClass:self andSelector:#leftMouseKeyIcon |
|
358 |
" |
|
359 |
||
360 |
<resource: #image> |
|
361 |
||
362 |
^Icon |
|
363 |
constantNamed:#'ImageEditor leftMouseKeyIcon' |
|
364 |
ifAbsentPut:[(Depth2Image new) width: 16; height: 16; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@JEE@@B!!QP@@(TT@@@@@@@AUUP@@UUT@@EUU@@AUUP@@UUT@@EUU@@@UU@@@@@@@@@@@@@@a') ; colorMapFromArray:#[0 0 0 255 255 255 255 0 0 0 255 0]; mask:((Depth1Image new) width: 16; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@?0G? _>A?8G? _>A?8G? _>A?8G? O<@_ @@@b') ; yourself); yourself]! |
|
365 |
||
366 |
rightMouseKeyIcon |
|
367 |
"This resource specification was automatically generated |
|
368 |
by the ImageEditor of ST/X." |
|
369 |
||
370 |
"Do not manually edit this!! If it is corrupted, |
|
371 |
the ImageEditor may not be able to read the specification." |
|
372 |
||
373 |
" |
|
374 |
ImageEditor openOnClass:self andSelector:#rightMouseKeyIcon |
|
375 |
" |
|
376 |
||
377 |
<resource: #image> |
|
378 |
||
379 |
^Icon |
|
380 |
constantNamed:#'ImageEditor rightMouseKeyIcon' |
|
381 |
ifAbsentPut:[(Depth2Image new) width: 16; height: 16; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@EEJ@@AQR @@TT(@@@@@@@AUUP@@UUT@@EUU@@AUUP@@UUT@@EUU@@@UU@@@@@@@@@@@@@@a') ; colorMapFromArray:#[0 0 0 255 255 255 255 0 0 0 255 0]; mask:((Depth1Image new) width: 16; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@?0G? _>A?8G? _>A?8G? _>A?8G? O<@_ @@@b') ; yourself); yourself]! ! |
|
382 |
||
400 | 383 |
!ImageEditor class methodsFor:'interface specs'! |
384 |
||
767 | 385 |
dialogSpecForNewImage |
737 | 386 |
"This resource specification was automatically generated |
387 |
by the UIPainter of ST/X." |
|
519 | 388 |
|
737 | 389 |
"Do not manually edit this!! If it is corrupted, |
390 |
the UIPainter may not be able to read the specification." |
|
519 | 391 |
|
392 |
" |
|
767 | 393 |
UIPainter new openOnClass:ImageEditor andSelector:#dialogSpecForNewImage |
394 |
ImageEditor new openInterface:#dialogSpecForNewImage |
|
519 | 395 |
" |
396 |
||
397 |
<resource: #canvas> |
|
398 |
||
399 |
^ |
|
400 |
||
401 |
#(#FullSpec |
|
672 | 402 |
#window: |
519 | 403 |
#(#WindowSpec |
672 | 404 |
#name: 'New Image' |
975 | 405 |
#layout: #(#LayoutFrame 81 0 288 0 381 0 406 0) |
672 | 406 |
#label: 'New Image' |
407 |
#min: #(#Point 10 10) |
|
408 |
#max: #(#Point 1152 900) |
|
975 | 409 |
#bounds: #(#Rectangle 81 288 382 407) |
672 | 410 |
#usePreferredExtent: false |
519 | 411 |
) |
672 | 412 |
#component: |
519 | 413 |
#(#SpecCollection |
672 | 414 |
#collection: |
519 | 415 |
#( |
416 |
#(#ViewSpec |
|
672 | 417 |
#name: 'View' |
737 | 418 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -35 1.0) |
672 | 419 |
#component: |
519 | 420 |
#(#SpecCollection |
672 | 421 |
#collection: |
519 | 422 |
#( |
423 |
#(#FramedBoxSpec |
|
672 | 424 |
#name: 'framedBox1' |
932
7111238cda23
fixed dimension of new-image dialog.
Claus Gittinger <cg@exept.de>
parents:
930
diff
changeset
|
425 |
#layout: #(#LayoutFrame 1 0.0 7 0.0 0 0.4 76 0) |
672 | 426 |
#component: |
519 | 427 |
#(#SpecCollection |
672 | 428 |
#collection: |
519 | 429 |
#( |
430 |
#(#ComboBoxSpec |
|
672 | 431 |
#name: 'defaultSizesComboBox' |
975 | 432 |
#layout: #(#LayoutFrame 0 0.0 10 0.0 0 1 35 0.0) |
672 | 433 |
#model: #selectionOfSize |
434 |
#type: #string |
|
435 |
#comboList: #listOfDefaultSizes |
|
519 | 436 |
) |
437 |
) |
|
438 |
) |
|
672 | 439 |
#label: 'Size' |
440 |
#labelPosition: #topLeft |
|
441 |
#style: #(#FontDescription #helvetica #medium #roman 12) |
|
519 | 442 |
) |
443 |
#(#FramedBoxSpec |
|
672 | 444 |
#name: 'framedBox2' |
932
7111238cda23
fixed dimension of new-image dialog.
Claus Gittinger <cg@exept.de>
parents:
930
diff
changeset
|
445 |
#layout: #(#LayoutFrame 0 0.4 7 0.0 -1 1.0 76 0) |
672 | 446 |
#component: |
519 | 447 |
#(#SpecCollection |
672 | 448 |
#collection: |
519 | 449 |
#( |
450 |
#(#ComboListSpec |
|
672 | 451 |
#name: 'colorMapComboBox' |
975 | 452 |
#layout: #(#LayoutFrame 0 0.0 10 0.0 0 1 35 0.0) |
672 | 453 |
#model: #selectionOfColorMap |
454 |
#comboList: #listOfColorMaps |
|
455 |
#useIndex: false |
|
519 | 456 |
) |
457 |
) |
|
458 |
) |
|
672 | 459 |
#label: 'Color Map' |
460 |
#labelPosition: #topLeft |
|
461 |
#style: #(#FontDescription #helvetica #medium #roman 12) |
|
519 | 462 |
) |
463 |
) |
|
464 |
) |
|
672 | 465 |
#level: 1 |
519 | 466 |
) |
672 | 467 |
#(#UISubSpecification |
975 | 468 |
#name: 'windowSpecForCommitWithoutChannels' |
737 | 469 |
#layout: #(#LayoutFrame 2 0.0 -26 1 -2 1.0 -2 1.0) |
672 | 470 |
#minorKey: #windowSpecForCommitWithoutChannels |
519 | 471 |
) |
472 |
) |
|
473 |
) |
|
474 |
) |
|
767 | 475 |
! |
476 |
||
1045 | 477 |
gropDialogSpec |
986 | 478 |
"This resource specification was automatically generated |
479 |
by the UIPainter of ST/X." |
|
480 |
||
481 |
"Do not manually edit this!! If it is corrupted, |
|
482 |
the UIPainter may not be able to read the specification." |
|
483 |
||
484 |
" |
|
485 |
UIPainter new openOnClass:ImageEditor andSelector:#grobDialogSpec |
|
486 |
ImageEditor new openInterface:#grobDialogSpec |
|
487 |
" |
|
488 |
||
489 |
<resource: #canvas> |
|
490 |
||
491 |
^ |
|
492 |
||
493 |
#(#FullSpec |
|
494 |
#window: |
|
495 |
#(#WindowSpec |
|
1045 | 496 |
#name: 'Crop Borders' |
986 | 497 |
#layout: #(#LayoutFrame 22 0 233 0 266 0 415 0) |
1045 | 498 |
#label: 'Crop Borders' |
986 | 499 |
#min: #(#Point 10 10) |
500 |
#max: #(#Point 800 478) |
|
501 |
#bounds: #(#Rectangle 22 233 267 416) |
|
502 |
#usePreferredExtent: false |
|
503 |
) |
|
504 |
#component: |
|
505 |
#(#SpecCollection |
|
506 |
#collection: |
|
507 |
#( |
|
508 |
#(#LabelSpec |
|
509 |
#name: 'Label1' |
|
510 |
#layout: #(#LayoutFrame 14 0 21 0 90 0 43 0) |
|
511 |
#label: 'Left:' |
|
512 |
#translateLabel: true |
|
513 |
#adjust: #right |
|
514 |
) |
|
515 |
#(#InputFieldSpec |
|
516 |
#name: 'EntryField1' |
|
517 |
#layout: #(#LayoutFrame 95 0 21 0 132 0 43 0) |
|
518 |
#model: #left |
|
519 |
#type: #number |
|
520 |
) |
|
521 |
#(#LabelSpec |
|
522 |
#name: 'Label2' |
|
523 |
#layout: #(#LayoutFrame 14 0 51 0 90 0 73 0) |
|
524 |
#label: 'Right:' |
|
525 |
#translateLabel: true |
|
526 |
#adjust: #right |
|
527 |
) |
|
528 |
#(#InputFieldSpec |
|
529 |
#name: 'EntryField2' |
|
530 |
#layout: #(#LayoutFrame 95 0 51 0 132 0 73 0) |
|
531 |
#model: #right |
|
532 |
#type: #number |
|
533 |
) |
|
534 |
#(#LabelSpec |
|
535 |
#name: 'Label3' |
|
536 |
#layout: #(#LayoutFrame 14 0 81 0 90 0 103 0) |
|
537 |
#label: 'Top:' |
|
538 |
#translateLabel: true |
|
539 |
#adjust: #right |
|
540 |
) |
|
541 |
#(#InputFieldSpec |
|
542 |
#name: 'EntryField3' |
|
543 |
#layout: #(#LayoutFrame 95 0 81 0 132 0 103 0) |
|
544 |
#model: #top |
|
545 |
#type: #number |
|
546 |
) |
|
547 |
#(#LabelSpec |
|
548 |
#name: 'Label4' |
|
549 |
#layout: #(#LayoutFrame 14 0 111 0 90 0 133 0) |
|
550 |
#label: 'Bottom:' |
|
551 |
#translateLabel: true |
|
552 |
#adjust: #right |
|
553 |
) |
|
554 |
#(#InputFieldSpec |
|
555 |
#name: 'EntryField4' |
|
556 |
#layout: #(#LayoutFrame 95 0 111 0 132 0 133 0) |
|
557 |
#model: #bottom |
|
558 |
#type: #number |
|
559 |
) |
|
560 |
#(#HorizontalPanelViewSpec |
|
561 |
#name: 'HorizontalPanel1' |
|
562 |
#layout: #(#LayoutFrame 0 0.0 -30 1 0 1.0 0 1) |
|
563 |
#component: |
|
564 |
#(#SpecCollection |
|
565 |
#collection: |
|
566 |
#( |
|
567 |
#(#ActionButtonSpec |
|
568 |
#name: 'Button1' |
|
569 |
#label: 'Cancel' |
|
570 |
#translateLabel: true |
|
571 |
#model: #cancel |
|
572 |
#extent: #(#Point 118 22) |
|
573 |
) |
|
574 |
#(#ActionButtonSpec |
|
575 |
#name: 'Button2' |
|
576 |
#label: 'OK' |
|
577 |
#translateLabel: true |
|
578 |
#model: #accept |
|
579 |
#extent: #(#Point 118 22) |
|
580 |
) |
|
581 |
) |
|
582 |
) |
|
583 |
#horizontalLayout: #fitSpace |
|
584 |
#verticalLayout: #center |
|
585 |
#horizontalSpace: 3 |
|
586 |
#verticalSpace: 3 |
|
587 |
) |
|
588 |
) |
|
589 |
) |
|
590 |
) |
|
591 |
||
592 |
"Modified: / 7.9.1998 / 18:29:34 / cg" |
|
593 |
! |
|
594 |
||
767 | 595 |
windowSpec |
596 |
"This resource specification was automatically generated |
|
597 |
by the UIPainter of ST/X." |
|
598 |
||
599 |
"Do not manually edit this!! If it is corrupted, |
|
600 |
the UIPainter may not be able to read the specification." |
|
601 |
||
602 |
" |
|
603 |
UIPainter new openOnClass:ImageEditor andSelector:#windowSpec |
|
604 |
ImageEditor new openInterface:#windowSpec |
|
605 |
ImageEditor open |
|
606 |
" |
|
607 |
||
608 |
<resource: #canvas> |
|
609 |
||
610 |
^ |
|
611 |
||
612 |
#(#FullSpec |
|
613 |
#window: |
|
614 |
#(#WindowSpec |
|
615 |
#name: 'Image Editor' |
|
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
616 |
#layout: #(#LayoutFrame 507 0 28 0 1004 0 371 0) |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
617 |
#level: 0 |
767 | 618 |
#label: 'Image Editor' |
619 |
#min: #(#Point 400 320) |
|
620 |
#max: #(#Point 1152 900) |
|
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
621 |
#bounds: #(#Rectangle 507 28 1005 372) |
767 | 622 |
#menu: #menu |
623 |
#usePreferredExtent: false |
|
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
624 |
#returnIsOKInDialog: true |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
625 |
#escapeIsCancelInDialog: true |
767 | 626 |
) |
627 |
#component: |
|
628 |
#(#SpecCollection |
|
629 |
#collection: |
|
630 |
#( |
|
631 |
#(#MenuPanelSpec |
|
632 |
#name: 'menuToolbarView' |
|
633 |
#layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 32 0) |
|
634 |
#menu: #menuToolbar |
|
635 |
#style: #(#FontDescription #helvetica #medium #roman 10) |
|
636 |
#showSeparatingLines: true |
|
637 |
) |
|
638 |
#(#VariableHorizontalPanelSpec |
|
639 |
#name: 'variableHorizontalPanel1' |
|
640 |
#layout: #(#LayoutFrame 0 0.0 34 0.0 0 1.0 -26 1.0) |
|
641 |
#component: |
|
642 |
#(#SpecCollection |
|
643 |
#collection: |
|
644 |
#( |
|
645 |
#(#ViewSpec |
|
646 |
#name: 'view1' |
|
647 |
#component: |
|
648 |
#(#SpecCollection |
|
649 |
#collection: |
|
650 |
#( |
|
651 |
#(#VariableVerticalPanelSpec |
|
652 |
#name: 'VariableVerticalPanel1' |
|
653 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
654 |
#component: |
|
655 |
#(#SpecCollection |
|
656 |
#collection: |
|
657 |
#( |
|
658 |
#(#ViewSpec |
|
659 |
#name: 'View1' |
|
660 |
#component: |
|
661 |
#(#SpecCollection |
|
662 |
#collection: |
|
663 |
#( |
|
664 |
#(#MenuPanelSpec |
|
665 |
#name: 'MouseButtonColorToolBar' |
|
666 |
#layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 24 0) |
|
667 |
#menu: #menuMouseButtonColors |
|
668 |
) |
|
669 |
#(#DataSetSpec |
|
670 |
#name: 'colorDataSetView' |
|
671 |
#layout: #(#LayoutFrame 0 0.0 26 0.0 0 1.0 0 1.0) |
|
672 |
#activeHelpKey: #colorMapTable |
|
673 |
#model: #selectionOfColor |
|
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
674 |
#menu: #colorMapMenu |
767 | 675 |
#style: #(#FontDescription #helvetica #medium #roman 10) |
676 |
#hasHorizontalScrollBar: true |
|
677 |
#hasVerticalScrollBar: true |
|
678 |
#miniScrollerHorizontal: true |
|
679 |
#miniScrollerVertical: true |
|
680 |
#dataList: #listOfColors |
|
681 |
#has3Dsepartors: true |
|
905 | 682 |
#has3Dseparators: true |
767 | 683 |
#verticalSpacing: 1 |
684 |
#columns: |
|
685 |
#( |
|
686 |
#(#DataSetColumnSpec |
|
687 |
#rendererType: #rowSelector |
|
688 |
#backgroundSelector: #yourself |
|
689 |
) |
|
690 |
#(#DataSetColumnSpec |
|
691 |
#label: 'R' |
|
692 |
#labelAlignment: #left |
|
942 | 693 |
#columnAlignment: #right |
694 |
#editorType: #InputField |
|
695 |
#type: #number |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
696 |
#model: #redFromColor: |
942 | 697 |
#writeSelector: #redAtColor:put: |
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
698 |
#selectSelector: #canSelectRedInColor: |
767 | 699 |
) |
700 |
#(#DataSetColumnSpec |
|
701 |
#label: 'G' |
|
702 |
#labelAlignment: #left |
|
942 | 703 |
#columnAlignment: #right |
704 |
#editorType: #InputField |
|
705 |
#type: #number |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
706 |
#model: #greenFromColor: |
942 | 707 |
#writeSelector: #greenAtColor:put: |
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
708 |
#selectSelector: #canSelectGreenInColor: |
767 | 709 |
) |
710 |
#(#DataSetColumnSpec |
|
711 |
#label: 'B' |
|
712 |
#labelAlignment: #left |
|
942 | 713 |
#columnAlignment: #right |
714 |
#editorType: #InputField |
|
715 |
#type: #number |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
716 |
#model: #blueFromColor: |
942 | 717 |
#writeSelector: #blueAtColor:put: |
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
718 |
#selectSelector: #canSelectBlueInColor: |
767 | 719 |
) |
720 |
) |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
721 |
#columnAdaptor: #colorColumnAdaptor |
767 | 722 |
) |
723 |
) |
|
724 |
) |
|
725 |
) |
|
726 |
#(#ArbitraryComponentSpec |
|
727 |
#name: 'imagePreView' |
|
728 |
#activeHelpKey: #previewView |
|
729 |
#hasHorizontalScrollBar: true |
|
730 |
#hasVerticalScrollBar: true |
|
731 |
#miniScrollerHorizontal: true |
|
732 |
#miniScrollerVertical: true |
|
733 |
#component: #ImageView |
|
734 |
#hasBorder: false |
|
735 |
) |
|
736 |
) |
|
737 |
) |
|
738 |
#handles: #(#Any 0.723776 1.0) |
|
739 |
) |
|
740 |
) |
|
741 |
) |
|
742 |
) |
|
743 |
#(#ViewSpec |
|
744 |
#name: 'view2' |
|
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
745 |
#level: -1 |
767 | 746 |
#component: |
747 |
#(#SpecCollection |
|
748 |
#collection: |
|
749 |
#( |
|
750 |
#(#ArbitraryComponentSpec |
|
751 |
#name: 'imageEditView' |
|
752 |
#layout: #(#LayoutFrame 2 0.0 2 0.0 -2 1.0 -24 1.0) |
|
753 |
#hasHorizontalScrollBar: true |
|
754 |
#hasVerticalScrollBar: true |
|
755 |
#component: #ImageEditView |
|
756 |
#hasBorder: false |
|
757 |
) |
|
758 |
#(#LabelSpec |
|
759 |
#name: 'coordLabel' |
|
760 |
#layout: #(#LayoutFrame 2 0.0 -22 1 -83 1.0 0 1.0) |
|
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
761 |
#level: -1 |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
762 |
#labelChannel: #imageInfoHolder |
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
763 |
#resizeForLabel: false |
767 | 764 |
#adjust: #left |
765 |
) |
|
766 |
#(#ArrowButtonSpec |
|
767 |
#name: 'magnifyDownButton' |
|
768 |
#layout: #(#LayoutFrame -80 1 -22 1 -58 1 0 1) |
|
769 |
#activeHelpKey: #magnifyImageDown |
|
770 |
#model: #doMagnifyDown |
|
771 |
#enableChannel: #imageIsLoaded |
|
772 |
#isTriggerOnDown: true |
|
773 |
#direction: #left |
|
774 |
) |
|
775 |
#(#ArrowButtonSpec |
|
776 |
#name: 'magnifyUpButton' |
|
777 |
#layout: #(#LayoutFrame -24 1 -22 1 -2 1 0 1) |
|
778 |
#activeHelpKey: #magnifyImageUp |
|
779 |
#model: #doMagnifyUp |
|
780 |
#enableChannel: #imageIsLoaded |
|
781 |
#isTriggerOnDown: true |
|
782 |
#direction: #right |
|
783 |
) |
|
784 |
#(#InputFieldSpec |
|
785 |
#name: 'magnificationInputField' |
|
786 |
#layout: #(#LayoutFrame -57 1 -22 1 -26 1 0 1) |
|
787 |
#activeHelpKey: #magnificationNumber |
|
788 |
#enableChannel: #imageIsLoaded |
|
789 |
#model: #valueOfMagnification |
|
905 | 790 |
#type: #numberInRange |
767 | 791 |
#acceptOnReturn: false |
792 |
#acceptOnTab: false |
|
793 |
#numChars: 2 |
|
905 | 794 |
#minValue: 1 |
795 |
#maxValue: 99 |
|
767 | 796 |
) |
797 |
) |
|
798 |
) |
|
799 |
) |
|
800 |
) |
|
801 |
) |
|
802 |
#handles: #(#Any 0.276 1.0) |
|
803 |
) |
|
804 |
#(#UISubSpecification |
|
805 |
#name: 'infoBarSubSpec' |
|
806 |
#layout: #(#LayoutFrame 0 0.0 -24 1 0 1.0 0 1.0) |
|
807 |
#majorKey: #ToolApplicationModel |
|
808 |
#minorKey: #windowSpecForInfoBar |
|
809 |
) |
|
810 |
) |
|
811 |
) |
|
812 |
) |
|
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
813 |
|
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
814 |
"Modified: / 12.3.1999 / 00:15:05 / cg" |
519 | 815 |
! ! |
816 |
||
817 |
!ImageEditor class methodsFor:'menu specs'! |
|
818 |
||
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
819 |
colorMapMenu |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
820 |
"This resource specification was automatically generated |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
821 |
by the MenuEditor of ST/X." |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
822 |
|
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
823 |
"Do not manually edit this!! If it is corrupted, |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
824 |
the MenuEditor may not be able to read the specification." |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
825 |
|
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
826 |
" |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
827 |
MenuEditor new openOnClass:ImageEditor andSelector:#menuSpec |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
828 |
(Menu new fromLiteralArrayEncoding:(ImageEditor menuSpec)) startUp |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
829 |
" |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
830 |
|
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
831 |
<resource: #menu> |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
832 |
|
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
833 |
^ |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
834 |
|
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
835 |
#(#Menu |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
836 |
|
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
837 |
#( |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
838 |
#(#MenuItem |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
839 |
#label: 'Add Color' |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
840 |
#translateLabel: true |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
841 |
#value: #addColorToColormap |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
842 |
) |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
843 |
) nil |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
844 |
nil |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
845 |
) |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
846 |
|
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
847 |
"Created: / 12.3.1999 / 00:19:00 / cg" |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
848 |
! |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
849 |
|
400 | 850 |
menu |
737 | 851 |
"This resource specification was automatically generated |
852 |
by the MenuEditor of ST/X." |
|
400 | 853 |
|
737 | 854 |
"Do not manually edit this!! If it is corrupted, |
855 |
the MenuEditor may not be able to read the specification." |
|
400 | 856 |
|
857 |
" |
|
858 |
MenuEditor new openOnClass:ImageEditor andSelector:#menu |
|
859 |
(Menu new fromLiteralArrayEncoding:(ImageEditor menu)) startUp |
|
860 |
" |
|
861 |
||
862 |
<resource: #menu> |
|
863 |
||
1124 | 864 |
^ |
865 |
#(#Menu |
|
866 |
#( |
|
867 |
#(#MenuItem |
|
868 |
#label: 'About' |
|
869 |
#translateLabel: true |
|
870 |
#activeHelpKey: #about |
|
871 |
#labelImage: #(#ResourceRetriever nil #menuIcon) |
|
872 |
#submenuChannel: #menuAbout |
|
873 |
) |
|
874 |
#(#MenuItem |
|
875 |
#label: 'File' |
|
876 |
#translateLabel: true |
|
877 |
#activeHelpKey: #file |
|
878 |
#submenu: |
|
879 |
#(#Menu |
|
880 |
#( |
|
881 |
#(#MenuItem |
|
882 |
#label: 'New...' |
|
883 |
#translateLabel: true |
|
884 |
#value: #doNewImage |
|
885 |
#activeHelpKey: #fileNewImage |
|
886 |
) |
|
887 |
#(#MenuItem |
|
888 |
#label: '-' |
|
889 |
) |
|
890 |
#(#MenuItem |
|
891 |
#label: 'Load...' |
|
892 |
#translateLabel: true |
|
893 |
#value: #doLoadFromClass |
|
894 |
#activeHelpKey: #fileLoadFromClass |
|
895 |
) |
|
896 |
#(#MenuItem |
|
897 |
#label: 'Load From File...' |
|
898 |
#translateLabel: true |
|
899 |
#value: #doLoadFromFile |
|
900 |
#activeHelpKey: #fileLoadFromFile |
|
901 |
) |
|
902 |
#(#MenuItem |
|
903 |
#label: 'Grab From Screen' |
|
904 |
#translateLabel: true |
|
905 |
#value: #grabScreenImage |
|
906 |
#activeHelpKey: #fileGrabImage |
|
907 |
) |
|
908 |
#(#MenuItem |
|
909 |
#label: '-' |
|
910 |
) |
|
911 |
#(#MenuItem |
|
912 |
#label: 'Save' |
|
913 |
#translateLabel: true |
|
914 |
#value: #doSaveMethod |
|
915 |
#activeHelpKey: #fileSaveMethod |
|
916 |
#enabled: #imageIsLoadedAndClassDefined |
|
917 |
) |
|
918 |
#(#MenuItem |
|
919 |
#label: 'Save As...' |
|
920 |
#translateLabel: true |
|
921 |
#value: #doSaveMethodAs |
|
922 |
#activeHelpKey: #fileSaveMethodAs |
|
923 |
#enabled: #imageIsLoaded |
|
924 |
) |
|
925 |
#(#MenuItem |
|
926 |
#label: '-' |
|
927 |
) |
|
928 |
#(#MenuItem |
|
929 |
#label: 'Save To File...' |
|
930 |
#translateLabel: true |
|
931 |
#value: #doSaveImageFileAs |
|
932 |
#activeHelpKey: #fileSaveAs |
|
933 |
#enabled: #imageIsLoaded |
|
934 |
) |
|
935 |
#(#MenuItem |
|
936 |
#label: 'Save Mask To File...' |
|
937 |
#translateLabel: true |
|
938 |
#value: #doSaveImageMaskFileAs |
|
939 |
#activeHelpKey: #fileSaveMaskAs |
|
940 |
#enabled: #imageIsLoaded |
|
941 |
) |
|
942 |
#(#MenuItem |
|
943 |
#label: '-' |
|
944 |
) |
|
945 |
#(#MenuItem |
|
1309
0a45ef81b47e
added showStoreString menu function
Claus Gittinger <cg@exept.de>
parents:
1250
diff
changeset
|
946 |
#label: 'Show storeString' |
0a45ef81b47e
added showStoreString menu function
Claus Gittinger <cg@exept.de>
parents:
1250
diff
changeset
|
947 |
#translateLabel: true |
0a45ef81b47e
added showStoreString menu function
Claus Gittinger <cg@exept.de>
parents:
1250
diff
changeset
|
948 |
#value: #doShowStoreString |
0a45ef81b47e
added showStoreString menu function
Claus Gittinger <cg@exept.de>
parents:
1250
diff
changeset
|
949 |
#activeHelpKey: #fileShowStoreString |
0a45ef81b47e
added showStoreString menu function
Claus Gittinger <cg@exept.de>
parents:
1250
diff
changeset
|
950 |
#enabled: #imageIsLoaded |
0a45ef81b47e
added showStoreString menu function
Claus Gittinger <cg@exept.de>
parents:
1250
diff
changeset
|
951 |
) |
0a45ef81b47e
added showStoreString menu function
Claus Gittinger <cg@exept.de>
parents:
1250
diff
changeset
|
952 |
#(#MenuItem |
0a45ef81b47e
added showStoreString menu function
Claus Gittinger <cg@exept.de>
parents:
1250
diff
changeset
|
953 |
#label: '-' |
0a45ef81b47e
added showStoreString menu function
Claus Gittinger <cg@exept.de>
parents:
1250
diff
changeset
|
954 |
) |
0a45ef81b47e
added showStoreString menu function
Claus Gittinger <cg@exept.de>
parents:
1250
diff
changeset
|
955 |
#(#MenuItem |
1124 | 956 |
#label: 'Print' |
957 |
#translateLabel: true |
|
958 |
#value: #doPrint |
|
959 |
#activeHelpKey: #filePrint |
|
960 |
#enabled: #imageIsLoaded |
|
961 |
) |
|
962 |
#(#MenuItem |
|
963 |
#label: '-' |
|
964 |
) |
|
965 |
#(#MenuItem |
|
966 |
#label: 'Browse Class' |
|
967 |
#translateLabel: true |
|
968 |
#value: #doBrowseClass |
|
969 |
#activeHelpKey: #fileBrowseClass |
|
970 |
#enabled: #hasClassDefined |
|
971 |
) |
|
972 |
#(#MenuItem |
|
973 |
#label: '-' |
|
974 |
) |
|
975 |
#(#MenuItem |
|
976 |
#label: 'Exit' |
|
977 |
#translateLabel: true |
|
978 |
#value: #closeRequest |
|
979 |
#activeHelpKey: #fileExit |
|
980 |
) |
|
981 |
) |
|
982 |
nil |
|
983 |
nil |
|
400 | 984 |
) |
1124 | 985 |
) |
986 |
#(#MenuItem |
|
987 |
#label: 'Edit' |
|
988 |
#translateLabel: true |
|
989 |
#activeHelpKey: #edit |
|
990 |
#enabled: #imageIsLoaded |
|
991 |
#submenu: |
|
992 |
#(#Menu |
|
993 |
#( |
|
994 |
#(#MenuItem |
|
995 |
#label: 'Undo' |
|
996 |
#translateLabel: true |
|
997 |
#value: #doUndo |
|
998 |
#activeHelpKey: #editUndo |
|
999 |
#enabled: #valueOfCanUndo |
|
1000 |
) |
|
1001 |
#(#MenuItem |
|
1002 |
#label: '-' |
|
1003 |
) |
|
1004 |
#(#MenuItem |
|
1005 |
#label: 'Flip - Vertical' |
|
1006 |
#translateLabel: true |
|
1007 |
#value: #doFlipVertical |
|
1008 |
#activeHelpKey: #editFlipVertical |
|
1009 |
) |
|
1010 |
#(#MenuItem |
|
1011 |
#label: 'Flip - Horizontal' |
|
1012 |
#translateLabel: true |
|
1013 |
#value: #doFlipHorizontal |
|
1014 |
#activeHelpKey: #editFlipHorizontal |
|
1015 |
) |
|
1016 |
#(#MenuItem |
|
1017 |
#label: '-' |
|
1018 |
) |
|
1019 |
#(#MenuItem |
|
1020 |
#label: 'Resize...' |
|
1021 |
#translateLabel: true |
|
1022 |
#value: #doResizeImage |
|
1023 |
#activeHelpKey: #editResize |
|
1024 |
) |
|
1025 |
#(#MenuItem |
|
1026 |
#label: 'Magnify...' |
|
1027 |
#translateLabel: true |
|
1028 |
#value: #doMagnifyImage |
|
1029 |
#activeHelpKey: #editMagnifyImage |
|
1030 |
) |
|
1031 |
#(#MenuItem |
|
1032 |
#label: 'Rotate...' |
|
1033 |
#translateLabel: true |
|
1034 |
#value: #doRotateImage |
|
1035 |
#activeHelpKey: #editRotate |
|
1036 |
) |
|
1037 |
#(#MenuItem |
|
1038 |
#label: '-' |
|
1039 |
) |
|
1040 |
#(#MenuItem |
|
1146 | 1041 |
#label: 'Invert' |
1042 |
#translateLabel: true |
|
1043 |
#value: #doNegativeImage |
|
1044 |
) |
|
1045 |
#(#MenuItem |
|
1046 |
#label: '-' |
|
1047 |
) |
|
1048 |
#(#MenuItem |
|
1124 | 1049 |
#label: 'Crop' |
1050 |
#translateLabel: true |
|
1051 |
#submenu: |
|
400 | 1052 |
#(#Menu |
1124 | 1053 |
#( |
1054 |
#(#MenuItem |
|
1055 |
#label: 'All' |
|
1056 |
#translateLabel: true |
|
1057 |
#value: #doCropAll |
|
1058 |
#activeHelpKey: #cropAll |
|
400 | 1059 |
) |
1124 | 1060 |
#(#MenuItem |
1061 |
#label: '-' |
|
986 | 1062 |
) |
1124 | 1063 |
#(#MenuItem |
1064 |
#label: 'Left' |
|
1065 |
#translateLabel: true |
|
1066 |
#value: #doCropLeft |
|
1067 |
#activeHelpKey: #cropLeft |
|
1068 |
) |
|
1069 |
#(#MenuItem |
|
1070 |
#label: 'Right' |
|
1071 |
#translateLabel: true |
|
1072 |
#value: #doCropRight |
|
1073 |
#activeHelpKey: #cropRight |
|
986 | 1074 |
) |
1124 | 1075 |
#(#MenuItem |
1076 |
#label: 'Top' |
|
1077 |
#translateLabel: true |
|
1078 |
#value: #doCropTop |
|
1079 |
#activeHelpKey: #cropTop |
|
672 | 1080 |
) |
1124 | 1081 |
#(#MenuItem |
1082 |
#label: 'Bottom' |
|
1083 |
#translateLabel: true |
|
1084 |
#value: #doCropBottom |
|
1085 |
#activeHelpKey: #cropBottom |
|
400 | 1086 |
) |
1124 | 1087 |
#(#MenuItem |
1088 |
#label: '-' |
|
400 | 1089 |
) |
1124 | 1090 |
#(#MenuItem |
1091 |
#label: 'Manual...' |
|
1092 |
#translateLabel: true |
|
1093 |
#value: #doCropManual |
|
1094 |
#activeHelpKey: #cropManual |
|
400 | 1095 |
) |
1124 | 1096 |
) |
1097 |
nil |
|
400 | 1098 |
nil |
1124 | 1099 |
) |
400 | 1100 |
) |
1124 | 1101 |
) |
1102 |
nil |
|
1103 |
nil |
|
400 | 1104 |
) |
1124 | 1105 |
) |
1106 |
#(#MenuItem |
|
1107 |
#label: 'ColorMap' |
|
1108 |
#translateLabel: true |
|
1109 |
#activeHelpKey: #colorMap |
|
1110 |
#enabled: #imageIsLoaded |
|
1111 |
#submenu: |
|
1112 |
#(#Menu |
|
1113 |
#( |
|
1114 |
#(#MenuItem |
|
1115 |
#label: '8-Plane' |
|
1116 |
#translateLabel: true |
|
1117 |
#value: #colorMapMode: |
|
1118 |
#activeHelpKey: #colorMap8 |
|
1119 |
#argument: '8-plane' |
|
1120 |
#choice: #colorMapMode |
|
1121 |
#choiceValue: '8-plane' |
|
1122 |
) |
|
1123 |
#(#MenuItem |
|
1124 |
#label: '4-Plane' |
|
1125 |
#translateLabel: true |
|
1126 |
#value: #colorMapMode: |
|
1127 |
#activeHelpKey: #colorMap4 |
|
1128 |
#argument: '4-plane' |
|
1129 |
#choice: #colorMapMode |
|
1130 |
#choiceValue: '4-plane' |
|
1131 |
) |
|
1132 |
#(#MenuItem |
|
1133 |
#label: '2-Plane' |
|
1134 |
#translateLabel: true |
|
1135 |
#value: #colorMapMode: |
|
1136 |
#activeHelpKey: #colorMap2 |
|
1137 |
#argument: '2-plane' |
|
1138 |
#choice: #colorMapMode |
|
1139 |
#choiceValue: '2-plane' |
|
1140 |
) |
|
1141 |
#(#MenuItem |
|
1142 |
#label: '1-Plane' |
|
1143 |
#translateLabel: true |
|
1144 |
#value: #colorMapMode: |
|
1145 |
#activeHelpKey: #colorMap1 |
|
1146 |
#argument: '1-plane' |
|
1147 |
#choice: #colorMapMode |
|
1148 |
#choiceValue: '1-plane' |
|
1149 |
) |
|
1150 |
#(#MenuItem |
|
1151 |
#label: '-' |
|
1152 |
) |
|
1153 |
#(#MenuItem |
|
1154 |
#label: '8-Plane + Mask' |
|
1155 |
#translateLabel: true |
|
1156 |
#value: #colorMapMode: |
|
1157 |
#activeHelpKey: #colorMap8M |
|
1158 |
#argument: '8-plane + mask' |
|
1159 |
#choice: #colorMapMode |
|
1160 |
#choiceValue: '8-plane + mask' |
|
1161 |
) |
|
1162 |
#(#MenuItem |
|
1163 |
#label: '4-Plane + Mask' |
|
1164 |
#translateLabel: true |
|
1165 |
#value: #colorMapMode: |
|
1166 |
#activeHelpKey: #colorMap4M |
|
1167 |
#argument: '4-plane + mask' |
|
1168 |
#choice: #colorMapMode |
|
1169 |
#choiceValue: '4-plane + mask' |
|
737 | 1170 |
) |
1124 | 1171 |
#(#MenuItem |
1172 |
#label: '2-Plane + Mask' |
|
1173 |
#translateLabel: true |
|
1174 |
#value: #colorMapMode: |
|
1175 |
#activeHelpKey: #colorMap2M |
|
1176 |
#argument: '2-plane + mask' |
|
1177 |
#choice: #colorMapMode |
|
1178 |
#choiceValue: '2-plane + mask' |
|
1179 |
) |
|
1180 |
#(#MenuItem |
|
1181 |
#label: '1-Plane + Mask' |
|
1182 |
#translateLabel: true |
|
1183 |
#value: #colorMapMode: |
|
1184 |
#activeHelpKey: #colorMap1M |
|
1185 |
#argument: '1-plane + mask' |
|
1186 |
#choice: #colorMapMode |
|
1187 |
#choiceValue: '1-plane + mask' |
|
1188 |
) |
|
1189 |
#(#MenuItem |
|
1190 |
#label: '-' |
|
1191 |
) |
|
1192 |
#(#MenuItem |
|
1193 |
#label: 'Compress colormap' |
|
1194 |
#translateLabel: true |
|
1195 |
#value: #compressColorMap |
|
1196 |
#activeHelpKey: #compressColormap |
|
1197 |
#enabled: #hasColormap |
|
1198 |
) |
|
1199 |
#(#MenuItem |
|
1200 |
#label: 'Sort colormap' |
|
1201 |
#translateLabel: true |
|
1202 |
#value: #sortColorMap |
|
1203 |
#enabled: #hasColormap |
|
1204 |
) |
|
1205 |
#(#MenuItem |
|
1206 |
#label: '-' |
|
1207 |
) |
|
1208 |
#(#MenuItem |
|
1209 |
#label: 'Reduce number of colors...' |
|
1210 |
#translateLabel: true |
|
1211 |
#value: #reduceNumberOfColors |
|
1212 |
) |
|
1213 |
) |
|
1214 |
nil |
|
1215 |
nil |
|
756 | 1216 |
) |
1124 | 1217 |
) |
1218 |
#(#MenuItem |
|
1219 |
#label: 'Settings' |
|
1220 |
#translateLabel: true |
|
1221 |
#submenu: |
|
1222 |
#(#Menu |
|
1223 |
#( |
|
1224 |
#(#MenuItem |
|
1353 | 1225 |
#label: 'Grid Magnification Limit...' |
1124 | 1226 |
#translateLabel: true |
1227 |
#value: #doChangeGridMagnification |
|
1228 |
#activeHelpKey: #settingsGridMagnification |
|
1229 |
) |
|
1230 |
) |
|
1231 |
nil |
|
1232 |
nil |
|
400 | 1233 |
) |
1124 | 1234 |
) |
1235 |
#(#MenuItem |
|
1236 |
#label: 'History' |
|
1237 |
#translateLabel: true |
|
1238 |
#activeHelpKey: #history |
|
1239 |
#submenuChannel: #menuHistory |
|
1240 |
) |
|
1241 |
#(#MenuItem |
|
1242 |
#label: 'Help' |
|
1243 |
#translateLabel: true |
|
1244 |
#startGroup: #right |
|
1245 |
#activeHelpKey: #help |
|
1246 |
#submenuChannel: #menuHelp |
|
1247 |
) |
|
1248 |
) |
|
1249 |
nil |
|
1250 |
nil |
|
400 | 1251 |
) |
1252 |
! |
|
1253 |
||
679 | 1254 |
menuMouseButtonColors |
737 | 1255 |
"This resource specification was automatically generated |
1256 |
by the MenuEditor of ST/X." |
|
679 | 1257 |
|
737 | 1258 |
"Do not manually edit this!! If it is corrupted, |
1259 |
the MenuEditor may not be able to read the specification." |
|
679 | 1260 |
|
1261 |
" |
|
1262 |
MenuEditor new openOnClass:ImageEditor andSelector:#menuMouseButtonColors |
|
1263 |
(Menu new fromLiteralArrayEncoding:(ImageEditor menuMouseButtonColors)) startUp |
|
1264 |
" |
|
1265 |
||
1266 |
<resource: #menu> |
|
1267 |
||
1268 |
^ |
|
1269 |
||
1270 |
#(#Menu |
|
1271 |
||
1272 |
#( |
|
1273 |
#(#MenuItem |
|
1274 |
#label: 'Left Mouse Button' |
|
1275 |
#nameKey: #leftMouseKeyButton |
|
1276 |
#activeHelpKey: #mouseKeyColorMode |
|
975 | 1277 |
#enabled: #imageIsLoaded |
679 | 1278 |
#labelImage: #(#ResourceRetriever nil #leftMouseKeyIcon) |
975 | 1279 |
#choice: #mouseKeyColorMode |
1280 |
#choiceValue: 1 |
|
679 | 1281 |
) |
1282 |
#(#MenuItem |
|
1283 |
#label: 'Right Mouse Button' |
|
1284 |
#nameKey: #rightMouseKeyButton |
|
1285 |
#activeHelpKey: #mouseKeyColorMode |
|
975 | 1286 |
#enabled: #imageIsLoaded |
679 | 1287 |
#labelImage: #(#ResourceRetriever nil #rightMouseKeyIcon) |
975 | 1288 |
#choice: #mouseKeyColorMode |
1289 |
#choiceValue: 2 |
|
679 | 1290 |
) |
1291 |
) nil |
|
1292 |
nil |
|
1293 |
) |
|
1294 |
! |
|
1295 |
||
400 | 1296 |
menuToolbar |
737 | 1297 |
"This resource specification was automatically generated |
1298 |
by the MenuEditor of ST/X." |
|
400 | 1299 |
|
737 | 1300 |
"Do not manually edit this!! If it is corrupted, |
1301 |
the MenuEditor may not be able to read the specification." |
|
400 | 1302 |
|
1303 |
" |
|
1304 |
MenuEditor new openOnClass:ImageEditor andSelector:#menuToolbar |
|
1305 |
(Menu new fromLiteralArrayEncoding:(ImageEditor menuToolbar)) startUp |
|
1306 |
" |
|
1307 |
||
1308 |
<resource: #menu> |
|
1309 |
||
1196 | 1310 |
^ |
1311 |
#(#Menu |
|
1312 |
#( |
|
1313 |
#(#MenuItem |
|
1314 |
#label: 'newImage' |
|
1315 |
#isButton: true |
|
1316 |
#value: #doNewImage |
|
1317 |
#activeHelpKey: #fileNewImage |
|
1318 |
#labelImage: #(#ResourceRetriever #Icon #newIcon) |
|
1319 |
) |
|
1320 |
#(#MenuItem |
|
1321 |
#label: 'loadFromClass' |
|
1322 |
#isButton: true |
|
1323 |
#value: #doLoadFromClass |
|
1324 |
#activeHelpKey: #fileLoadFromClass |
|
1325 |
#labelImage: #(#ResourceRetriever #Icon #loadIcon) |
|
1326 |
) |
|
1327 |
#(#MenuItem |
|
1328 |
#label: 'saveMethod' |
|
1329 |
#isButton: true |
|
1330 |
#value: #doSaveMethod |
|
1331 |
#activeHelpKey: #fileSaveMethod |
|
1332 |
#enabled: #imageIsLoaded |
|
1333 |
#labelImage: #(#ResourceRetriever #Icon #saveIcon) |
|
1334 |
) |
|
1335 |
#(#MenuItem |
|
1336 |
#label: '' |
|
1337 |
) |
|
1338 |
#(#MenuItem |
|
1339 |
#label: '' |
|
1340 |
) |
|
1341 |
#(#MenuItem |
|
1342 |
#label: '' |
|
1343 |
) |
|
1344 |
#(#MenuItem |
|
1345 |
#label: '' |
|
1346 |
) |
|
1347 |
#(#MenuItem |
|
1348 |
#label: 'Point' |
|
1349 |
#activeHelpKey: #drawModePoint |
|
1350 |
#enabled: #imageIsLoaded |
|
1351 |
#choice: #editMode |
|
1352 |
#choiceValue: #point |
|
1353 |
) |
|
1354 |
#(#MenuItem |
|
1355 |
#label: 'Rect' |
|
1356 |
#activeHelpKey: #drawModeBox |
|
1357 |
#enabled: #imageIsLoaded |
|
1358 |
#choice: #editMode |
|
1359 |
#choiceValue: #box |
|
1360 |
) |
|
1361 |
#(#MenuItem |
|
1362 |
#label: 'FillRect' |
|
1363 |
#activeHelpKey: #drawModeFilledBox |
|
1364 |
#enabled: #imageIsLoaded |
|
1365 |
#choice: #editMode |
|
1366 |
#choiceValue: #filledBox |
|
1367 |
) |
|
1368 |
#(#MenuItem |
|
1369 |
#label: 'Fill' |
|
1370 |
#activeHelpKey: #drawModeFill |
|
1371 |
#enabled: #imageIsLoaded |
|
1372 |
#choice: #editMode |
|
1373 |
#choiceValue: #fill |
|
1374 |
) |
|
1375 |
#(#MenuItem |
|
1376 |
#label: 'Copy' |
|
1377 |
#activeHelpKey: #drawModeCopy |
|
1378 |
#enabled: #imageIsLoaded |
|
1379 |
#choice: #editMode |
|
1380 |
#choiceValue: #copy |
|
1381 |
) |
|
1382 |
#(#MenuItem |
|
1383 |
#label: 'Paste' |
|
1384 |
#activeHelpKey: #drawModePaste |
|
1385 |
#enabled: #imageIsLoaded |
|
1386 |
#choice: #editMode |
|
1387 |
#choiceValue: #paste |
|
1388 |
) |
|
1389 |
#(#MenuItem |
|
1390 |
#label: 'Paste Under' |
|
1391 |
#activeHelpKey: #drawModePasteUnder |
|
1392 |
#enabled: #imageIsLoaded |
|
1393 |
#choice: #editMode |
|
1394 |
#choiceValue: #pasteUnder |
|
1395 |
) |
|
1396 |
) |
|
1397 |
nil |
|
1398 |
nil |
|
400 | 1399 |
) |
1400 |
! ! |
|
1401 |
||
1402 |
!ImageEditor methodsFor:'accessing'! |
|
1403 |
||
1404 |
image |
|
767 | 1405 |
"returns the current editing image" |
400 | 1406 |
|
911 | 1407 |
^imageEditView image |
400 | 1408 |
! |
1409 |
||
1410 |
postOpenAction: anAction |
|
767 | 1411 |
"sets an action which is evaluated after opening" |
400 | 1412 |
|
1413 |
postOpenAction := anAction |
|
1414 |
! ! |
|
1415 |
||
1416 |
!ImageEditor methodsFor:'accessing - views'! |
|
1417 |
||
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1418 |
colorDataSetView |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1419 |
"returns the view of the colormap" |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1420 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1421 |
^(builder componentAt: #colorDataSetView) |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1422 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1423 |
"Created: / 26.7.1998 / 12:02:14 / cg" |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1424 |
! |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1425 |
|
487 | 1426 |
coordLabel |
767 | 1427 |
"returns the view the coord label" |
487 | 1428 |
|
1429 |
^builder componentAt: #coordLabel |
|
1430 |
! |
|
1431 |
||
400 | 1432 |
imageEditView |
911 | 1433 |
"returns the view of the image" |
400 | 1434 |
|
1345 | 1435 |
^ imageEditView := (builder componentAt: #imageEditView) scrolledView |
1436 |
||
1437 |
"Modified: / 10.2.2000 / 23:19:20 / cg" |
|
400 | 1438 |
! |
1439 |
||
1440 |
imagePreView |
|
767 | 1441 |
"returns the preview of the image" |
400 | 1442 |
|
1443 |
^(builder componentAt: #imagePreView) subViews first |
|
475 | 1444 |
! ! |
1445 |
||
400 | 1446 |
!ImageEditor methodsFor:'aspects'! |
1447 |
||
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1448 |
activityInfoHolder |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1449 |
^ self valueOfInfoLabel |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1450 |
|
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1451 |
"Modified: / 29.7.1998 / 18:49:03 / cg" |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1452 |
! |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1453 |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1454 |
colorColumnAdaptor |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1455 |
^ self |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1456 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1457 |
"Created: / 26.7.1998 / 12:17:03 / cg" |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1458 |
! |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1459 |
|
933
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1460 |
hasClassAndSelectorDefined |
1054 | 1461 |
^ [ |
1462 |
|clsName| |
|
1463 |
||
1464 |
(clsName := imageEditView resourceClass) size > 0 |
|
1465 |
and:[(Smalltalk at:clsName ifAbsent:nil) notNil |
|
1466 |
and:[imageEditView resourceSelector notNil]] |
|
1467 |
] |
|
933
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1468 |
|
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1469 |
"Created: / 31.7.1998 / 02:02:54 / cg" |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1470 |
! |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1471 |
|
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1472 |
hasClassDefined |
1054 | 1473 |
^ [ |
1474 |
|clsName| |
|
1475 |
||
1476 |
(clsName := imageEditView resourceClass) > 0 |
|
1477 |
and:[(Smalltalk at:clsName ifAbsent:nil) notNil] |
|
1478 |
] |
|
933
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1479 |
|
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1480 |
"Created: / 31.7.1998 / 02:02:22 / cg" |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1481 |
! |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1482 |
|
1008 | 1483 |
hasColormap |
1484 |
^ [self image notNil and:[self image colorMap notNil]] |
|
1485 |
||
1486 |
"Created: / 30.9.1998 / 23:53:55 / cg" |
|
1487 |
! |
|
1488 |
||
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1489 |
imageInfoHolder |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1490 |
|holder| |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1491 |
(holder := builder bindingAt:#imageInfoHolder) isNil ifTrue:[ |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1492 |
builder aspectAt:#imageInfoHolder put:(holder := '' asValue). |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1493 |
]. |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1494 |
^ holder |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1495 |
|
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1496 |
"Modified: / 29.7.1998 / 18:32:08 / cg" |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1497 |
! |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1498 |
|
400 | 1499 |
imageIsLoaded |
767 | 1500 |
"returns whether an image is loaded as value holder" |
400 | 1501 |
|
1502 |
|holder| |
|
1503 |
(holder := builder bindingAt:#imageIsLoaded) isNil ifTrue:[ |
|
1504 |
builder aspectAt:#imageIsLoaded put:(holder := false asValue). |
|
1505 |
]. |
|
1506 |
^ holder |
|
1507 |
! |
|
1508 |
||
933
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1509 |
imageIsLoadedAndClassDefined |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1510 |
"returns whether an image is loaded as value holder" |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1511 |
|
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1512 |
^ [self hasClassAndSelectorDefined value |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1513 |
and:[self imageIsLoaded value]] |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1514 |
|
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1515 |
"Created: / 31.7.1998 / 02:04:18 / cg" |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1516 |
! |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1517 |
|
400 | 1518 |
listOfColors |
767 | 1519 |
"returns the list of colors in a List" |
400 | 1520 |
|
1521 |
|holder| |
|
1522 |
(holder := builder bindingAt:#listOfColors) isNil ifTrue:[ |
|
1523 |
builder aspectAt:#listOfColors put:(holder := List new). |
|
942 | 1524 |
holder addDependent:self. |
400 | 1525 |
]. |
1526 |
^ holder |
|
1527 |
! |
|
1528 |
||
1529 |
selectionOfColor |
|
767 | 1530 |
"returns current selection of the edit color as an AspectAdaptor" |
400 | 1531 |
|
1532 |
|holder| |
|
1533 |
(holder := builder bindingAt:#selectionOfColor) isNil ifTrue:[ |
|
1534 |
builder aspectAt:#selectionOfColor put:( |
|
1535 |
holder := AspectAdaptor new subject:self; forAspect:#selectedColorIndex). |
|
1536 |
]. |
|
1537 |
^ holder |
|
1538 |
! |
|
1539 |
||
1540 |
valueOfMagnification |
|
767 | 1541 |
"returns current magnification of the image as an AspectAdaptor" |
400 | 1542 |
|
1543 |
|holder| |
|
1544 |
(holder := builder bindingAt:#valueOfMagnification) isNil ifTrue:[ |
|
1545 |
builder aspectAt:#valueOfMagnification put:( |
|
1546 |
holder := AspectAdaptor new subject:self; forAspect:#magnification) |
|
1547 |
]. |
|
1548 |
^ holder |
|
1549 |
! ! |
|
1550 |
||
767 | 1551 |
!ImageEditor methodsFor:'change & update'! |
1552 |
||
1553 |
findColorMapMode |
|
899 | 1554 |
"finds the colorMapMode for a new image" |
767 | 1555 |
|
1054 | 1556 |
|image listOfColors| |
1557 |
||
1558 |
image := self image. |
|
1559 |
image depth > 8 ifTrue: [ |
|
1560 |
colorMapMode value: ''. |
|
1561 |
self listOfColors removeAll. |
|
1562 |
^ nil |
|
1563 |
]. |
|
1564 |
||
1565 |
colorMapMode value:(image depth printString, '-plane'). |
|
1566 |
||
1567 |
(listOfColors := self listOfColors) isEmpty ifTrue:[ |
|
1568 |
self colorMapMode: colorMapMode value. |
|
1569 |
listOfColors := self listOfColors. |
|
1570 |
image := self image. |
|
767 | 1571 |
]. |
1054 | 1572 |
imageEditView selectColors: (Array |
1573 |
with: (listOfColors at:1) |
|
1574 |
with: (listOfColors at:2 ifAbsent:[listOfColors at:1])). |
|
1575 |
||
1576 |
image mask notNil ifTrue: [ |
|
1577 |
colorMapMode value:(colorMapMode value, ' + mask'). |
|
1578 |
||
1579 |
(listOfColors detect: [:clr| clr = (Color basicNew setColorId:0)] ifNone: nil) isNil |
|
1580 |
ifTrue:[ |
|
1581 |
listOfColors addFirst: (Color basicNew setColorId:0). |
|
1582 |
imageEditView selectColors: (Array |
|
1583 |
with:(listOfColors at:2 ifAbsent:[listOfColors at: 1]) |
|
1584 |
with: (listOfColors at: 1)). |
|
898 | 1585 |
] |
767 | 1586 |
]. |
1054 | 1587 |
self selectionOfColor |
1588 |
value: 0; |
|
1589 |
value: (self listOfColors indexOf: imageEditView selectedColor). |
|
767 | 1590 |
! |
1591 |
||
942 | 1592 |
update:something with:aParameter from:changedObject |
960 | 1593 |
|clrIndex| |
1594 |
||
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1595 |
changedObject == self listOfColors ifTrue:[ |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1596 |
something == #at: ifTrue:[ |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1597 |
"/ colormap entry changed at aParameter |
960 | 1598 |
|
1599 |
clrIndex := aParameter. |
|
1600 |
(self hasMask) ifTrue:[ |
|
1601 |
clrIndex := clrIndex - 1. |
|
1602 |
]. |
|
1603 |
||
1604 |
self image colorMap at:clrIndex put:(changedObject at:aParameter). |
|
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1605 |
self colorMapChanged. |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1606 |
^ self |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1607 |
]. |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1608 |
]. |
1124 | 1609 |
|
1610 |
changedObject == imageEditView undoImages ifTrue:[ |
|
1611 |
self valueOfCanUndo value:(changedObject notEmpty). |
|
1612 |
^ self. |
|
1613 |
]. |
|
1614 |
||
1345 | 1615 |
changedObject == imageEditView ifTrue:[ |
1616 |
something == #imageColors ifTrue:[ |
|
1617 |
self listOfColors contents:self image colorMap. |
|
1618 |
self findColorMapMode. |
|
1619 |
^ self. |
|
1620 |
]. |
|
1621 |
something == #image ifTrue:[ |
|
1622 |
self imagePreView image:self image. |
|
1623 |
^ self. |
|
1624 |
]. |
|
1625 |
something == #subImageIn ifTrue:[ |
|
1626 |
self imagePreView redraw:aParameter. |
|
1627 |
^ self. |
|
1628 |
]. |
|
1629 |
||
1630 |
^ self. |
|
1631 |
]. |
|
1632 |
||
1633 |
changedObject == imageEditView image ifTrue:[ |
|
1634 |
self halt. |
|
1635 |
^ self. |
|
1636 |
]. |
|
1637 |
||
942 | 1638 |
super update:something with:aParameter from:changedObject |
1639 |
||
1345 | 1640 |
"Modified: / 10.2.2000 / 23:36:49 / cg" |
942 | 1641 |
! |
1642 |
||
1054 | 1643 |
updateForNoImage |
767 | 1644 |
"updates channels and view, if image is loaded" |
1645 |
||
1646 |
self imageIsLoaded value: false. |
|
1647 |
self listOfColors removeAll. |
|
1648 |
self imagePreView image: nil |
|
1649 |
||
1650 |
||
1651 |
||
1652 |
||
1653 |
! |
|
1654 |
||
1655 |
updateLabelsAndHistory |
|
1656 |
"updates labels and history, if something has changed" |
|
1657 |
||
1658 |
self imageIsLoaded value: self image notNil. |
|
1659 |
||
1660 |
self image isNil ifTrue: [^nil]. |
|
1661 |
||
1662 |
self updateInfoLabel. |
|
1663 |
||
911 | 1664 |
imageEditView resourceMessage asCollectionOfWords size = 2 |
1665 |
ifTrue: [self addToHistory: imageEditView resourceMessage -> #loadFromMessage:]. |
|
767 | 1666 |
|
1667 |
self image fileName notNil |
|
1668 |
ifTrue: [self addToHistory: self image fileName -> #loadFromFile:]. |
|
1669 |
||
1670 |
||
1671 |
||
1672 |
! ! |
|
1673 |
||
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1674 |
!ImageEditor methodsFor:'data access'! |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1675 |
|
942 | 1676 |
blueAtColor:aColor put:newBlue |
1677 |
"helper used to return a new row element, when blue is changed" |
|
1678 |
||
1679 |
|byte| |
|
1680 |
||
1681 |
aColor isNil ifTrue:[^ aColor]. "/ mask cannot be changed |
|
1682 |
byte := newBlue clampBetween:0 and:255. |
|
960 | 1683 |
byte = aColor blueByte ifTrue:[^ aColor]. |
942 | 1684 |
^ Color redByte:(aColor redByte) greenByte:(aColor greenByte) blueByte:byte |
960 | 1685 |
|
1686 |
"Modified: / 18.8.1998 / 17:00:12 / cg" |
|
942 | 1687 |
! |
1688 |
||
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1689 |
blueFromColor:aColor |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1690 |
"helper used to access a color as a row in the dataSet view" |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1691 |
|
930 | 1692 |
aColor isNil ifTrue:[^ 'none']. |
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1693 |
^ aColor blueByte ? 'mask' |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1694 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1695 |
"Created: / 26.7.1998 / 12:30:35 / cg" |
930 | 1696 |
"Modified: / 31.7.1998 / 01:11:18 / cg" |
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1697 |
! |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1698 |
|
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1699 |
canSelectBlueInColor:aColor |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1700 |
^ aColor blueByte notNil |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1701 |
|
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1702 |
"Created: / 7.8.1998 / 22:50:34 / cg" |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1703 |
"Modified: / 7.8.1998 / 22:52:57 / cg" |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1704 |
! |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1705 |
|
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1706 |
canSelectGreenInColor:aColor |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1707 |
^ aColor greenByte notNil |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1708 |
|
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1709 |
"Created: / 7.8.1998 / 22:50:22 / cg" |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1710 |
"Modified: / 7.8.1998 / 22:52:46 / cg" |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1711 |
! |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1712 |
|
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1713 |
canSelectRedInColor:aColor |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1714 |
^ aColor redByte notNil |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1715 |
|
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1716 |
"Created: / 7.8.1998 / 22:50:00 / cg" |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1717 |
"Modified: / 7.8.1998 / 22:51:03 / cg" |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1718 |
! |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1719 |
|
942 | 1720 |
greenAtColor:aColor put:newGreen |
1721 |
"helper used to return a new row element, when green is changed" |
|
1722 |
||
1723 |
|byte| |
|
1724 |
||
1725 |
aColor isNil ifTrue:[^ aColor]. "/ mask cannot be changed |
|
1726 |
byte := newGreen clampBetween:0 and:255. |
|
960 | 1727 |
byte = aColor greenByte ifTrue:[^ aColor]. |
942 | 1728 |
^ Color redByte:(aColor redByte) greenByte:byte blueByte:(aColor blueByte) |
960 | 1729 |
|
1730 |
"Modified: / 18.8.1998 / 17:00:38 / cg" |
|
942 | 1731 |
! |
1732 |
||
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1733 |
greenFromColor:aColor |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1734 |
"helper used to access a color as a row in the dataSet view" |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1735 |
|
930 | 1736 |
aColor isNil ifTrue:[^ 'none']. |
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1737 |
^ aColor greenByte ? 'mask' |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1738 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1739 |
"Created: / 26.7.1998 / 12:30:29 / cg" |
930 | 1740 |
"Modified: / 31.7.1998 / 01:11:31 / cg" |
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1741 |
! |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1742 |
|
942 | 1743 |
redAtColor:aColor put:newRed |
1744 |
"helper used to return a new row element, when red is changed" |
|
1745 |
||
1746 |
|byte| |
|
1747 |
||
1748 |
aColor isNil ifTrue:[^ aColor]. "/ mask cannot be changed |
|
1749 |
byte := newRed clampBetween:0 and:255. |
|
960 | 1750 |
byte = aColor redByte ifTrue:[^ aColor]. |
942 | 1751 |
^ Color redByte:byte greenByte:(aColor greenByte) blueByte:(aColor blueByte) |
960 | 1752 |
|
1753 |
"Modified: / 18.8.1998 / 17:00:49 / cg" |
|
942 | 1754 |
! |
1755 |
||
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1756 |
redFromColor:aColor |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1757 |
"helper used to access a color as a row in the dataSet view" |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1758 |
|
930 | 1759 |
aColor isNil ifTrue:[^ 'none']. |
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1760 |
^ aColor redByte ? 'mask' |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1761 |
|
930 | 1762 |
"Modified: / 31.7.1998 / 01:11:35 / cg" |
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1763 |
! ! |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1764 |
|
672 | 1765 |
!ImageEditor methodsFor:'help'! |
1766 |
||
1767 |
defaultInfoLabel |
|
767 | 1768 |
"returns the default info label" |
672 | 1769 |
|
911 | 1770 |
(imageEditView resourceClass isSymbol and: [(Smalltalk at: imageEditView resourceClass) isClass]) |
672 | 1771 |
ifTrue: |
1772 |
[ |
|
911 | 1773 |
^imageEditView resourceClass, ' >> ', imageEditView resourceSelector |
672 | 1774 |
]. |
767 | 1775 |
^'No class and selector defined.' |
674 | 1776 |
! |
1777 |
||
702 | 1778 |
openDocumentation |
767 | 1779 |
"opens the documentation file of the Image Editor" |
674 | 1780 |
|
763 | 1781 |
self openHTMLDocument: 'tools/uipainter/ImageEditor.html' |
1782 |
||
672 | 1783 |
! ! |
1784 |
||
767 | 1785 |
!ImageEditor methodsFor:'loading'! |
1786 |
||
1787 |
loadFromFile: aFileName |
|
1788 |
"loads an image from aFileName and sets up color map list and other info labels" |
|
1789 |
||
960 | 1790 |
|img| |
1791 |
||
980
bd21079f40e1
show waitCursor while loading from file.
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1792 |
self withCursor:Cursor wait do:[ |
bd21079f40e1
show waitCursor while loading from file.
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1793 |
(imageEditView loadFromFile: aFileName) notNil ifTrue:[ |
bd21079f40e1
show waitCursor while loading from file.
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1794 |
(img := self image) notNil ifTrue:[ |
bd21079f40e1
show waitCursor while loading from file.
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1795 |
img colorMap notNil ifTrue:[ |
bd21079f40e1
show waitCursor while loading from file.
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1796 |
self listOfColors contents:(img usedColors asSet asOrderedCollection). |
bd21079f40e1
show waitCursor while loading from file.
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1797 |
] ifFalse:[ |
bd21079f40e1
show waitCursor while loading from file.
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1798 |
self listOfColors removeAll. |
bd21079f40e1
show waitCursor while loading from file.
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1799 |
]. |
bd21079f40e1
show waitCursor while loading from file.
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1800 |
self findColorMapMode. |
bd21079f40e1
show waitCursor while loading from file.
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1801 |
self updateLabelsAndHistory. |
1057 | 1802 |
imageEditView image:img. |
960 | 1803 |
] ifFalse:[ |
1054 | 1804 |
self updateForNoImage |
1057 | 1805 |
]. |
1806 |
self imagePreView image:img. |
|
767 | 1807 |
] |
1808 |
] |
|
960 | 1809 |
|
1057 | 1810 |
"Modified: / 16.3.1999 / 21:44:26 / cg" |
767 | 1811 |
! |
1812 |
||
960 | 1813 |
loadFromImage:anImage |
767 | 1814 |
"loads an image from anImage and sets up color map list and other info labels" |
1815 |
||
960 | 1816 |
imageEditView image:anImage. |
1057 | 1817 |
self imagePreView image: anImage. |
1818 |
anImage notNil ifTrue:[ |
|
1819 |
anImage colorMap notNil ifTrue:[ |
|
1820 |
self listOfColors contents:(anImage usedColors asSet asOrderedCollection). |
|
960 | 1821 |
] ifFalse:[ |
767 | 1822 |
self listOfColors removeAll. |
1823 |
]. |
|
1824 |
self findColorMapMode. |
|
1825 |
self updateLabelsAndHistory. |
|
960 | 1826 |
] ifFalse:[ |
1054 | 1827 |
self updateForNoImage |
767 | 1828 |
] |
960 | 1829 |
|
1057 | 1830 |
"Modified: / 16.3.1999 / 21:43:56 / cg" |
767 | 1831 |
! |
1832 |
||
1833 |
loadFromMessage: aMessage |
|
1834 |
"loads an image by evaluating aMessage and sets up color map list and other info labels" |
|
1835 |
||
960 | 1836 |
|img| |
1837 |
||
1838 |
(imageEditView loadFromMessage: aMessage) notNil ifTrue:[ |
|
1839 |
(img := self image) notNil ifTrue:[ |
|
1840 |
self listOfColors contents:(img usedColors asSet asOrderedCollection). |
|
767 | 1841 |
self findColorMapMode. |
1842 |
self updateLabelsAndHistory. |
|
1057 | 1843 |
imageEditView image:img. |
1844 |
self imagePreView image:img. |
|
960 | 1845 |
] ifFalse:[ |
1054 | 1846 |
self updateForNoImage |
767 | 1847 |
] |
1848 |
] |
|
960 | 1849 |
|
1057 | 1850 |
"Modified: / 16.3.1999 / 21:44:41 / cg" |
767 | 1851 |
! |
1852 |
||
1853 |
loadFromOrPrepareForMessage: aMessage |
|
1854 |
"loads an image by evaluating aMessage; |
|
1855 |
if no image could extract from aMessage; do set the class and the selector from |
|
1856 |
the aMessage for a saving at the end of editing" |
|
1857 |
||
911 | 1858 |
(imageEditView loadFromMessage: aMessage) notNil |
767 | 1859 |
ifTrue: |
1860 |
[ |
|
1861 |
self listOfColors contents: self image usedColors asSet asOrderedCollection. |
|
1862 |
self findColorMapMode. |
|
1863 |
] |
|
1864 |
ifFalse: |
|
1865 |
[ |
|
911 | 1866 |
imageEditView resourceMessage: aMessage. |
767 | 1867 |
]. |
1868 |
self updateLabelsAndHistory. |
|
1057 | 1869 |
self imagePreView image:(self image). |
1870 |
||
1871 |
"Modified: / 16.3.1999 / 21:45:07 / cg" |
|
767 | 1872 |
! ! |
1873 |
||
400 | 1874 |
!ImageEditor methodsFor:'menu modes'! |
1875 |
||
975 | 1876 |
colorMapMode |
1877 |
"returns colorMapMode" |
|
400 | 1878 |
|
975 | 1879 |
colorMapMode isNil ifTrue: [colorMapMode := '' asValue]. |
400 | 1880 |
|
975 | 1881 |
^colorMapMode |
400 | 1882 |
! |
1883 |
||
975 | 1884 |
editMode |
1885 |
"returns editMode" |
|
400 | 1886 |
|
1054 | 1887 |
editMode isNil ifTrue: [ |
975 | 1888 |
editMode := #point asValue. |
1329 | 1889 |
editMode onChangeEvaluate:[imageEditView editMode:(editMode value)] |
975 | 1890 |
]. |
1891 |
||
1892 |
^editMode |
|
400 | 1893 |
! |
1894 |
||
975 | 1895 |
mouseKeyColorMode |
1896 |
"returns mouseKeyColorMode" |
|
400 | 1897 |
|
1345 | 1898 |
mouseKeyColorMode isNil ifTrue:[ |
975 | 1899 |
mouseKeyColorMode := 1 asValue. |
1345 | 1900 |
mouseKeyColorMode onChangeEvaluate: [ |
1901 |
imageEditView mouseKeyColorMode:mouseKeyColorMode value. |
|
1902 |
self selectionOfColor value: (self listOfColors indexOf:imageEditView selectedColor). |
|
1903 |
] |
|
956 | 1904 |
]. |
400 | 1905 |
|
975 | 1906 |
^mouseKeyColorMode |
1345 | 1907 |
|
1908 |
"Modified: / 10.2.2000 / 23:16:42 / cg" |
|
400 | 1909 |
! ! |
1910 |
||
535 | 1911 |
!ImageEditor methodsFor:'queries'! |
1912 |
||
960 | 1913 |
hasMask |
975 | 1914 |
^ colorMapMode notNil and:[colorMapMode value endsWith:'mask'] |
960 | 1915 |
|
1916 |
"Created: / 18.8.1998 / 17:17:38 / cg" |
|
1917 |
! |
|
1918 |
||
535 | 1919 |
preferredExtent |
767 | 1920 |
"returns the preferred extent" |
535 | 1921 |
|
1922 |
^super preferredExtent max: (Screen current width//3)@(Screen current height//3.5) |
|
1923 |
||
1924 |
||
1925 |
! ! |
|
1926 |
||
400 | 1927 |
!ImageEditor methodsFor:'selection'! |
1928 |
||
1929 |
magnification |
|
767 | 1930 |
"returns the magnification of the image" |
400 | 1931 |
|
911 | 1932 |
self imageEditView isNil ifTrue: [^1]. |
1933 |
^imageEditView magnification x |
|
400 | 1934 |
! |
1935 |
||
1936 |
magnification: aValue |
|
767 | 1937 |
"sets the magnification of the image" |
400 | 1938 |
|
905 | 1939 |
|magnification| |
1940 |
magnification := (aValue ? 1) asPoint. |
|
911 | 1941 |
(magnification = imageEditView magnification or: [magnification = (0@0)]) ifTrue: [^nil]. |
1942 |
imageEditView magnification: magnification |
|
400 | 1943 |
! |
1944 |
||
1945 |
selectedColorIndex |
|
767 | 1946 |
"returns the index of the selected color" |
400 | 1947 |
|
1948 |
^selectedColorIndex |
|
1949 |
! |
|
1950 |
||
1951 |
selectedColorIndex: anIndex |
|
767 | 1952 |
"sets the index of the selected color" |
400 | 1953 |
|
1054 | 1954 |
|clr pixel| |
1955 |
||
1956 |
selectedColorIndex := anIndex. |
|
1957 |
clr := self listOfColors at:anIndex ifAbsent:nil. |
|
1958 |
clr isNil ifTrue:[^ self]. |
|
1959 |
||
1075 | 1960 |
pixel := anIndex - 1. |
1054 | 1961 |
(self listOfColors at:1) = Color noColor ifTrue:[ |
1962 |
anIndex == 1 ifTrue:[ |
|
1963 |
pixel := nil. "/ mask |
|
1964 |
] ifFalse:[ |
|
1075 | 1965 |
pixel := pixel - 1 |
1054 | 1966 |
] |
1967 |
]. |
|
1968 |
imageEditView selectedColorIndex:pixel. |
|
1969 |
imageEditView selectedColor:clr. |
|
400 | 1970 |
|
1971 |
! ! |
|
1972 |
||
1973 |
!ImageEditor methodsFor:'startup / release'! |
|
1974 |
||
1975 |
closeRequest |
|
767 | 1976 |
"close request" |
400 | 1977 |
|
911 | 1978 |
imageEditView checkModified ifTrue:[super closeRequest] |
400 | 1979 |
|
1980 |
! |
|
1981 |
||
1982 |
open |
|
767 | 1983 |
"after opening, sets the masterApplication of the imageEditView to self" |
400 | 1984 |
|
1985 |
super open. |
|
444 | 1986 |
|
911 | 1987 |
imageEditView := (builder componentAt: #imageEditView) subViews first. |
975 | 1988 |
imageEditView masterApplication: self. |
1989 |
||
400 | 1990 |
! |
1991 |
||
1992 |
postOpenWith:aBuilder |
|
767 | 1993 |
"after opening, sets the masterApplication of the imageEditView to self; |
1994 |
evaluate the postOpenAction" |
|
400 | 1995 |
|
911 | 1996 |
imageEditView masterApplication: self. |
1124 | 1997 |
imageEditView undoImages addDependent:self. |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1998 |
imageEditView imageInfoHolder:(self imageInfoHolder). |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1999 |
imageEditView activityInfoHolder:(self activityInfoHolder). |
1345 | 2000 |
imageEditView clickInfoCallBack:[:button :point | |
2001 |
|mouseButtonColorToolBar| |
|
2002 |
||
2003 |
mouseButtonColorToolBar := builder componentAt:#MouseButtonColorToolBar. |
|
2004 |
(mouseButtonColorToolBar itemAt:button) toggleIndication. |
|
2005 |
mouseButtonColorToolBar do: [:i| i updateIndicators]. |
|
2006 |
]. |
|
2007 |
imageEditView addDependent:self. |
|
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
2008 |
|
400 | 2009 |
postOpenAction notNil ifTrue: [postOpenAction value]. |
2010 |
||
1250 | 2011 |
super postOpenWith:aBuilder. |
2012 |
||
2013 |
aBuilder keyboardProcessor menuBar:nil. |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
2014 |
|
1345 | 2015 |
"Modified: / 10.2.2000 / 23:17:43 / cg" |
400 | 2016 |
! ! |
2017 |
||
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2018 |
!ImageEditor methodsFor:'user actions - colormap'! |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2019 |
|
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
2020 |
addColorToColormap |
1057 | 2021 |
|depth img cMap newColorMap newImage oldCListSize newMode| |
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
2022 |
|
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
2023 |
img := self image. |
1054 | 2024 |
depth := img depth. |
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
2025 |
cMap := img colorMap. |
1054 | 2026 |
cMap isNil ifTrue:[ |
2027 |
self warn:'Image has no colormap\change colorMap mode first.' withCRs. |
|
2028 |
^ self |
|
2029 |
]. |
|
2030 |
||
2031 |
((depth == 1) |
|
2032 |
or:[cMap size == (1 bitShift:depth)]) ifTrue:[ |
|
2033 |
depth >= 8 ifTrue:[ |
|
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
2034 |
self warn:'No space for more colors in colormap.'. |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
2035 |
^ self |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
2036 |
]. |
1054 | 2037 |
(self confirm:'No space for more colors in colormap.\Change depth first.' withCRs) |
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
2038 |
ifFalse:[ |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
2039 |
^ self |
1057 | 2040 |
]. |
2041 |
||
2042 |
imageEditView makeUndo. |
|
2043 |
newMode := (depth*2) printString , (colorMapMode value copyFrom:2). |
|
2044 |
self colorMapMode:newMode. |
|
2045 |
] ifFalse:[ |
|
2046 |
imageEditView makeUndo. |
|
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
2047 |
]. |
1054 | 2048 |
|
2049 |
cMap := cMap asArray. |
|
2050 |
oldCListSize := self listOfColors size. |
|
2051 |
||
2052 |
"/ (colorMapMode value asString endsWith:'mask') ifTrue:[ |
|
2053 |
"/ cMap last = Color noColor ifTrue:[ |
|
2054 |
"/ cMap := cMap copyWithoutLast:1 |
|
2055 |
"/ ] ifFalse:[ |
|
2056 |
"/ cMap first = Color noColor ifTrue:[ |
|
2057 |
"/ cMap := cMap copyFrom:2 |
|
2058 |
"/ ] |
|
2059 |
"/ ]. |
|
2060 |
"/ ]. |
|
2061 |
"/ |
|
2062 |
||
2063 |
newColorMap := cMap copyWith:(Color black). |
|
2064 |
||
2065 |
newImage := img species new |
|
2066 |
width:img width |
|
2067 |
height:img height |
|
2068 |
depth:depth |
|
2069 |
fromArray:img bits. |
|
2070 |
||
2071 |
newImage colorMap:newColorMap. |
|
2072 |
newImage fileName:img fileName. |
|
2073 |
newImage mask:(img mask copy). |
|
2074 |
||
2075 |
(imageEditView image:newImage) notNil ifTrue:[ |
|
2076 |
self listOfColors contents: newImage colorMap. |
|
2077 |
self findColorMapMode. |
|
2078 |
"/ mhmh - somehow, we get two colors added ... (sigh findColorMapMode adds another one ...) |
|
2079 |
self listOfColors size > (oldCListSize + 1) ifTrue:[ |
|
2080 |
self listOfColors removeLast |
|
2081 |
]. |
|
2082 |
self selectionOfColor value:(self listOfColors size). |
|
2083 |
self updateLabelsAndHistory. |
|
2084 |
] |
|
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
2085 |
|
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
2086 |
"Created: / 12.3.1999 / 00:20:28 / cg" |
1057 | 2087 |
"Modified: / 16.3.1999 / 21:57:26 / cg" |
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
2088 |
! |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
2089 |
|
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2090 |
colorMapChanged |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2091 |
|img| |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2092 |
|
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2093 |
img := self image. |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2094 |
img release. |
960 | 2095 |
imageEditView invalidate. |
2096 |
self imagePreView invalidate. |
|
2097 |
||
2098 |
"/ (imageEditView image:img) notNil ifTrue:[ |
|
2099 |
"/ self updateLabelsAndHistory. |
|
2100 |
"/ self imagePreView image:img |
|
2101 |
"/ ] |
|
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2102 |
|
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2103 |
"Created: / 7.8.1998 / 22:26:10 / cg" |
960 | 2104 |
"Modified: / 18.8.1998 / 17:08:55 / cg" |
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2105 |
! |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2106 |
|
975 | 2107 |
colorMapMode:aMode |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2108 |
"calculates a new color map for the image from aMode" |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2109 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2110 |
|depth numColors newColorMap newImage |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2111 |
oldImage image newColors realColorMap oldFileName |
1008 | 2112 |
usedColors useNearest usageCounts tmpBits tmpMap quest |
2113 |
prevMode maskThreshold maskImage| |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2114 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2115 |
self withExecuteCursorDo:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2116 |
oldImage := self image. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2117 |
|
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
2118 |
prevMode := colorMapMode value. |
1008 | 2119 |
oldImage depth > 8 ifTrue:[ |
2120 |
prevMode := nil |
|
2121 |
]. |
|
2122 |
||
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2123 |
newColorMap := self class listOfColorMaps at:aMode. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2124 |
depth := (newColorMap size log: 2) asInteger. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2125 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2126 |
useNearest := false. |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
2127 |
depth == 1 ifTrue:[ |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
2128 |
quest := 'Keep colormap (or use standard B&W)' |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
2129 |
] ifFalse:[ |
1008 | 2130 |
prevMode isNil ifTrue:[ |
2131 |
quest := 'Compute colormap (or use standard)' |
|
2132 |
] ifFalse:[ |
|
2133 |
quest := 'Keep colormap (or use standard)' |
|
2134 |
] |
|
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
2135 |
]. |
1008 | 2136 |
((prevMode = aMode) |
1057 | 2137 |
or:[depth > oldImage depth |
2138 |
or:[self confirm:(resources string:quest)]]) ifTrue:[ |
|
1008 | 2139 |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2140 |
"/ keep the colormap |
1008 | 2141 |
newColorMap atAllPut:Color black. |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2142 |
depth > oldImage depth ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2143 |
"/ easy - simply copy the part |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2144 |
numColors := 1 bitShift:oldImage depth. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2145 |
0 to:numColors-1 do:[:pixel | |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2146 |
newColorMap at:(pixel+1) put:(oldImage colorFromValue:pixel) |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2147 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2148 |
] ifFalse:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2149 |
"/ see if all used color fit the new colormap |
986 | 2150 |
usedColors := oldImage usedColorsMax:(1 bitShift:depth). |
2151 |
(usedColors notNil and:[usedColors size <= (1 bitShift:depth)]) ifTrue:[ |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2152 |
"/ yea - just install them |
986 | 2153 |
usedColors asArray keysAndValuesDo:[:idx :clr | |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2154 |
newColorMap at:idx put:clr |
1008 | 2155 |
]. |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2156 |
] ifFalse:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2157 |
"/ copy over those that are most often used. |
986 | 2158 |
oldImage depth < 8 ifTrue:[ |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2159 |
tmpBits := ByteArray uninitializedNew:(oldImage width*oldImage height). |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2160 |
oldImage bits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2161 |
expandPixels:(oldImage depth) |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2162 |
width:oldImage width |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2163 |
height:oldImage height |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2164 |
into:tmpBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2165 |
mapping:nil. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2166 |
] ifFalse:[ |
986 | 2167 |
oldImage depth == 8 ifTrue:[ |
2168 |
tmpBits := oldImage bits |
|
2169 |
] ifFalse:[ |
|
1124 | 2170 |
colorMapMode value:prevMode. |
1123 | 2171 |
self warn:('Too many colors in image ( ', oldImage usedColors size printString , ').'). |
986 | 2172 |
^ self |
2173 |
] |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2174 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2175 |
usageCounts := tmpBits usageCounts. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2176 |
tmpMap := Array new:usageCounts size. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2177 |
oldImage colorMap asArray keysAndValuesDo:[:i :clr | |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2178 |
tmpMap at:i put:clr |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2179 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2180 |
usageCounts sort:[:a :b | a > b] with:tmpMap. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2181 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2182 |
1 to:(1 bitShift:depth) do:[:idx | |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2183 |
newColorMap at:idx put:(tmpMap at:idx) |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2184 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2185 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2186 |
useNearest := Dialog |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
2187 |
confirmWithCancel:(resources |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
2188 |
string:'Image requires %1 colors.\ColorMap has only space for %2\\Use nearest (or map to first color) ?' |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
2189 |
with:usedColors size |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
2190 |
with:(1 bitShift:depth)) withCRs |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
2191 |
labels:(resources array:#('cancel' 'first' 'nearest')). |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2192 |
useNearest isNil ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2193 |
^ self "/ cancel |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2194 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2195 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2196 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2197 |
] ifFalse:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2198 |
"/ standard colormap |
921
a5aca21ea803
also allow nearest-color mode for standard colormap.
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
2199 |
usedColors := oldImage usedColors. |
a5aca21ea803
also allow nearest-color mode for standard colormap.
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
2200 |
(usedColors conform:[:clr | newColorMap includes:clr]) ifFalse:[ |
a5aca21ea803
also allow nearest-color mode for standard colormap.
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
2201 |
useNearest := Dialog |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
2202 |
confirmWithCancel:(resources |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
2203 |
string:'Not all colors are present in the new colormap.\\Map missing ones to nearest (or map to first color) ?' |
921
a5aca21ea803
also allow nearest-color mode for standard colormap.
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
2204 |
) withCRs |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
2205 |
labels:(resources string:#('cancel' 'first' 'nearest')). |
921
a5aca21ea803
also allow nearest-color mode for standard colormap.
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
2206 |
useNearest isNil ifTrue:[ |
a5aca21ea803
also allow nearest-color mode for standard colormap.
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
2207 |
^ self "/ cancel |
a5aca21ea803
also allow nearest-color mode for standard colormap.
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
2208 |
]. |
a5aca21ea803
also allow nearest-color mode for standard colormap.
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
2209 |
]. |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2210 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2211 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2212 |
imageEditView makeUndo. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2213 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2214 |
newImage := (Image implementorForDepth: depth) new. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2215 |
oldFileName := oldImage fileName. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2216 |
|
1008 | 2217 |
Image imageErrorSignal handle:[:ex| |
2218 |
Color colorErrorSignal handle:[:ex| |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2219 |
imageEditView undo. |
1008 | 2220 |
^ self warn:(resources string:'Conversion failed !!') |
2221 |
] do:[ |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2222 |
newImage := (Image implementorForDepth: depth) new. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2223 |
newImage width:oldImage width height:oldImage height depth:depth. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2224 |
newImage colorMap:newColorMap. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2225 |
newImage photometric:#palette. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2226 |
newImage bits:(ByteArray new:(newImage bytesPerRow * newImage height)). |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2227 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2228 |
oldImage colorsFromX:0 y:0 toX:(oldImage width-1) y:(oldImage height-1) do: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2229 |
[:x :y :clr | |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2230 |
|newColor| |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2231 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2232 |
(newColorMap includes:clr) |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2233 |
ifTrue: [newColor := clr] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2234 |
ifFalse: [ |
1008 | 2235 |
newColor := clr nearestIn:newColorMap. |
2236 |
useNearest ifFalse:[ |
|
2237 |
(newColor deltaFrom:clr) > 0.5 ifTrue:[ |
|
2238 |
newColor := oldImage colorFromValue:0 |
|
2239 |
] |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2240 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2241 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2242 |
newImage colorAtX:x y:y put:newColor. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2243 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2244 |
image := newImage |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2245 |
]. |
1008 | 2246 |
] do:[ |
2247 |
image := newImage fromImage:oldImage |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2248 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2249 |
|
1008 | 2250 |
(aMode asString endsWith:'mask') ifTrue:[ |
2251 |
image mask isNil ifTrue:[ |
|
2252 |
(self confirm:'Generate mask from black ?') ifTrue:[ |
|
2253 |
maskThreshold := 0.1. |
|
2254 |
maskImage := Depth1Image fromImage:(image asThresholdMonochromeImage:maskThreshold). |
|
2255 |
] ifFalse:[ |
|
2256 |
maskImage := Depth1Image extent:image extent. |
|
2257 |
maskImage data:(ByteArray |
|
2258 |
new:(maskImage bytesPerRow * maskImage height) |
|
2259 |
withAll:16rFF). |
|
2260 |
||
2261 |
"/ maskImage fillRectangle:(image bounds) withColor:(Color colorId:1). |
|
2262 |
]. |
|
2263 |
image mask:maskImage. |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2264 |
]. |
1008 | 2265 |
] ifFalse:[ |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2266 |
image mask: nil. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2267 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2268 |
realColorMap := OrderedCollection new. |
1054 | 2269 |
image realColorMap do:[:clr| |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2270 |
(realColorMap includes: clr) ifFalse: [realColorMap add: clr] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2271 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2272 |
newColors := realColorMap copyFrom: 1 to: (newColorMap size min: realColorMap size). |
1054 | 2273 |
newColorMap do:[:clr| |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2274 |
((newColors size < newColorMap size) and: [(newColors includes: clr) not]) |
1054 | 2275 |
ifTrue:[ |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2276 |
newColors add: clr |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2277 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2278 |
]. |
975 | 2279 |
image colorMap: newColors. |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2280 |
|
1054 | 2281 |
(imageEditView image: image) notNil ifTrue:[ |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2282 |
image fileName: oldFileName. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2283 |
self listOfColors contents: image colorMap. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2284 |
self findColorMapMode. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2285 |
self updateLabelsAndHistory. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2286 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2287 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2288 |
|
1057 | 2289 |
"Modified: / 16.3.1999 / 21:55:39 / cg" |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2290 |
! |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2291 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2292 |
compressColorMap |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2293 |
"calculates a new color map for the image, using only used colors" |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2294 |
|
927 | 2295 |
|depth newColorMap newImage oldImage usedColors oldToNew oldBits newBits tmpBits| |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2296 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2297 |
oldImage := self image. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2298 |
depth := oldImage depth. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2299 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2300 |
oldImage photometric ~~ #palette ifTrue:[ |
930 | 2301 |
self information:'Compress colorMap: Only palette images have colormaps.'. |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2302 |
^ self |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2303 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2304 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2305 |
usedColors := oldImage usedColors. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2306 |
usedColors size == (1 bitShift:depth) ifTrue:[ |
930 | 2307 |
self information:'Compress colorMap: All colors are used - no compression.'. |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2308 |
^ self |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2309 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2310 |
usedColors size == oldImage colorMap size ifTrue:[ |
930 | 2311 |
self information:'Compress colorMap: Colormap already compressed - no compression.'. |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2312 |
^ self |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2313 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2314 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2315 |
imageEditView makeUndo. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2316 |
|
930 | 2317 |
self information:('Compress colorMap: %1 colors used.' bindWith:usedColors size). |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2318 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2319 |
self withExecuteCursorDo:[ |
996
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2320 |
"/ newColorMap := Array new:usedColors size. |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2321 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2322 |
"/ translation table |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2323 |
oldToNew := ByteArray new:(1 bitShift:depth). |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2324 |
newColorMap := usedColors asArray. |
996
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2325 |
newColorMap sort:[:a :b | |
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2326 |
a redByte == b redByte ifTrue:[ |
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2327 |
a greenByte == b greenByte ifTrue:[ |
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2328 |
a blueByte < b blueByte |
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2329 |
] ifFalse:[ |
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2330 |
a greenByte < b greenByte |
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2331 |
] |
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2332 |
] ifFalse:[ |
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2333 |
a redByte < b redByte |
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2334 |
] |
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2335 |
]. |
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2336 |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2337 |
oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr | |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2338 |
|newPixel| |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2339 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2340 |
(usedColors includes:clr) ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2341 |
newPixel := newColorMap indexOf:clr. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2342 |
oldToNew at:oldIdx put:newPixel-1. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2343 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2344 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2345 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2346 |
oldBits := oldImage bits. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2347 |
newBits := ByteArray new:(oldBits size). |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2348 |
depth ~~ 8 ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2349 |
"/ expand/compress can only handle 8bits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2350 |
tmpBits := ByteArray uninitializedNew:(oldImage width*oldImage height). |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2351 |
oldBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2352 |
expandPixels:depth |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2353 |
width:oldImage width |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2354 |
height:oldImage height |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2355 |
into:tmpBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2356 |
mapping:oldToNew. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2357 |
tmpBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2358 |
compressPixels:depth |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2359 |
width:oldImage width |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2360 |
height:oldImage height |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2361 |
into:newBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2362 |
mapping:nil |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2363 |
] ifFalse:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2364 |
oldBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2365 |
expandPixels:depth |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2366 |
width:oldImage width |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2367 |
height:oldImage height |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2368 |
into:newBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2369 |
mapping:oldToNew. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2370 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2371 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2372 |
newImage := oldImage species new |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2373 |
width:oldImage width |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2374 |
height:oldImage height |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2375 |
depth:depth |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2376 |
fromArray:newBits. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2377 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2378 |
newImage colorMap:newColorMap. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2379 |
newImage fileName:oldImage fileName. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2380 |
newImage mask:(oldImage mask copy). |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2381 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2382 |
(imageEditView image:newImage) notNil ifTrue: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2383 |
[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2384 |
self listOfColors contents: newImage colorMap. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2385 |
self findColorMapMode. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2386 |
self updateLabelsAndHistory. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2387 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2388 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2389 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2390 |
"Created: / 28.7.1998 / 20:03:11 / cg" |
996
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2391 |
"Modified: / 15.9.1998 / 17:53:32 / cg" |
1008 | 2392 |
! |
2393 |
||
1124 | 2394 |
reduceNumberOfColors |
2395 |
|s n anyChange img| |
|
2396 |
||
2397 |
s := Dialog request:'Number of color bits to strip (1-7) ?'. |
|
2398 |
s isNil ifTrue:[^ self]. |
|
2399 |
n := Integer readFrom:s onError:0. |
|
2400 |
(n between:1 and:7) ifFalse:[ |
|
2401 |
Dialog warn:'Image unchanged'. |
|
2402 |
^ self |
|
2403 |
]. |
|
2404 |
||
2405 |
imageEditView makeUndo. |
|
2406 |
self withExecuteCursorDo:[ |
|
2407 |
anyChange := imageEditView reduceColorResolutionBy:n. |
|
2408 |
anyChange ifFalse:[ |
|
2409 |
Dialog warn:'Image unchanged'. |
|
2410 |
] ifTrue:[ |
|
2411 |
img := imageEditView image. |
|
2412 |
imageEditView image:img. |
|
2413 |
self listOfColors contents:(img colorMap). |
|
2414 |
self findColorMapMode. |
|
2415 |
self updateLabelsAndHistory. |
|
2416 |
Dialog information:(img usedColors size printString , ' colors used.') |
|
2417 |
] |
|
2418 |
]. |
|
2419 |
! |
|
2420 |
||
1008 | 2421 |
sortColorMap |
2422 |
"calculates a new color map for the image, sorting colors" |
|
2423 |
||
2424 |
|depth newColorMap newImage oldImage usedColors oldToNew oldBits newBits tmpBits| |
|
2425 |
||
2426 |
oldImage := self image. |
|
2427 |
depth := oldImage depth. |
|
2428 |
||
2429 |
oldImage photometric ~~ #palette ifTrue:[ |
|
2430 |
self information:'Compress colorMap: Only palette images have colormaps.'. |
|
2431 |
^ self |
|
2432 |
]. |
|
2433 |
||
2434 |
usedColors := oldImage realColorMap. |
|
2435 |
||
2436 |
imageEditView makeUndo. |
|
2437 |
||
2438 |
self withExecuteCursorDo:[ |
|
2439 |
"/ newColorMap := Array new:usedColors size. |
|
2440 |
||
2441 |
"/ translation table |
|
2442 |
oldToNew := ByteArray new:(1 bitShift:depth). |
|
2443 |
newColorMap := usedColors asArray. |
|
2444 |
newColorMap sort:[:a :b | |
|
2445 |
a redByte == b redByte ifTrue:[ |
|
2446 |
a greenByte == b greenByte ifTrue:[ |
|
2447 |
a blueByte < b blueByte |
|
2448 |
] ifFalse:[ |
|
2449 |
a greenByte < b greenByte |
|
2450 |
] |
|
2451 |
] ifFalse:[ |
|
2452 |
a redByte < b redByte |
|
2453 |
] |
|
2454 |
]. |
|
2455 |
||
2456 |
oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr | |
|
2457 |
|newPixel| |
|
2458 |
||
2459 |
(usedColors includes:clr) ifTrue:[ |
|
2460 |
newPixel := newColorMap indexOf:clr. |
|
2461 |
oldToNew at:oldIdx put:newPixel-1. |
|
2462 |
] |
|
2463 |
]. |
|
2464 |
||
2465 |
oldBits := oldImage bits. |
|
2466 |
newBits := ByteArray new:(oldBits size). |
|
2467 |
depth ~~ 8 ifTrue:[ |
|
2468 |
"/ expand/compress can only handle 8bits |
|
2469 |
tmpBits := ByteArray uninitializedNew:(oldImage width*oldImage height). |
|
2470 |
oldBits |
|
2471 |
expandPixels:depth |
|
2472 |
width:oldImage width |
|
2473 |
height:oldImage height |
|
2474 |
into:tmpBits |
|
2475 |
mapping:oldToNew. |
|
2476 |
tmpBits |
|
2477 |
compressPixels:depth |
|
2478 |
width:oldImage width |
|
2479 |
height:oldImage height |
|
2480 |
into:newBits |
|
2481 |
mapping:nil |
|
2482 |
] ifFalse:[ |
|
2483 |
oldBits |
|
2484 |
expandPixels:depth |
|
2485 |
width:oldImage width |
|
2486 |
height:oldImage height |
|
2487 |
into:newBits |
|
2488 |
mapping:oldToNew. |
|
2489 |
]. |
|
2490 |
||
2491 |
newImage := oldImage species new |
|
2492 |
width:oldImage width |
|
2493 |
height:oldImage height |
|
2494 |
depth:depth |
|
2495 |
fromArray:newBits. |
|
2496 |
||
2497 |
newImage colorMap:newColorMap. |
|
2498 |
newImage fileName:oldImage fileName. |
|
2499 |
newImage mask:(oldImage mask copy). |
|
2500 |
||
1054 | 2501 |
(imageEditView image:newImage) notNil ifTrue:[ |
1008 | 2502 |
self listOfColors contents: newImage colorMap. |
2503 |
self findColorMapMode. |
|
2504 |
self updateLabelsAndHistory. |
|
2505 |
] |
|
2506 |
] |
|
2507 |
||
2508 |
"Modified: / 15.9.1998 / 17:53:32 / cg" |
|
2509 |
"Created: / 30.9.1998 / 23:51:23 / cg" |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2510 |
! ! |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2511 |
|
400 | 2512 |
!ImageEditor methodsFor:'user actions - editing'! |
2513 |
||
767 | 2514 |
doBrowseClass |
2515 |
"opens a System Browser on the resourceClass and the resourceSelector" |
|
400 | 2516 |
|
933
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2517 |
|cls| |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2518 |
|
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2519 |
cls := Smalltalk at:(imageEditView resourceClass) ifAbsent:nil. |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2520 |
cls isNil ifTrue:[^ self warn:'No Class specified']. |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2521 |
SystemBrowser |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2522 |
openInClass:cls class |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2523 |
selector:(imageEditView resourceSelector) |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2524 |
|
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2525 |
"Modified: / 31.7.1998 / 02:01:15 / cg" |
400 | 2526 |
! |
2527 |
||
1045 | 2528 |
doCropAll |
986 | 2529 |
"find all borders and cut them off" |
2530 |
||
1045 | 2531 |
imageEditView cropLeft:true right:true top:true bottom:true. |
986 | 2532 |
self updateInfoLabel |
2533 |
||
2534 |
"Modified: / 7.9.1998 / 14:26:23 / cg" |
|
2535 |
"Created: / 7.9.1998 / 16:33:43 / cg" |
|
2536 |
! |
|
2537 |
||
1045 | 2538 |
doCropBottom |
986 | 2539 |
"find a bottom border and cut it off" |
2540 |
||
1045 | 2541 |
imageEditView cropLeft:false right:false top:false bottom:true. |
986 | 2542 |
self updateInfoLabel |
2543 |
||
2544 |
"Created: / 7.9.1998 / 13:00:20 / cg" |
|
2545 |
"Modified: / 7.9.1998 / 14:26:23 / cg" |
|
2546 |
! |
|
2547 |
||
1045 | 2548 |
doCropLeft |
986 | 2549 |
"find a left border and cut it off" |
2550 |
||
1045 | 2551 |
imageEditView cropLeft:true right:false top:false bottom:false. |
986 | 2552 |
self updateInfoLabel |
2553 |
||
2554 |
"Created: / 7.9.1998 / 13:00:14 / cg" |
|
2555 |
"Modified: / 7.9.1998 / 14:26:34 / cg" |
|
2556 |
! |
|
2557 |
||
1045 | 2558 |
doCropManual |
986 | 2559 |
"let user specify borders and cut them off" |
2560 |
||
2561 |
|bindings left top right bottom| |
|
2562 |
||
2563 |
bindings := IdentityDictionary new. |
|
2564 |
bindings at:#left put:(left := 0 asValue). |
|
2565 |
bindings at:#right put:(right := 0 asValue). |
|
2566 |
bindings at:#top put:(top := 0 asValue). |
|
2567 |
bindings at:#bottom put:(bottom := 0 asValue). |
|
1045 | 2568 |
(self openDialogInterface:#gropDialogSpec withBindings:bindings) |
986 | 2569 |
ifTrue:[ |
2570 |
left := left value. |
|
2571 |
right := right value. |
|
2572 |
top := top value. |
|
2573 |
bottom := bottom value. |
|
2574 |
imageEditView |
|
2575 |
makeSubImageX:left y:top |
|
2576 |
width:(imageEditView image width - left - right) |
|
2577 |
height:(imageEditView image height - top - bottom). |
|
2578 |
self updateInfoLabel |
|
2579 |
]. |
|
2580 |
||
2581 |
"Created: / 7.9.1998 / 18:16:07 / cg" |
|
2582 |
"Modified: / 7.9.1998 / 18:20:42 / cg" |
|
2583 |
! |
|
2584 |
||
1045 | 2585 |
doCropRight |
986 | 2586 |
"find a right border and cut it off" |
2587 |
||
1045 | 2588 |
imageEditView cropLeft:false right:true top:false bottom:false. |
986 | 2589 |
self updateInfoLabel |
2590 |
||
2591 |
"Created: / 7.9.1998 / 13:00:14 / cg" |
|
2592 |
"Modified: / 7.9.1998 / 14:26:44 / cg" |
|
2593 |
! |
|
2594 |
||
1045 | 2595 |
doCropTop |
986 | 2596 |
"find a top border and cut it off" |
2597 |
||
1045 | 2598 |
imageEditView cropLeft:false right:false top:true bottom:false. |
986 | 2599 |
self updateInfoLabel |
2600 |
||
2601 |
"Created: / 7.9.1998 / 13:00:19 / cg" |
|
2602 |
"Modified: / 7.9.1998 / 14:26:52 / cg" |
|
2603 |
! |
|
2604 |
||
767 | 2605 |
doFlipHorizontal |
2606 |
"flips horizontally current image" |
|
400 | 2607 |
|
911 | 2608 |
imageEditView flipHorizontal |
400 | 2609 |
! |
2610 |
||
767 | 2611 |
doFlipVertical |
2612 |
"flips vertically current image" |
|
400 | 2613 |
|
911 | 2614 |
imageEditView flipVertical |
400 | 2615 |
! |
2616 |
||
767 | 2617 |
doMagnifyDown |
2618 |
"magnifies current image one step down" |
|
400 | 2619 |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
2620 |
|magHolder mag| |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
2621 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
2622 |
magHolder := self valueOfMagnification. |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
2623 |
(mag := magHolder value) > 1 ifTrue: [ |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
2624 |
magHolder value: mag - 1 |
400 | 2625 |
] |
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
2626 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
2627 |
"Modified: / 26.7.1998 / 20:24:08 / cg" |
400 | 2628 |
! |
2629 |
||
767 | 2630 |
doMagnifyImage |
2631 |
"magnifies current image" |
|
400 | 2632 |
|
1353 | 2633 |
|box newSize image| |
2634 |
||
2635 |
image := imageEditView image. |
|
2636 |
||
2637 |
box := EnterBox new. |
|
2638 |
box title:(resources string:'Images new size:'). |
|
2639 |
box okText:(resources string:'OK'). |
|
2640 |
box abortText:(resources string:'Cancel'). |
|
2641 |
box initialText:image extent printString. |
|
2642 |
box showAtPointer. |
|
2643 |
(box accepted |
|
2644 |
and: [(newSize := Object readFromString:(box contents) onError:nil) notNil]) |
|
2645 |
ifTrue:[ |
|
2646 |
imageEditView magnifyImageTo:newSize. |
|
2647 |
]. |
|
2648 |
||
400 | 2649 |
self updateInfoLabel |
2650 |
! |
|
2651 |
||
767 | 2652 |
doMagnifyUp |
2653 |
"magnifies current image one step up" |
|
400 | 2654 |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
2655 |
|magHolder mag| |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
2656 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
2657 |
magHolder := self valueOfMagnification. |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
2658 |
(mag := magHolder value) < 99 ifTrue: [ |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
2659 |
magHolder value: mag + 1 |
400 | 2660 |
] |
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
2661 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
2662 |
"Modified: / 26.7.1998 / 20:23:52 / cg" |
400 | 2663 |
! |
2664 |
||
767 | 2665 |
doNegativeImage |
2666 |
"negates current image by negating the color map" |
|
400 | 2667 |
|
911 | 2668 |
imageEditView negativeImage. |
400 | 2669 |
self listOfColors removeAll. |
901 | 2670 |
self findColorMapMode. |
911 | 2671 |
imageEditView undoImages removeLast |
400 | 2672 |
! |
2673 |
||
767 | 2674 |
doResizeImage |
1353 | 2675 |
"resizes the current image" |
2676 |
||
2677 |
|box newSize image| |
|
2678 |
||
2679 |
image := imageEditView image. |
|
2680 |
||
2681 |
box := EnterBox new. |
|
2682 |
box title:(resources string:'Images new size:'). |
|
2683 |
box okText:(resources string:'OK'). |
|
2684 |
box abortText:(resources string:'Cancel'). |
|
2685 |
box initialText:image extent printString. |
|
2686 |
box showAtPointer. |
|
2687 |
(box accepted |
|
2688 |
and: [(newSize := Object readFromString:(box contents) onError:nil) notNil]) |
|
2689 |
ifTrue:[ |
|
2690 |
imageEditView resizeImageTo:newSize. |
|
2691 |
]. |
|
2692 |
||
400 | 2693 |
! |
2694 |
||
767 | 2695 |
doRotateImage |
2696 |
"rotates current image" |
|
400 | 2697 |
|
1353 | 2698 |
|box rotation| |
2699 |
||
2700 |
box := EnterBox new. |
|
2701 |
box title:(resources string:'Rotate by (degrees, clockwise):'). |
|
2702 |
box okText:(resources string:'OK'). |
|
2703 |
box abortText:(resources string:'Cancel'). |
|
2704 |
box initialText: '0'. |
|
2705 |
box showAtPointer. |
|
2706 |
(box accepted and: [(rotation := Object readFromString: box contents onError:nil) notNil]) |
|
2707 |
ifTrue:[ |
|
2708 |
imageEditView rotateImageBy:rotation. |
|
2709 |
self updateInfoLabel |
|
2710 |
]. |
|
400 | 2711 |
! |
2712 |
||
767 | 2713 |
doUndo |
2714 |
"reverses last edit action" |
|
400 | 2715 |
|
911 | 2716 |
imageEditView undo |
400 | 2717 |
! ! |
2718 |
||
2719 |
!ImageEditor methodsFor:'user actions - loading'! |
|
2720 |
||
767 | 2721 |
doLoadFromClass |
2722 |
"opens a dialog for loading an image from class and a (resource-) selector" |
|
400 | 2723 |
|
1122 | 2724 |
|img| |
2725 |
||
1054 | 2726 |
(imageEditView loadFromClass) notNil ifTrue:[ |
1122 | 2727 |
(img := self image) notNil ifTrue: [ |
2728 |
self listOfColors contents: img usedColors asSet asOrderedCollection. |
|
574 | 2729 |
self findColorMapMode. |
767 | 2730 |
self updateLabelsAndHistory |
1054 | 2731 |
] ifFalse: [ |
2732 |
self updateForNoImage |
|
461 | 2733 |
] |
449 | 2734 |
] |
400 | 2735 |
! |
2736 |
||
767 | 2737 |
doLoadFromFile |
2738 |
"opens a dialog for loading an image from a file" |
|
400 | 2739 |
|
1353 | 2740 |
|img file dir filters| |
2741 |
||
2742 |
img := self image. |
|
2743 |
img notNil ifTrue: [ |
|
2744 |
file := img fileName |
|
2745 |
] ifFalse:[ |
|
2746 |
dir := LastDirectory |
|
2747 |
]. |
|
2748 |
||
2749 |
filters := FileSelectionBrowser loadImageFileNameFilters. |
|
2750 |
||
2751 |
file notNil ifTrue:[ |
|
2752 |
file := FileSelectionBrowser |
|
2753 |
request:'Load Image From' |
|
2754 |
fileName:file |
|
2755 |
withFileFilters:filters. |
|
2756 |
] ifFalse:[ |
|
2757 |
file := FileSelectionBrowser |
|
2758 |
request:'Load Image From' |
|
2759 |
inDirectory:dir |
|
2760 |
withFileFilters:filters. |
|
2761 |
]. |
|
2762 |
file notNil ifTrue:[ |
|
2763 |
LastDirectory := file asFilename directoryName. |
|
2764 |
self loadFromFile:file |
|
2765 |
] |
|
400 | 2766 |
! |
2767 |
||
767 | 2768 |
doNewImage |
2769 |
"opens a dialog with choices of size and color map for creating a new image" |
|
400 | 2770 |
|
2771 |
|aspects| |
|
767 | 2772 |
|
400 | 2773 |
aspects := IdentityDictionary new |
767 | 2774 |
at:#listOfSizes put: self class listOfDefaultSizes asValue; |
2775 |
at:#listOfColorMaps put: self class listOfColorMaps keys asSortedCollection asValue; |
|
2776 |
at:#selectionOfSize put: self class listOfDefaultSizes first copy asValue; |
|
400 | 2777 |
at:#selectionOfColorMap put: self class listOfColorMaps keys asSortedCollection first asValue; |
2778 |
yourself. |
|
2779 |
||
767 | 2780 |
(self openDialogInterface:#dialogSpecForNewImage withBindings:aspects) |
400 | 2781 |
ifTrue: |
2782 |
[ |
|
2783 |
|width height cMap imageClass image| |
|
767 | 2784 |
|
2785 |
width := 128 min: (Integer readFromString: ((aspects at:#selectionOfSize) value upTo: $x) onError:[24]). |
|
400 | 2786 |
height := 128 min: (Integer readFromString: ((aspects at:#selectionOfSize) value copy reverse upTo: $x) reverse onError:[24]). |
2787 |
||
975 | 2788 |
cMap := (self class listOfColorMaps at: (colorMapMode value: (aspects at:#selectionOfColorMap) value) value). |
400 | 2789 |
imageClass := Image implementorForDepth: ((cMap size log: 2) asInteger). |
767 | 2790 |
image := imageClass width: width height: height fromArray: (ByteArray new: width*height). |
400 | 2791 |
|
975 | 2792 |
(colorMapMode value endsWith: 'mask') |
400 | 2793 |
ifTrue: |
2794 |
[ |
|
767 | 2795 |
image mask: (Depth1Image width: width height: height depth: 1 fromArray: (ByteArray new: width*height)) clearMaskedPixels |
400 | 2796 |
]. |
2797 |
image colorMap: cMap. |
|
2798 |
image fillRectangleX:0 y:0 width:width height:height with:Color white. |
|
911 | 2799 |
(imageEditView image: image) notNil |
400 | 2800 |
ifTrue: |
2801 |
[ |
|
2802 |
self listOfColors contents: cMap. |
|
2803 |
self findColorMapMode. |
|
694 | 2804 |
self updateLabelsAndHistory |
400 | 2805 |
] |
767 | 2806 |
] |
929 | 2807 |
! |
2808 |
||
2809 |
grabScreenImage |
|
2810 |
"let user choose an area and grab that are for editing" |
|
2811 |
||
990
4303f0064410
delay a second before grabbing screen image (to allow for redraws to happen)
Claus Gittinger <cg@exept.de>
parents:
986
diff
changeset
|
2812 |
Processor |
4303f0064410
delay a second before grabbing screen image (to allow for redraws to happen)
Claus Gittinger <cg@exept.de>
parents:
986
diff
changeset
|
2813 |
addTimedBlock:[ |
4303f0064410
delay a second before grabbing screen image (to allow for redraws to happen)
Claus Gittinger <cg@exept.de>
parents:
986
diff
changeset
|
2814 |
|image d8image img| |
929 | 2815 |
|
990
4303f0064410
delay a second before grabbing screen image (to allow for redraws to happen)
Claus Gittinger <cg@exept.de>
parents:
986
diff
changeset
|
2816 |
image := Image fromUser. |
1121 | 2817 |
image isNil ifFalse:[ |
2818 |
image depth > 8 ifTrue:[ |
|
1122 | 2819 |
Object errorSignal handle:[:ex | |sig| |
2820 |
(sig := ex signal) == Object haltSignal ifTrue:[ex reject]. |
|
2821 |
sig == Signal noHandlerSignal ifTrue:[ex reject]. |
|
1121 | 2822 |
|
2823 |
self warn:'Could not convert to depth8 image (too many colors)'. |
|
2824 |
d8image := nil. |
|
2825 |
] do:[ |
|
2826 |
d8image := Depth8Image new. |
|
2827 |
d8image fromImage:image. |
|
2828 |
]. |
|
2829 |
d8image notNil ifTrue:[ |
|
2830 |
image := d8image |
|
2831 |
] |
|
990
4303f0064410
delay a second before grabbing screen image (to allow for redraws to happen)
Claus Gittinger <cg@exept.de>
parents:
986
diff
changeset
|
2832 |
]. |
1121 | 2833 |
(imageEditView image:image) notNil ifTrue:[ |
2834 |
self listOfColors contents:(image colorMap). |
|
2835 |
self findColorMapMode. |
|
2836 |
self updateLabelsAndHistory. |
|
990
4303f0064410
delay a second before grabbing screen image (to allow for redraws to happen)
Claus Gittinger <cg@exept.de>
parents:
986
diff
changeset
|
2837 |
] |
1121 | 2838 |
] |
2839 |
] |
|
990
4303f0064410
delay a second before grabbing screen image (to allow for redraws to happen)
Claus Gittinger <cg@exept.de>
parents:
986
diff
changeset
|
2840 |
afterSeconds:1 |
929 | 2841 |
|
2842 |
"Created: / 29.7.1998 / 21:24:42 / cg" |
|
990
4303f0064410
delay a second before grabbing screen image (to allow for redraws to happen)
Claus Gittinger <cg@exept.de>
parents:
986
diff
changeset
|
2843 |
"Modified: / 10.9.1998 / 16:01:23 / cg" |
400 | 2844 |
! ! |
2845 |
||
2846 |
!ImageEditor methodsFor:'user actions - saving'! |
|
2847 |
||
767 | 2848 |
doPrint |
2849 |
"prints current image on the current printer" |
|
400 | 2850 |
|
911 | 2851 |
imageEditView print |
400 | 2852 |
! |
2853 |
||
767 | 2854 |
doSaveImageFile |
2855 |
"saves current image to current file" |
|
400 | 2856 |
|
911 | 2857 |
imageEditView save |
400 | 2858 |
! |
2859 |
||
767 | 2860 |
doSaveImageFileAs |
2861 |
"opens a dialog for saving current image to a file" |
|
400 | 2862 |
|
911 | 2863 |
imageEditView saveImageFileAs. |
694 | 2864 |
self updateLabelsAndHistory |
400 | 2865 |
! |
2866 |
||
767 | 2867 |
doSaveImageMaskFileAs |
2868 |
"opens a dialog for saving mask of current image to a file" |
|
400 | 2869 |
|
911 | 2870 |
imageEditView saveImageMaskFileAs |
400 | 2871 |
! |
2872 |
||
767 | 2873 |
doSaveMethod |
2874 |
"saves current image on current class and selector" |
|
400 | 2875 |
|
911 | 2876 |
imageEditView saveMethod notNil |
400 | 2877 |
ifTrue: |
2878 |
[ |
|
694 | 2879 |
self updateLabelsAndHistory |
400 | 2880 |
] |
2881 |
! |
|
2882 |
||
767 | 2883 |
doSaveMethodAs |
2884 |
"opens a dialog for saving current image on a class and a selector" |
|
400 | 2885 |
|
911 | 2886 |
imageEditView saveMethodAs notNil |
400 | 2887 |
ifTrue: |
2888 |
[ |
|
694 | 2889 |
self updateLabelsAndHistory |
400 | 2890 |
] |
1309
0a45ef81b47e
added showStoreString menu function
Claus Gittinger <cg@exept.de>
parents:
1250
diff
changeset
|
2891 |
! |
0a45ef81b47e
added showStoreString menu function
Claus Gittinger <cg@exept.de>
parents:
1250
diff
changeset
|
2892 |
|
0a45ef81b47e
added showStoreString menu function
Claus Gittinger <cg@exept.de>
parents:
1250
diff
changeset
|
2893 |
doShowStoreString |
0a45ef81b47e
added showStoreString menu function
Claus Gittinger <cg@exept.de>
parents:
1250
diff
changeset
|
2894 |
"opens a dialog showing the storeString |
0a45ef81b47e
added showStoreString menu function
Claus Gittinger <cg@exept.de>
parents:
1250
diff
changeset
|
2895 |
(sometimes useful to embed an image into source code)" |
0a45ef81b47e
added showStoreString menu function
Claus Gittinger <cg@exept.de>
parents:
1250
diff
changeset
|
2896 |
|
0a45ef81b47e
added showStoreString menu function
Claus Gittinger <cg@exept.de>
parents:
1250
diff
changeset
|
2897 |
|img| |
0a45ef81b47e
added showStoreString menu function
Claus Gittinger <cg@exept.de>
parents:
1250
diff
changeset
|
2898 |
|
0a45ef81b47e
added showStoreString menu function
Claus Gittinger <cg@exept.de>
parents:
1250
diff
changeset
|
2899 |
img := imageEditView image. |
0a45ef81b47e
added showStoreString menu function
Claus Gittinger <cg@exept.de>
parents:
1250
diff
changeset
|
2900 |
TextBox openOn:img storeString |
400 | 2901 |
! ! |
2902 |
||
1353 | 2903 |
!ImageEditor methodsFor:'user actions - settings'! |
2904 |
||
2905 |
doChangeGridMagnification |
|
2906 |
"change grid magnification" |
|
2907 |
||
2908 |
|box oldGridLimit newGridLimit| |
|
2909 |
||
2910 |
oldGridLimit := imageEditView class gridMagnificationLimit asPoint. |
|
2911 |
||
2912 |
box := EnterBox new. |
|
2913 |
box title:(resources string:'Grid Magnification Limit:'). |
|
2914 |
box okText:(resources string:'OK'). |
|
2915 |
box abortText:(resources string:'Cancel'). |
|
2916 |
box initialText:(oldGridLimit x printString). |
|
2917 |
box showAtPointer. |
|
2918 |
||
2919 |
(box accepted |
|
2920 |
and: [(newGridLimit := Number readFromString:(box contents) onError:[2]) notNil] |
|
2921 |
) ifTrue:[ |
|
2922 |
newGridLimit := (99 min: (2 max:newGridLimit)) asPoint. |
|
2923 |
imageEditView class gridMagnificationLimit:newGridLimit. |
|
2924 |
imageEditView invalidate |
|
2925 |
] |
|
2926 |
||
2927 |
! ! |
|
2928 |
||
400 | 2929 |
!ImageEditor class methodsFor:'documentation'! |
2930 |
||
2931 |
version |
|
2932 |
^ '$Header$' |
|
2933 |
! ! |