author | Claus Gittinger <cg@exept.de> |
Mon, 31 May 1999 18:44:46 +0200 | |
changeset 1139 | c5940bfd4ce2 |
parent 1124 | 2392df0934bc |
child 1146 | 5645240fdc25 |
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' |
|
929 | 16 |
classVariableNames:'' |
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 |
|
946 |
#label: 'Print' |
|
947 |
#translateLabel: true |
|
948 |
#value: #doPrint |
|
949 |
#activeHelpKey: #filePrint |
|
950 |
#enabled: #imageIsLoaded |
|
951 |
) |
|
952 |
#(#MenuItem |
|
953 |
#label: '-' |
|
954 |
) |
|
955 |
#(#MenuItem |
|
956 |
#label: 'Browse Class' |
|
957 |
#translateLabel: true |
|
958 |
#value: #doBrowseClass |
|
959 |
#activeHelpKey: #fileBrowseClass |
|
960 |
#enabled: #hasClassDefined |
|
961 |
) |
|
962 |
#(#MenuItem |
|
963 |
#label: '-' |
|
964 |
) |
|
965 |
#(#MenuItem |
|
966 |
#label: 'Exit' |
|
967 |
#translateLabel: true |
|
968 |
#value: #closeRequest |
|
969 |
#activeHelpKey: #fileExit |
|
970 |
) |
|
971 |
) |
|
972 |
nil |
|
973 |
nil |
|
400 | 974 |
) |
1124 | 975 |
) |
976 |
#(#MenuItem |
|
977 |
#label: 'Edit' |
|
978 |
#translateLabel: true |
|
979 |
#activeHelpKey: #edit |
|
980 |
#enabled: #imageIsLoaded |
|
981 |
#submenu: |
|
982 |
#(#Menu |
|
983 |
#( |
|
984 |
#(#MenuItem |
|
985 |
#label: 'Undo' |
|
986 |
#translateLabel: true |
|
987 |
#value: #doUndo |
|
988 |
#activeHelpKey: #editUndo |
|
989 |
#enabled: #valueOfCanUndo |
|
990 |
) |
|
991 |
#(#MenuItem |
|
992 |
#label: '-' |
|
993 |
) |
|
994 |
#(#MenuItem |
|
995 |
#label: 'Flip - Vertical' |
|
996 |
#translateLabel: true |
|
997 |
#value: #doFlipVertical |
|
998 |
#activeHelpKey: #editFlipVertical |
|
999 |
) |
|
1000 |
#(#MenuItem |
|
1001 |
#label: 'Flip - Horizontal' |
|
1002 |
#translateLabel: true |
|
1003 |
#value: #doFlipHorizontal |
|
1004 |
#activeHelpKey: #editFlipHorizontal |
|
1005 |
) |
|
1006 |
#(#MenuItem |
|
1007 |
#label: '-' |
|
1008 |
) |
|
1009 |
#(#MenuItem |
|
1010 |
#label: 'Resize...' |
|
1011 |
#translateLabel: true |
|
1012 |
#value: #doResizeImage |
|
1013 |
#activeHelpKey: #editResize |
|
1014 |
) |
|
1015 |
#(#MenuItem |
|
1016 |
#label: 'Magnify...' |
|
1017 |
#translateLabel: true |
|
1018 |
#value: #doMagnifyImage |
|
1019 |
#activeHelpKey: #editMagnifyImage |
|
1020 |
) |
|
1021 |
#(#MenuItem |
|
1022 |
#label: 'Rotate...' |
|
1023 |
#translateLabel: true |
|
1024 |
#value: #doRotateImage |
|
1025 |
#activeHelpKey: #editRotate |
|
1026 |
) |
|
1027 |
#(#MenuItem |
|
1028 |
#label: '-' |
|
1029 |
) |
|
1030 |
#(#MenuItem |
|
1031 |
#label: 'Crop' |
|
1032 |
#translateLabel: true |
|
1033 |
#submenu: |
|
400 | 1034 |
#(#Menu |
1124 | 1035 |
#( |
1036 |
#(#MenuItem |
|
1037 |
#label: 'All' |
|
1038 |
#translateLabel: true |
|
1039 |
#value: #doCropAll |
|
1040 |
#activeHelpKey: #cropAll |
|
400 | 1041 |
) |
1124 | 1042 |
#(#MenuItem |
1043 |
#label: '-' |
|
986 | 1044 |
) |
1124 | 1045 |
#(#MenuItem |
1046 |
#label: 'Left' |
|
1047 |
#translateLabel: true |
|
1048 |
#value: #doCropLeft |
|
1049 |
#activeHelpKey: #cropLeft |
|
1050 |
) |
|
1051 |
#(#MenuItem |
|
1052 |
#label: 'Right' |
|
1053 |
#translateLabel: true |
|
1054 |
#value: #doCropRight |
|
1055 |
#activeHelpKey: #cropRight |
|
986 | 1056 |
) |
1124 | 1057 |
#(#MenuItem |
1058 |
#label: 'Top' |
|
1059 |
#translateLabel: true |
|
1060 |
#value: #doCropTop |
|
1061 |
#activeHelpKey: #cropTop |
|
672 | 1062 |
) |
1124 | 1063 |
#(#MenuItem |
1064 |
#label: 'Bottom' |
|
1065 |
#translateLabel: true |
|
1066 |
#value: #doCropBottom |
|
1067 |
#activeHelpKey: #cropBottom |
|
400 | 1068 |
) |
1124 | 1069 |
#(#MenuItem |
1070 |
#label: '-' |
|
400 | 1071 |
) |
1124 | 1072 |
#(#MenuItem |
1073 |
#label: 'Manual...' |
|
1074 |
#translateLabel: true |
|
1075 |
#value: #doCropManual |
|
1076 |
#activeHelpKey: #cropManual |
|
400 | 1077 |
) |
1124 | 1078 |
) |
1079 |
nil |
|
400 | 1080 |
nil |
1124 | 1081 |
) |
400 | 1082 |
) |
1124 | 1083 |
) |
1084 |
nil |
|
1085 |
nil |
|
400 | 1086 |
) |
1124 | 1087 |
) |
1088 |
#(#MenuItem |
|
1089 |
#label: 'ColorMap' |
|
1090 |
#translateLabel: true |
|
1091 |
#activeHelpKey: #colorMap |
|
1092 |
#enabled: #imageIsLoaded |
|
1093 |
#submenu: |
|
1094 |
#(#Menu |
|
1095 |
#( |
|
1096 |
#(#MenuItem |
|
1097 |
#label: '8-Plane' |
|
1098 |
#translateLabel: true |
|
1099 |
#value: #colorMapMode: |
|
1100 |
#activeHelpKey: #colorMap8 |
|
1101 |
#argument: '8-plane' |
|
1102 |
#choice: #colorMapMode |
|
1103 |
#choiceValue: '8-plane' |
|
1104 |
) |
|
1105 |
#(#MenuItem |
|
1106 |
#label: '4-Plane' |
|
1107 |
#translateLabel: true |
|
1108 |
#value: #colorMapMode: |
|
1109 |
#activeHelpKey: #colorMap4 |
|
1110 |
#argument: '4-plane' |
|
1111 |
#choice: #colorMapMode |
|
1112 |
#choiceValue: '4-plane' |
|
1113 |
) |
|
1114 |
#(#MenuItem |
|
1115 |
#label: '2-Plane' |
|
1116 |
#translateLabel: true |
|
1117 |
#value: #colorMapMode: |
|
1118 |
#activeHelpKey: #colorMap2 |
|
1119 |
#argument: '2-plane' |
|
1120 |
#choice: #colorMapMode |
|
1121 |
#choiceValue: '2-plane' |
|
1122 |
) |
|
1123 |
#(#MenuItem |
|
1124 |
#label: '1-Plane' |
|
1125 |
#translateLabel: true |
|
1126 |
#value: #colorMapMode: |
|
1127 |
#activeHelpKey: #colorMap1 |
|
1128 |
#argument: '1-plane' |
|
1129 |
#choice: #colorMapMode |
|
1130 |
#choiceValue: '1-plane' |
|
1131 |
) |
|
1132 |
#(#MenuItem |
|
1133 |
#label: '-' |
|
1134 |
) |
|
1135 |
#(#MenuItem |
|
1136 |
#label: '8-Plane + Mask' |
|
1137 |
#translateLabel: true |
|
1138 |
#value: #colorMapMode: |
|
1139 |
#activeHelpKey: #colorMap8M |
|
1140 |
#argument: '8-plane + mask' |
|
1141 |
#choice: #colorMapMode |
|
1142 |
#choiceValue: '8-plane + mask' |
|
1143 |
) |
|
1144 |
#(#MenuItem |
|
1145 |
#label: '4-Plane + Mask' |
|
1146 |
#translateLabel: true |
|
1147 |
#value: #colorMapMode: |
|
1148 |
#activeHelpKey: #colorMap4M |
|
1149 |
#argument: '4-plane + mask' |
|
1150 |
#choice: #colorMapMode |
|
1151 |
#choiceValue: '4-plane + mask' |
|
737 | 1152 |
) |
1124 | 1153 |
#(#MenuItem |
1154 |
#label: '2-Plane + Mask' |
|
1155 |
#translateLabel: true |
|
1156 |
#value: #colorMapMode: |
|
1157 |
#activeHelpKey: #colorMap2M |
|
1158 |
#argument: '2-plane + mask' |
|
1159 |
#choice: #colorMapMode |
|
1160 |
#choiceValue: '2-plane + mask' |
|
1161 |
) |
|
1162 |
#(#MenuItem |
|
1163 |
#label: '1-Plane + Mask' |
|
1164 |
#translateLabel: true |
|
1165 |
#value: #colorMapMode: |
|
1166 |
#activeHelpKey: #colorMap1M |
|
1167 |
#argument: '1-plane + mask' |
|
1168 |
#choice: #colorMapMode |
|
1169 |
#choiceValue: '1-plane + mask' |
|
1170 |
) |
|
1171 |
#(#MenuItem |
|
1172 |
#label: '-' |
|
1173 |
) |
|
1174 |
#(#MenuItem |
|
1175 |
#label: 'Compress colormap' |
|
1176 |
#translateLabel: true |
|
1177 |
#value: #compressColorMap |
|
1178 |
#activeHelpKey: #compressColormap |
|
1179 |
#enabled: #hasColormap |
|
1180 |
) |
|
1181 |
#(#MenuItem |
|
1182 |
#label: 'Sort colormap' |
|
1183 |
#translateLabel: true |
|
1184 |
#value: #sortColorMap |
|
1185 |
#enabled: #hasColormap |
|
1186 |
) |
|
1187 |
#(#MenuItem |
|
1188 |
#label: '-' |
|
1189 |
) |
|
1190 |
#(#MenuItem |
|
1191 |
#label: 'Reduce number of colors...' |
|
1192 |
#translateLabel: true |
|
1193 |
#value: #reduceNumberOfColors |
|
1194 |
) |
|
1195 |
) |
|
1196 |
nil |
|
1197 |
nil |
|
756 | 1198 |
) |
1124 | 1199 |
) |
1200 |
#(#MenuItem |
|
1201 |
#label: 'Settings' |
|
1202 |
#translateLabel: true |
|
1203 |
#submenu: |
|
1204 |
#(#Menu |
|
1205 |
#( |
|
1206 |
#(#MenuItem |
|
1207 |
#label: 'Grid Magnification...' |
|
1208 |
#translateLabel: true |
|
1209 |
#value: #doChangeGridMagnification |
|
1210 |
#activeHelpKey: #settingsGridMagnification |
|
1211 |
) |
|
1212 |
) |
|
1213 |
nil |
|
1214 |
nil |
|
400 | 1215 |
) |
1124 | 1216 |
) |
1217 |
#(#MenuItem |
|
1218 |
#label: 'History' |
|
1219 |
#translateLabel: true |
|
1220 |
#activeHelpKey: #history |
|
1221 |
#submenuChannel: #menuHistory |
|
1222 |
) |
|
1223 |
#(#MenuItem |
|
1224 |
#label: 'Help' |
|
1225 |
#translateLabel: true |
|
1226 |
#startGroup: #right |
|
1227 |
#activeHelpKey: #help |
|
1228 |
#submenuChannel: #menuHelp |
|
1229 |
) |
|
1230 |
) |
|
1231 |
nil |
|
1232 |
nil |
|
400 | 1233 |
) |
1234 |
! |
|
1235 |
||
679 | 1236 |
menuMouseButtonColors |
737 | 1237 |
"This resource specification was automatically generated |
1238 |
by the MenuEditor of ST/X." |
|
679 | 1239 |
|
737 | 1240 |
"Do not manually edit this!! If it is corrupted, |
1241 |
the MenuEditor may not be able to read the specification." |
|
679 | 1242 |
|
1243 |
" |
|
1244 |
MenuEditor new openOnClass:ImageEditor andSelector:#menuMouseButtonColors |
|
1245 |
(Menu new fromLiteralArrayEncoding:(ImageEditor menuMouseButtonColors)) startUp |
|
1246 |
" |
|
1247 |
||
1248 |
<resource: #menu> |
|
1249 |
||
1250 |
^ |
|
1251 |
||
1252 |
#(#Menu |
|
1253 |
||
1254 |
#( |
|
1255 |
#(#MenuItem |
|
1256 |
#label: 'Left Mouse Button' |
|
1257 |
#nameKey: #leftMouseKeyButton |
|
1258 |
#activeHelpKey: #mouseKeyColorMode |
|
975 | 1259 |
#enabled: #imageIsLoaded |
679 | 1260 |
#labelImage: #(#ResourceRetriever nil #leftMouseKeyIcon) |
975 | 1261 |
#choice: #mouseKeyColorMode |
1262 |
#choiceValue: 1 |
|
679 | 1263 |
) |
1264 |
#(#MenuItem |
|
1265 |
#label: 'Right Mouse Button' |
|
1266 |
#nameKey: #rightMouseKeyButton |
|
1267 |
#activeHelpKey: #mouseKeyColorMode |
|
975 | 1268 |
#enabled: #imageIsLoaded |
679 | 1269 |
#labelImage: #(#ResourceRetriever nil #rightMouseKeyIcon) |
975 | 1270 |
#choice: #mouseKeyColorMode |
1271 |
#choiceValue: 2 |
|
679 | 1272 |
) |
1273 |
) nil |
|
1274 |
nil |
|
1275 |
) |
|
1276 |
! |
|
1277 |
||
400 | 1278 |
menuToolbar |
737 | 1279 |
"This resource specification was automatically generated |
1280 |
by the MenuEditor of ST/X." |
|
400 | 1281 |
|
737 | 1282 |
"Do not manually edit this!! If it is corrupted, |
1283 |
the MenuEditor may not be able to read the specification." |
|
400 | 1284 |
|
1285 |
" |
|
1286 |
MenuEditor new openOnClass:ImageEditor andSelector:#menuToolbar |
|
1287 |
(Menu new fromLiteralArrayEncoding:(ImageEditor menuToolbar)) startUp |
|
1288 |
" |
|
1289 |
||
1290 |
<resource: #menu> |
|
1291 |
||
1292 |
^ |
|
1293 |
||
1294 |
#(#Menu |
|
1295 |
||
1296 |
#( |
|
1297 |
#(#MenuItem |
|
672 | 1298 |
#label: 'newImage' |
1299 |
#isButton: true |
|
767 | 1300 |
#value: #doNewImage |
672 | 1301 |
#activeHelpKey: #fileNewImage |
880 | 1302 |
#labelImage: #(#ResourceRetriever #Icon #newIcon) |
400 | 1303 |
) |
1304 |
#(#MenuItem |
|
672 | 1305 |
#label: 'loadFromClass' |
1306 |
#isButton: true |
|
767 | 1307 |
#value: #doLoadFromClass |
672 | 1308 |
#activeHelpKey: #fileLoadFromClass |
880 | 1309 |
#labelImage: #(#ResourceRetriever #Icon #loadIcon) |
672 | 1310 |
) |
1311 |
#(#MenuItem |
|
1312 |
#label: 'saveMethod' |
|
1313 |
#isButton: true |
|
767 | 1314 |
#value: #doSaveMethod |
672 | 1315 |
#activeHelpKey: #fileSaveMethod |
1316 |
#enabled: #imageIsLoaded |
|
880 | 1317 |
#labelImage: #(#ResourceRetriever #Icon #saveIcon) |
400 | 1318 |
) |
1319 |
#(#MenuItem |
|
672 | 1320 |
#label: '' |
400 | 1321 |
) |
1322 |
#(#MenuItem |
|
672 | 1323 |
#label: '' |
1324 |
) |
|
1325 |
#(#MenuItem |
|
1326 |
#label: '' |
|
1327 |
) |
|
1328 |
#(#MenuItem |
|
1329 |
#label: '' |
|
400 | 1330 |
) |
1331 |
#(#MenuItem |
|
672 | 1332 |
#label: 'Point' |
1333 |
#activeHelpKey: #drawModePoint |
|
1334 |
#enabled: #imageIsLoaded |
|
975 | 1335 |
#choice: #editMode |
1336 |
#choiceValue: #point |
|
400 | 1337 |
) |
1338 |
#(#MenuItem |
|
672 | 1339 |
#label: 'Box' |
1340 |
#activeHelpKey: #drawModeBox |
|
1341 |
#enabled: #imageIsLoaded |
|
975 | 1342 |
#choice: #editMode |
1343 |
#choiceValue: #box |
|
400 | 1344 |
) |
1345 |
#(#MenuItem |
|
672 | 1346 |
#label: 'Filled Box' |
1347 |
#activeHelpKey: #drawModeFilledBox |
|
1348 |
#enabled: #imageIsLoaded |
|
975 | 1349 |
#choice: #editMode |
1350 |
#choiceValue: #filledBox |
|
400 | 1351 |
) |
1352 |
#(#MenuItem |
|
672 | 1353 |
#label: 'Fill' |
1354 |
#activeHelpKey: #drawModeFill |
|
1355 |
#enabled: #imageIsLoaded |
|
975 | 1356 |
#choice: #editMode |
1357 |
#choiceValue: #fill |
|
400 | 1358 |
) |
1359 |
#(#MenuItem |
|
672 | 1360 |
#label: 'Copy' |
1361 |
#activeHelpKey: #drawModeCopy |
|
1362 |
#enabled: #imageIsLoaded |
|
975 | 1363 |
#choice: #editMode |
1364 |
#choiceValue: #copy |
|
400 | 1365 |
) |
1366 |
#(#MenuItem |
|
672 | 1367 |
#label: 'Paste' |
1368 |
#activeHelpKey: #drawModePaste |
|
1369 |
#enabled: #imageIsLoaded |
|
975 | 1370 |
#choice: #editMode |
1371 |
#choiceValue: #paste |
|
400 | 1372 |
) |
914 | 1373 |
#(#MenuItem |
1374 |
#label: 'Paste Under' |
|
1375 |
#activeHelpKey: #drawModePasteUnder |
|
1376 |
#enabled: #imageIsLoaded |
|
975 | 1377 |
#choice: #editMode |
1378 |
#choiceValue: #pasteUnder |
|
914 | 1379 |
) |
400 | 1380 |
) nil |
1381 |
nil |
|
1382 |
) |
|
1383 |
! ! |
|
1384 |
||
1385 |
!ImageEditor methodsFor:'accessing'! |
|
1386 |
||
1387 |
image |
|
767 | 1388 |
"returns the current editing image" |
400 | 1389 |
|
911 | 1390 |
^imageEditView image |
400 | 1391 |
! |
1392 |
||
1393 |
postOpenAction: anAction |
|
767 | 1394 |
"sets an action which is evaluated after opening" |
400 | 1395 |
|
1396 |
postOpenAction := anAction |
|
1397 |
! ! |
|
1398 |
||
1399 |
!ImageEditor methodsFor:'accessing - views'! |
|
1400 |
||
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1401 |
colorDataSetView |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1402 |
"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
|
1403 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1404 |
^(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
|
1405 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1406 |
"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
|
1407 |
! |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1408 |
|
487 | 1409 |
coordLabel |
767 | 1410 |
"returns the view the coord label" |
487 | 1411 |
|
1412 |
^builder componentAt: #coordLabel |
|
1413 |
! |
|
1414 |
||
400 | 1415 |
imageEditView |
911 | 1416 |
"returns the view of the image" |
400 | 1417 |
|
911 | 1418 |
^imageEditView := (builder componentAt: #imageEditView) subViews first |
400 | 1419 |
! |
1420 |
||
1421 |
imagePreView |
|
767 | 1422 |
"returns the preview of the image" |
400 | 1423 |
|
1424 |
^(builder componentAt: #imagePreView) subViews first |
|
475 | 1425 |
! ! |
1426 |
||
400 | 1427 |
!ImageEditor methodsFor:'aspects'! |
1428 |
||
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1429 |
activityInfoHolder |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1430 |
^ self valueOfInfoLabel |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1431 |
|
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1432 |
"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
|
1433 |
! |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1434 |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1435 |
colorColumnAdaptor |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1436 |
^ self |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1437 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1438 |
"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
|
1439 |
! |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1440 |
|
933
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1441 |
hasClassAndSelectorDefined |
1054 | 1442 |
^ [ |
1443 |
|clsName| |
|
1444 |
||
1445 |
(clsName := imageEditView resourceClass) size > 0 |
|
1446 |
and:[(Smalltalk at:clsName ifAbsent:nil) notNil |
|
1447 |
and:[imageEditView resourceSelector notNil]] |
|
1448 |
] |
|
933
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1449 |
|
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1450 |
"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
|
1451 |
! |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1452 |
|
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1453 |
hasClassDefined |
1054 | 1454 |
^ [ |
1455 |
|clsName| |
|
1456 |
||
1457 |
(clsName := imageEditView resourceClass) > 0 |
|
1458 |
and:[(Smalltalk at:clsName ifAbsent:nil) notNil] |
|
1459 |
] |
|
933
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1460 |
|
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1461 |
"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
|
1462 |
! |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1463 |
|
1008 | 1464 |
hasColormap |
1465 |
^ [self image notNil and:[self image colorMap notNil]] |
|
1466 |
||
1467 |
"Created: / 30.9.1998 / 23:53:55 / cg" |
|
1468 |
! |
|
1469 |
||
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1470 |
imageInfoHolder |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1471 |
|holder| |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1472 |
(holder := builder bindingAt:#imageInfoHolder) isNil ifTrue:[ |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1473 |
builder aspectAt:#imageInfoHolder put:(holder := '' asValue). |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1474 |
]. |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1475 |
^ holder |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1476 |
|
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1477 |
"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
|
1478 |
! |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1479 |
|
400 | 1480 |
imageIsLoaded |
767 | 1481 |
"returns whether an image is loaded as value holder" |
400 | 1482 |
|
1483 |
|holder| |
|
1484 |
(holder := builder bindingAt:#imageIsLoaded) isNil ifTrue:[ |
|
1485 |
builder aspectAt:#imageIsLoaded put:(holder := false asValue). |
|
1486 |
]. |
|
1487 |
^ holder |
|
1488 |
! |
|
1489 |
||
933
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1490 |
imageIsLoadedAndClassDefined |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1491 |
"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
|
1492 |
|
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1493 |
^ [self hasClassAndSelectorDefined value |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1494 |
and:[self imageIsLoaded value]] |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1495 |
|
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1496 |
"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
|
1497 |
! |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1498 |
|
400 | 1499 |
listOfColors |
767 | 1500 |
"returns the list of colors in a List" |
400 | 1501 |
|
1502 |
|holder| |
|
1503 |
(holder := builder bindingAt:#listOfColors) isNil ifTrue:[ |
|
1504 |
builder aspectAt:#listOfColors put:(holder := List new). |
|
942 | 1505 |
holder addDependent:self. |
400 | 1506 |
]. |
1507 |
^ holder |
|
1508 |
! |
|
1509 |
||
1510 |
selectionOfColor |
|
767 | 1511 |
"returns current selection of the edit color as an AspectAdaptor" |
400 | 1512 |
|
1513 |
|holder| |
|
1514 |
(holder := builder bindingAt:#selectionOfColor) isNil ifTrue:[ |
|
1515 |
builder aspectAt:#selectionOfColor put:( |
|
1516 |
holder := AspectAdaptor new subject:self; forAspect:#selectedColorIndex). |
|
1517 |
]. |
|
1518 |
^ holder |
|
1519 |
! |
|
1520 |
||
1521 |
valueOfMagnification |
|
767 | 1522 |
"returns current magnification of the image as an AspectAdaptor" |
400 | 1523 |
|
1524 |
|holder| |
|
1525 |
(holder := builder bindingAt:#valueOfMagnification) isNil ifTrue:[ |
|
1526 |
builder aspectAt:#valueOfMagnification put:( |
|
1527 |
holder := AspectAdaptor new subject:self; forAspect:#magnification) |
|
1528 |
]. |
|
1529 |
^ holder |
|
1530 |
! ! |
|
1531 |
||
767 | 1532 |
!ImageEditor methodsFor:'change & update'! |
1533 |
||
1534 |
findColorMapMode |
|
899 | 1535 |
"finds the colorMapMode for a new image" |
767 | 1536 |
|
1054 | 1537 |
|image listOfColors| |
1538 |
||
1539 |
image := self image. |
|
1540 |
image depth > 8 ifTrue: [ |
|
1541 |
colorMapMode value: ''. |
|
1542 |
self listOfColors removeAll. |
|
1543 |
^ nil |
|
1544 |
]. |
|
1545 |
||
1546 |
colorMapMode value:(image depth printString, '-plane'). |
|
1547 |
||
1548 |
(listOfColors := self listOfColors) isEmpty ifTrue:[ |
|
1549 |
self colorMapMode: colorMapMode value. |
|
1550 |
listOfColors := self listOfColors. |
|
1551 |
image := self image. |
|
767 | 1552 |
]. |
1054 | 1553 |
imageEditView selectColors: (Array |
1554 |
with: (listOfColors at:1) |
|
1555 |
with: (listOfColors at:2 ifAbsent:[listOfColors at:1])). |
|
1556 |
||
1557 |
image mask notNil ifTrue: [ |
|
1558 |
colorMapMode value:(colorMapMode value, ' + mask'). |
|
1559 |
||
1560 |
(listOfColors detect: [:clr| clr = (Color basicNew setColorId:0)] ifNone: nil) isNil |
|
1561 |
ifTrue:[ |
|
1562 |
listOfColors addFirst: (Color basicNew setColorId:0). |
|
1563 |
imageEditView selectColors: (Array |
|
1564 |
with:(listOfColors at:2 ifAbsent:[listOfColors at: 1]) |
|
1565 |
with: (listOfColors at: 1)). |
|
898 | 1566 |
] |
767 | 1567 |
]. |
1054 | 1568 |
self selectionOfColor |
1569 |
value: 0; |
|
1570 |
value: (self listOfColors indexOf: imageEditView selectedColor). |
|
767 | 1571 |
! |
1572 |
||
942 | 1573 |
update:something with:aParameter from:changedObject |
960 | 1574 |
|clrIndex| |
1575 |
||
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1576 |
changedObject == self listOfColors ifTrue:[ |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1577 |
something == #at: ifTrue:[ |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1578 |
"/ colormap entry changed at aParameter |
960 | 1579 |
|
1580 |
clrIndex := aParameter. |
|
1581 |
(self hasMask) ifTrue:[ |
|
1582 |
clrIndex := clrIndex - 1. |
|
1583 |
]. |
|
1584 |
||
1585 |
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
|
1586 |
self colorMapChanged. |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1587 |
^ self |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1588 |
]. |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1589 |
]. |
1124 | 1590 |
|
1591 |
changedObject == imageEditView undoImages ifTrue:[ |
|
1592 |
self valueOfCanUndo value:(changedObject notEmpty). |
|
1593 |
^ self. |
|
1594 |
]. |
|
1595 |
||
942 | 1596 |
super update:something with:aParameter from:changedObject |
1597 |
||
960 | 1598 |
"Modified: / 18.8.1998 / 17:18:42 / cg" |
942 | 1599 |
! |
1600 |
||
1054 | 1601 |
updateForNoImage |
767 | 1602 |
"updates channels and view, if image is loaded" |
1603 |
||
1604 |
self imageIsLoaded value: false. |
|
1605 |
self listOfColors removeAll. |
|
1606 |
self imagePreView image: nil |
|
1607 |
||
1608 |
||
1609 |
||
1610 |
||
1611 |
! |
|
1612 |
||
1613 |
updateLabelsAndHistory |
|
1614 |
"updates labels and history, if something has changed" |
|
1615 |
||
1616 |
self imageIsLoaded value: self image notNil. |
|
1617 |
||
1618 |
self image isNil ifTrue: [^nil]. |
|
1619 |
||
1620 |
self updateInfoLabel. |
|
1621 |
||
911 | 1622 |
imageEditView resourceMessage asCollectionOfWords size = 2 |
1623 |
ifTrue: [self addToHistory: imageEditView resourceMessage -> #loadFromMessage:]. |
|
767 | 1624 |
|
1625 |
self image fileName notNil |
|
1626 |
ifTrue: [self addToHistory: self image fileName -> #loadFromFile:]. |
|
1627 |
||
1628 |
||
1629 |
||
1630 |
! ! |
|
1631 |
||
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1632 |
!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
|
1633 |
|
942 | 1634 |
blueAtColor:aColor put:newBlue |
1635 |
"helper used to return a new row element, when blue is changed" |
|
1636 |
||
1637 |
|byte| |
|
1638 |
||
1639 |
aColor isNil ifTrue:[^ aColor]. "/ mask cannot be changed |
|
1640 |
byte := newBlue clampBetween:0 and:255. |
|
960 | 1641 |
byte = aColor blueByte ifTrue:[^ aColor]. |
942 | 1642 |
^ Color redByte:(aColor redByte) greenByte:(aColor greenByte) blueByte:byte |
960 | 1643 |
|
1644 |
"Modified: / 18.8.1998 / 17:00:12 / cg" |
|
942 | 1645 |
! |
1646 |
||
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1647 |
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
|
1648 |
"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
|
1649 |
|
930 | 1650 |
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
|
1651 |
^ 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
|
1652 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1653 |
"Created: / 26.7.1998 / 12:30:35 / cg" |
930 | 1654 |
"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
|
1655 |
! |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1656 |
|
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1657 |
canSelectBlueInColor:aColor |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1658 |
^ aColor blueByte notNil |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1659 |
|
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1660 |
"Created: / 7.8.1998 / 22:50:34 / cg" |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1661 |
"Modified: / 7.8.1998 / 22:52:57 / cg" |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1662 |
! |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1663 |
|
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1664 |
canSelectGreenInColor:aColor |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1665 |
^ aColor greenByte notNil |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1666 |
|
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1667 |
"Created: / 7.8.1998 / 22:50:22 / cg" |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1668 |
"Modified: / 7.8.1998 / 22:52:46 / cg" |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1669 |
! |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1670 |
|
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1671 |
canSelectRedInColor:aColor |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1672 |
^ aColor redByte notNil |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1673 |
|
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1674 |
"Created: / 7.8.1998 / 22:50:00 / cg" |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1675 |
"Modified: / 7.8.1998 / 22:51:03 / cg" |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1676 |
! |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1677 |
|
942 | 1678 |
greenAtColor:aColor put:newGreen |
1679 |
"helper used to return a new row element, when green is changed" |
|
1680 |
||
1681 |
|byte| |
|
1682 |
||
1683 |
aColor isNil ifTrue:[^ aColor]. "/ mask cannot be changed |
|
1684 |
byte := newGreen clampBetween:0 and:255. |
|
960 | 1685 |
byte = aColor greenByte ifTrue:[^ aColor]. |
942 | 1686 |
^ Color redByte:(aColor redByte) greenByte:byte blueByte:(aColor blueByte) |
960 | 1687 |
|
1688 |
"Modified: / 18.8.1998 / 17:00:38 / cg" |
|
942 | 1689 |
! |
1690 |
||
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1691 |
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
|
1692 |
"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
|
1693 |
|
930 | 1694 |
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
|
1695 |
^ 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
|
1696 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1697 |
"Created: / 26.7.1998 / 12:30:29 / cg" |
930 | 1698 |
"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
|
1699 |
! |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1700 |
|
942 | 1701 |
redAtColor:aColor put:newRed |
1702 |
"helper used to return a new row element, when red is changed" |
|
1703 |
||
1704 |
|byte| |
|
1705 |
||
1706 |
aColor isNil ifTrue:[^ aColor]. "/ mask cannot be changed |
|
1707 |
byte := newRed clampBetween:0 and:255. |
|
960 | 1708 |
byte = aColor redByte ifTrue:[^ aColor]. |
942 | 1709 |
^ Color redByte:byte greenByte:(aColor greenByte) blueByte:(aColor blueByte) |
960 | 1710 |
|
1711 |
"Modified: / 18.8.1998 / 17:00:49 / cg" |
|
942 | 1712 |
! |
1713 |
||
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1714 |
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
|
1715 |
"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
|
1716 |
|
930 | 1717 |
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
|
1718 |
^ 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
|
1719 |
|
930 | 1720 |
"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
|
1721 |
! ! |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1722 |
|
672 | 1723 |
!ImageEditor methodsFor:'help'! |
1724 |
||
1725 |
defaultInfoLabel |
|
767 | 1726 |
"returns the default info label" |
672 | 1727 |
|
911 | 1728 |
(imageEditView resourceClass isSymbol and: [(Smalltalk at: imageEditView resourceClass) isClass]) |
672 | 1729 |
ifTrue: |
1730 |
[ |
|
911 | 1731 |
^imageEditView resourceClass, ' >> ', imageEditView resourceSelector |
672 | 1732 |
]. |
767 | 1733 |
^'No class and selector defined.' |
674 | 1734 |
! |
1735 |
||
702 | 1736 |
openDocumentation |
767 | 1737 |
"opens the documentation file of the Image Editor" |
674 | 1738 |
|
763 | 1739 |
self openHTMLDocument: 'tools/uipainter/ImageEditor.html' |
1740 |
||
672 | 1741 |
! ! |
1742 |
||
767 | 1743 |
!ImageEditor methodsFor:'loading'! |
1744 |
||
1745 |
loadFromFile: aFileName |
|
1746 |
"loads an image from aFileName and sets up color map list and other info labels" |
|
1747 |
||
960 | 1748 |
|img| |
1749 |
||
980
bd21079f40e1
show waitCursor while loading from file.
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1750 |
self withCursor:Cursor wait do:[ |
bd21079f40e1
show waitCursor while loading from file.
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1751 |
(imageEditView loadFromFile: aFileName) notNil ifTrue:[ |
bd21079f40e1
show waitCursor while loading from file.
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1752 |
(img := self image) notNil ifTrue:[ |
bd21079f40e1
show waitCursor while loading from file.
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1753 |
img colorMap notNil ifTrue:[ |
bd21079f40e1
show waitCursor while loading from file.
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1754 |
self listOfColors contents:(img usedColors asSet asOrderedCollection). |
bd21079f40e1
show waitCursor while loading from file.
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1755 |
] ifFalse:[ |
bd21079f40e1
show waitCursor while loading from file.
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1756 |
self listOfColors removeAll. |
bd21079f40e1
show waitCursor while loading from file.
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1757 |
]. |
bd21079f40e1
show waitCursor while loading from file.
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1758 |
self findColorMapMode. |
bd21079f40e1
show waitCursor while loading from file.
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1759 |
self updateLabelsAndHistory. |
1057 | 1760 |
imageEditView image:img. |
960 | 1761 |
] ifFalse:[ |
1054 | 1762 |
self updateForNoImage |
1057 | 1763 |
]. |
1764 |
self imagePreView image:img. |
|
767 | 1765 |
] |
1766 |
] |
|
960 | 1767 |
|
1057 | 1768 |
"Modified: / 16.3.1999 / 21:44:26 / cg" |
767 | 1769 |
! |
1770 |
||
960 | 1771 |
loadFromImage:anImage |
767 | 1772 |
"loads an image from anImage and sets up color map list and other info labels" |
1773 |
||
960 | 1774 |
imageEditView image:anImage. |
1057 | 1775 |
self imagePreView image: anImage. |
1776 |
anImage notNil ifTrue:[ |
|
1777 |
anImage colorMap notNil ifTrue:[ |
|
1778 |
self listOfColors contents:(anImage usedColors asSet asOrderedCollection). |
|
960 | 1779 |
] ifFalse:[ |
767 | 1780 |
self listOfColors removeAll. |
1781 |
]. |
|
1782 |
self findColorMapMode. |
|
1783 |
self updateLabelsAndHistory. |
|
960 | 1784 |
] ifFalse:[ |
1054 | 1785 |
self updateForNoImage |
767 | 1786 |
] |
960 | 1787 |
|
1057 | 1788 |
"Modified: / 16.3.1999 / 21:43:56 / cg" |
767 | 1789 |
! |
1790 |
||
1791 |
loadFromMessage: aMessage |
|
1792 |
"loads an image by evaluating aMessage and sets up color map list and other info labels" |
|
1793 |
||
960 | 1794 |
|img| |
1795 |
||
1796 |
(imageEditView loadFromMessage: aMessage) notNil ifTrue:[ |
|
1797 |
(img := self image) notNil ifTrue:[ |
|
1798 |
self listOfColors contents:(img usedColors asSet asOrderedCollection). |
|
767 | 1799 |
self findColorMapMode. |
1800 |
self updateLabelsAndHistory. |
|
1057 | 1801 |
imageEditView image:img. |
1802 |
self imagePreView image:img. |
|
960 | 1803 |
] ifFalse:[ |
1054 | 1804 |
self updateForNoImage |
767 | 1805 |
] |
1806 |
] |
|
960 | 1807 |
|
1057 | 1808 |
"Modified: / 16.3.1999 / 21:44:41 / cg" |
767 | 1809 |
! |
1810 |
||
1811 |
loadFromOrPrepareForMessage: aMessage |
|
1812 |
"loads an image by evaluating aMessage; |
|
1813 |
if no image could extract from aMessage; do set the class and the selector from |
|
1814 |
the aMessage for a saving at the end of editing" |
|
1815 |
||
911 | 1816 |
(imageEditView loadFromMessage: aMessage) notNil |
767 | 1817 |
ifTrue: |
1818 |
[ |
|
1819 |
self listOfColors contents: self image usedColors asSet asOrderedCollection. |
|
1820 |
self findColorMapMode. |
|
1821 |
] |
|
1822 |
ifFalse: |
|
1823 |
[ |
|
911 | 1824 |
imageEditView resourceMessage: aMessage. |
767 | 1825 |
]. |
1826 |
self updateLabelsAndHistory. |
|
1057 | 1827 |
self imagePreView image:(self image). |
1828 |
||
1829 |
"Modified: / 16.3.1999 / 21:45:07 / cg" |
|
767 | 1830 |
! ! |
1831 |
||
400 | 1832 |
!ImageEditor methodsFor:'menu modes'! |
1833 |
||
975 | 1834 |
colorMapMode |
1835 |
"returns colorMapMode" |
|
400 | 1836 |
|
975 | 1837 |
colorMapMode isNil ifTrue: [colorMapMode := '' asValue]. |
400 | 1838 |
|
975 | 1839 |
^colorMapMode |
400 | 1840 |
! |
1841 |
||
975 | 1842 |
editMode |
1843 |
"returns editMode" |
|
400 | 1844 |
|
1054 | 1845 |
editMode isNil ifTrue: [ |
975 | 1846 |
editMode := #point asValue. |
1054 | 1847 |
editMode onChangeSend:#value to:[imageEditView editMode:(editMode value)] |
975 | 1848 |
]. |
1849 |
||
1850 |
^editMode |
|
400 | 1851 |
! |
1852 |
||
975 | 1853 |
mouseKeyColorMode |
1854 |
"returns mouseKeyColorMode" |
|
400 | 1855 |
|
975 | 1856 |
mouseKeyColorMode isNil |
1857 |
ifTrue: |
|
1858 |
[ |
|
1859 |
mouseKeyColorMode := 1 asValue. |
|
1860 |
mouseKeyColorMode onChangeSend: #value to: [imageEditView mouseKeyColorMode: mouseKeyColorMode value. self selectionOfColor value: (self listOfColors indexOf: imageEditView selectedColor).] |
|
956 | 1861 |
]. |
400 | 1862 |
|
975 | 1863 |
^mouseKeyColorMode |
400 | 1864 |
! ! |
1865 |
||
535 | 1866 |
!ImageEditor methodsFor:'queries'! |
1867 |
||
960 | 1868 |
hasMask |
975 | 1869 |
^ colorMapMode notNil and:[colorMapMode value endsWith:'mask'] |
960 | 1870 |
|
1871 |
"Created: / 18.8.1998 / 17:17:38 / cg" |
|
1872 |
! |
|
1873 |
||
535 | 1874 |
preferredExtent |
767 | 1875 |
"returns the preferred extent" |
535 | 1876 |
|
1877 |
^super preferredExtent max: (Screen current width//3)@(Screen current height//3.5) |
|
1878 |
||
1879 |
||
1880 |
! ! |
|
1881 |
||
400 | 1882 |
!ImageEditor methodsFor:'selection'! |
1883 |
||
1884 |
magnification |
|
767 | 1885 |
"returns the magnification of the image" |
400 | 1886 |
|
911 | 1887 |
self imageEditView isNil ifTrue: [^1]. |
1888 |
^imageEditView magnification x |
|
400 | 1889 |
! |
1890 |
||
1891 |
magnification: aValue |
|
767 | 1892 |
"sets the magnification of the image" |
400 | 1893 |
|
905 | 1894 |
|magnification| |
1895 |
magnification := (aValue ? 1) asPoint. |
|
911 | 1896 |
(magnification = imageEditView magnification or: [magnification = (0@0)]) ifTrue: [^nil]. |
1897 |
imageEditView magnification: magnification |
|
400 | 1898 |
! |
1899 |
||
1900 |
selectedColorIndex |
|
767 | 1901 |
"returns the index of the selected color" |
400 | 1902 |
|
1903 |
^selectedColorIndex |
|
1904 |
! |
|
1905 |
||
1906 |
selectedColorIndex: anIndex |
|
767 | 1907 |
"sets the index of the selected color" |
400 | 1908 |
|
1054 | 1909 |
|clr pixel| |
1910 |
||
1911 |
selectedColorIndex := anIndex. |
|
1912 |
clr := self listOfColors at:anIndex ifAbsent:nil. |
|
1913 |
clr isNil ifTrue:[^ self]. |
|
1914 |
||
1075 | 1915 |
pixel := anIndex - 1. |
1054 | 1916 |
(self listOfColors at:1) = Color noColor ifTrue:[ |
1917 |
anIndex == 1 ifTrue:[ |
|
1918 |
pixel := nil. "/ mask |
|
1919 |
] ifFalse:[ |
|
1075 | 1920 |
pixel := pixel - 1 |
1054 | 1921 |
] |
1922 |
]. |
|
1923 |
imageEditView selectedColorIndex:pixel. |
|
1924 |
imageEditView selectedColor:clr. |
|
400 | 1925 |
|
1926 |
! ! |
|
1927 |
||
1928 |
!ImageEditor methodsFor:'startup / release'! |
|
1929 |
||
1930 |
closeRequest |
|
767 | 1931 |
"close request" |
400 | 1932 |
|
911 | 1933 |
imageEditView checkModified ifTrue:[super closeRequest] |
400 | 1934 |
|
1935 |
! |
|
1936 |
||
1937 |
open |
|
767 | 1938 |
"after opening, sets the masterApplication of the imageEditView to self" |
400 | 1939 |
|
1940 |
super open. |
|
444 | 1941 |
|
911 | 1942 |
imageEditView := (builder componentAt: #imageEditView) subViews first. |
975 | 1943 |
imageEditView masterApplication: self. |
1944 |
||
400 | 1945 |
! |
1946 |
||
1947 |
postOpenWith:aBuilder |
|
767 | 1948 |
"after opening, sets the masterApplication of the imageEditView to self; |
1949 |
evaluate the postOpenAction" |
|
400 | 1950 |
|
911 | 1951 |
imageEditView masterApplication: self. |
1124 | 1952 |
imageEditView undoImages addDependent:self. |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1953 |
imageEditView imageInfoHolder:(self imageInfoHolder). |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1954 |
imageEditView activityInfoHolder:(self activityInfoHolder). |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1955 |
|
400 | 1956 |
postOpenAction notNil ifTrue: [postOpenAction value]. |
1957 |
||
767 | 1958 |
super postOpenWith:aBuilder |
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1959 |
|
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1960 |
"Modified: / 29.7.1998 / 18:49:20 / cg" |
400 | 1961 |
! ! |
1962 |
||
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1963 |
!ImageEditor methodsFor:'user actions - colormap'! |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1964 |
|
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
1965 |
addColorToColormap |
1057 | 1966 |
|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
|
1967 |
|
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
1968 |
img := self image. |
1054 | 1969 |
depth := img depth. |
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
1970 |
cMap := img colorMap. |
1054 | 1971 |
cMap isNil ifTrue:[ |
1972 |
self warn:'Image has no colormap\change colorMap mode first.' withCRs. |
|
1973 |
^ self |
|
1974 |
]. |
|
1975 |
||
1976 |
((depth == 1) |
|
1977 |
or:[cMap size == (1 bitShift:depth)]) ifTrue:[ |
|
1978 |
depth >= 8 ifTrue:[ |
|
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
1979 |
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
|
1980 |
^ self |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
1981 |
]. |
1054 | 1982 |
(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
|
1983 |
ifFalse:[ |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
1984 |
^ self |
1057 | 1985 |
]. |
1986 |
||
1987 |
imageEditView makeUndo. |
|
1988 |
newMode := (depth*2) printString , (colorMapMode value copyFrom:2). |
|
1989 |
self colorMapMode:newMode. |
|
1990 |
] ifFalse:[ |
|
1991 |
imageEditView makeUndo. |
|
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
1992 |
]. |
1054 | 1993 |
|
1994 |
cMap := cMap asArray. |
|
1995 |
oldCListSize := self listOfColors size. |
|
1996 |
||
1997 |
"/ (colorMapMode value asString endsWith:'mask') ifTrue:[ |
|
1998 |
"/ cMap last = Color noColor ifTrue:[ |
|
1999 |
"/ cMap := cMap copyWithoutLast:1 |
|
2000 |
"/ ] ifFalse:[ |
|
2001 |
"/ cMap first = Color noColor ifTrue:[ |
|
2002 |
"/ cMap := cMap copyFrom:2 |
|
2003 |
"/ ] |
|
2004 |
"/ ]. |
|
2005 |
"/ ]. |
|
2006 |
"/ |
|
2007 |
||
2008 |
newColorMap := cMap copyWith:(Color black). |
|
2009 |
||
2010 |
newImage := img species new |
|
2011 |
width:img width |
|
2012 |
height:img height |
|
2013 |
depth:depth |
|
2014 |
fromArray:img bits. |
|
2015 |
||
2016 |
newImage colorMap:newColorMap. |
|
2017 |
newImage fileName:img fileName. |
|
2018 |
newImage mask:(img mask copy). |
|
2019 |
||
2020 |
(imageEditView image:newImage) notNil ifTrue:[ |
|
2021 |
self listOfColors contents: newImage colorMap. |
|
2022 |
self findColorMapMode. |
|
2023 |
"/ mhmh - somehow, we get two colors added ... (sigh findColorMapMode adds another one ...) |
|
2024 |
self listOfColors size > (oldCListSize + 1) ifTrue:[ |
|
2025 |
self listOfColors removeLast |
|
2026 |
]. |
|
2027 |
self selectionOfColor value:(self listOfColors size). |
|
2028 |
self updateLabelsAndHistory. |
|
2029 |
] |
|
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
2030 |
|
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
2031 |
"Created: / 12.3.1999 / 00:20:28 / cg" |
1057 | 2032 |
"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
|
2033 |
! |
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
2034 |
|
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2035 |
colorMapChanged |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2036 |
|img| |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2037 |
|
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2038 |
img := self image. |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2039 |
img release. |
960 | 2040 |
imageEditView invalidate. |
2041 |
self imagePreView invalidate. |
|
2042 |
||
2043 |
"/ (imageEditView image:img) notNil ifTrue:[ |
|
2044 |
"/ self updateLabelsAndHistory. |
|
2045 |
"/ self imagePreView image:img |
|
2046 |
"/ ] |
|
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2047 |
|
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2048 |
"Created: / 7.8.1998 / 22:26:10 / cg" |
960 | 2049 |
"Modified: / 18.8.1998 / 17:08:55 / cg" |
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2050 |
! |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
2051 |
|
975 | 2052 |
colorMapMode:aMode |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2053 |
"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
|
2054 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2055 |
|depth numColors newColorMap newImage |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2056 |
oldImage image newColors realColorMap oldFileName |
1008 | 2057 |
usedColors useNearest usageCounts tmpBits tmpMap quest |
2058 |
prevMode maskThreshold maskImage| |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2059 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2060 |
self withExecuteCursorDo:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2061 |
oldImage := self image. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2062 |
|
1053
31097504a15a
fixed startup (modal box in calling thread, instead of
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
2063 |
prevMode := colorMapMode value. |
1008 | 2064 |
oldImage depth > 8 ifTrue:[ |
2065 |
prevMode := nil |
|
2066 |
]. |
|
2067 |
||
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2068 |
newColorMap := self class listOfColorMaps at:aMode. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2069 |
depth := (newColorMap size log: 2) asInteger. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2070 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2071 |
useNearest := false. |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
2072 |
depth == 1 ifTrue:[ |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
2073 |
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
|
2074 |
] ifFalse:[ |
1008 | 2075 |
prevMode isNil ifTrue:[ |
2076 |
quest := 'Compute colormap (or use standard)' |
|
2077 |
] ifFalse:[ |
|
2078 |
quest := 'Keep colormap (or use standard)' |
|
2079 |
] |
|
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
2080 |
]. |
1008 | 2081 |
((prevMode = aMode) |
1057 | 2082 |
or:[depth > oldImage depth |
2083 |
or:[self confirm:(resources string:quest)]]) ifTrue:[ |
|
1008 | 2084 |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2085 |
"/ keep the colormap |
1008 | 2086 |
newColorMap atAllPut:Color black. |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2087 |
depth > oldImage depth ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2088 |
"/ easy - simply copy the part |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2089 |
numColors := 1 bitShift:oldImage depth. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2090 |
0 to:numColors-1 do:[:pixel | |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2091 |
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
|
2092 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2093 |
] ifFalse:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2094 |
"/ see if all used color fit the new colormap |
986 | 2095 |
usedColors := oldImage usedColorsMax:(1 bitShift:depth). |
2096 |
(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
|
2097 |
"/ yea - just install them |
986 | 2098 |
usedColors asArray keysAndValuesDo:[:idx :clr | |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2099 |
newColorMap at:idx put:clr |
1008 | 2100 |
]. |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2101 |
] ifFalse:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2102 |
"/ copy over those that are most often used. |
986 | 2103 |
oldImage depth < 8 ifTrue:[ |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2104 |
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
|
2105 |
oldImage bits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2106 |
expandPixels:(oldImage depth) |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2107 |
width:oldImage width |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2108 |
height:oldImage height |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2109 |
into:tmpBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2110 |
mapping:nil. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2111 |
] ifFalse:[ |
986 | 2112 |
oldImage depth == 8 ifTrue:[ |
2113 |
tmpBits := oldImage bits |
|
2114 |
] ifFalse:[ |
|
1124 | 2115 |
colorMapMode value:prevMode. |
1123 | 2116 |
self warn:('Too many colors in image ( ', oldImage usedColors size printString , ').'). |
986 | 2117 |
^ self |
2118 |
] |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2119 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2120 |
usageCounts := tmpBits usageCounts. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2121 |
tmpMap := Array new:usageCounts size. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2122 |
oldImage colorMap asArray keysAndValuesDo:[:i :clr | |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2123 |
tmpMap at:i put:clr |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2124 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2125 |
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
|
2126 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2127 |
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
|
2128 |
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
|
2129 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2130 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2131 |
useNearest := Dialog |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
2132 |
confirmWithCancel:(resources |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
2133 |
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
|
2134 |
with:usedColors size |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
2135 |
with:(1 bitShift:depth)) withCRs |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
2136 |
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
|
2137 |
useNearest isNil ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2138 |
^ self "/ cancel |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2139 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2140 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2141 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2142 |
] ifFalse:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2143 |
"/ standard colormap |
921
a5aca21ea803
also allow nearest-color mode for standard colormap.
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
2144 |
usedColors := oldImage usedColors. |
a5aca21ea803
also allow nearest-color mode for standard colormap.
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
2145 |
(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
|
2146 |
useNearest := Dialog |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
2147 |
confirmWithCancel:(resources |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
2148 |
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
|
2149 |
) withCRs |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
2150 |
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
|
2151 |
useNearest isNil ifTrue:[ |
a5aca21ea803
also allow nearest-color mode for standard colormap.
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
2152 |
^ self "/ cancel |
a5aca21ea803
also allow nearest-color mode for standard colormap.
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
2153 |
]. |
a5aca21ea803
also allow nearest-color mode for standard colormap.
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
2154 |
]. |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2155 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2156 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2157 |
imageEditView makeUndo. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2158 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2159 |
newImage := (Image implementorForDepth: depth) new. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2160 |
oldFileName := oldImage fileName. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2161 |
|
1008 | 2162 |
Image imageErrorSignal handle:[:ex| |
2163 |
Color colorErrorSignal handle:[:ex| |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2164 |
imageEditView undo. |
1008 | 2165 |
^ self warn:(resources string:'Conversion failed !!') |
2166 |
] do:[ |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2167 |
newImage := (Image implementorForDepth: depth) new. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2168 |
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
|
2169 |
newImage colorMap:newColorMap. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2170 |
newImage photometric:#palette. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2171 |
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
|
2172 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2173 |
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
|
2174 |
[:x :y :clr | |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2175 |
|newColor| |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2176 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2177 |
(newColorMap includes:clr) |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2178 |
ifTrue: [newColor := clr] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2179 |
ifFalse: [ |
1008 | 2180 |
newColor := clr nearestIn:newColorMap. |
2181 |
useNearest ifFalse:[ |
|
2182 |
(newColor deltaFrom:clr) > 0.5 ifTrue:[ |
|
2183 |
newColor := oldImage colorFromValue:0 |
|
2184 |
] |
|
919
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 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2187 |
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
|
2188 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2189 |
image := newImage |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2190 |
]. |
1008 | 2191 |
] do:[ |
2192 |
image := newImage fromImage:oldImage |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2193 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2194 |
|
1008 | 2195 |
(aMode asString endsWith:'mask') ifTrue:[ |
2196 |
image mask isNil ifTrue:[ |
|
2197 |
(self confirm:'Generate mask from black ?') ifTrue:[ |
|
2198 |
maskThreshold := 0.1. |
|
2199 |
maskImage := Depth1Image fromImage:(image asThresholdMonochromeImage:maskThreshold). |
|
2200 |
] ifFalse:[ |
|
2201 |
maskImage := Depth1Image extent:image extent. |
|
2202 |
maskImage data:(ByteArray |
|
2203 |
new:(maskImage bytesPerRow * maskImage height) |
|
2204 |
withAll:16rFF). |
|
2205 |
||
2206 |
"/ maskImage fillRectangle:(image bounds) withColor:(Color colorId:1). |
|
2207 |
]. |
|
2208 |
image mask:maskImage. |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2209 |
]. |
1008 | 2210 |
] ifFalse:[ |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2211 |
image mask: nil. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2212 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2213 |
realColorMap := OrderedCollection new. |
1054 | 2214 |
image realColorMap do:[:clr| |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2215 |
(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
|
2216 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2217 |
newColors := realColorMap copyFrom: 1 to: (newColorMap size min: realColorMap size). |
1054 | 2218 |
newColorMap do:[:clr| |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2219 |
((newColors size < newColorMap size) and: [(newColors includes: clr) not]) |
1054 | 2220 |
ifTrue:[ |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2221 |
newColors add: clr |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2222 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2223 |
]. |
975 | 2224 |
image colorMap: newColors. |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2225 |
|
1054 | 2226 |
(imageEditView image: image) notNil ifTrue:[ |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2227 |
image fileName: oldFileName. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2228 |
self listOfColors contents: image colorMap. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2229 |
self findColorMapMode. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2230 |
self updateLabelsAndHistory. |
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 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2233 |
|
1057 | 2234 |
"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
|
2235 |
! |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2236 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2237 |
compressColorMap |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2238 |
"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
|
2239 |
|
927 | 2240 |
|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
|
2241 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2242 |
oldImage := self image. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2243 |
depth := oldImage depth. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2244 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2245 |
oldImage photometric ~~ #palette ifTrue:[ |
930 | 2246 |
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
|
2247 |
^ self |
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 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2250 |
usedColors := oldImage usedColors. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2251 |
usedColors size == (1 bitShift:depth) ifTrue:[ |
930 | 2252 |
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
|
2253 |
^ self |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2254 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2255 |
usedColors size == oldImage colorMap size ifTrue:[ |
930 | 2256 |
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
|
2257 |
^ self |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2258 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2259 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2260 |
imageEditView makeUndo. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2261 |
|
930 | 2262 |
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
|
2263 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2264 |
self withExecuteCursorDo:[ |
996
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2265 |
"/ newColorMap := Array new:usedColors size. |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2266 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2267 |
"/ translation table |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2268 |
oldToNew := ByteArray new:(1 bitShift:depth). |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2269 |
newColorMap := usedColors asArray. |
996
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2270 |
newColorMap sort:[:a :b | |
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2271 |
a redByte == b redByte ifTrue:[ |
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2272 |
a greenByte == b greenByte ifTrue:[ |
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2273 |
a blueByte < b blueByte |
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2274 |
] ifFalse:[ |
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2275 |
a greenByte < b greenByte |
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2276 |
] |
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2277 |
] ifFalse:[ |
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2278 |
a redByte < b redByte |
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2279 |
] |
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2280 |
]. |
9423ae277168
sort colors when compressing the colorMap
Claus Gittinger <cg@exept.de>
parents:
990
diff
changeset
|
2281 |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2282 |
oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr | |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2283 |
|newPixel| |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2284 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2285 |
(usedColors includes:clr) ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2286 |
newPixel := newColorMap indexOf:clr. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2287 |
oldToNew at:oldIdx put:newPixel-1. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2288 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2289 |
]. |
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 |
oldBits := oldImage bits. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2292 |
newBits := ByteArray new:(oldBits size). |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2293 |
depth ~~ 8 ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2294 |
"/ expand/compress can only handle 8bits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2295 |
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
|
2296 |
oldBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2297 |
expandPixels:depth |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2298 |
width:oldImage width |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2299 |
height:oldImage height |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2300 |
into:tmpBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2301 |
mapping:oldToNew. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2302 |
tmpBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2303 |
compressPixels:depth |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2304 |
width:oldImage width |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2305 |
height:oldImage height |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2306 |
into:newBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2307 |
mapping:nil |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2308 |
] ifFalse:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2309 |
oldBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2310 |
expandPixels:depth |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2311 |
width:oldImage width |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2312 |
height:oldImage height |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2313 |
into:newBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2314 |
mapping:oldToNew. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2315 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2316 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2317 |
newImage := oldImage species new |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2318 |
width:oldImage width |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2319 |
height:oldImage height |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2320 |
depth:depth |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2321 |
fromArray:newBits. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2322 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2323 |
newImage colorMap:newColorMap. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2324 |
newImage fileName:oldImage fileName. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2325 |
newImage mask:(oldImage mask copy). |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2326 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2327 |
(imageEditView image:newImage) notNil ifTrue: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2328 |
[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2329 |
self listOfColors contents: newImage colorMap. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2330 |
self findColorMapMode. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2331 |
self updateLabelsAndHistory. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2332 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2333 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2334 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2335 |
"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
|
2336 |
"Modified: / 15.9.1998 / 17:53:32 / cg" |
1008 | 2337 |
! |
2338 |
||
1124 | 2339 |
reduceNumberOfColors |
2340 |
|s n anyChange img| |
|
2341 |
||
2342 |
s := Dialog request:'Number of color bits to strip (1-7) ?'. |
|
2343 |
s isNil ifTrue:[^ self]. |
|
2344 |
n := Integer readFrom:s onError:0. |
|
2345 |
(n between:1 and:7) ifFalse:[ |
|
2346 |
Dialog warn:'Image unchanged'. |
|
2347 |
^ self |
|
2348 |
]. |
|
2349 |
||
2350 |
imageEditView makeUndo. |
|
2351 |
self withExecuteCursorDo:[ |
|
2352 |
anyChange := imageEditView reduceColorResolutionBy:n. |
|
2353 |
anyChange ifFalse:[ |
|
2354 |
Dialog warn:'Image unchanged'. |
|
2355 |
] ifTrue:[ |
|
2356 |
img := imageEditView image. |
|
2357 |
imageEditView image:img. |
|
2358 |
self listOfColors contents:(img colorMap). |
|
2359 |
self findColorMapMode. |
|
2360 |
self updateLabelsAndHistory. |
|
2361 |
Dialog information:(img usedColors size printString , ' colors used.') |
|
2362 |
] |
|
2363 |
]. |
|
2364 |
! |
|
2365 |
||
1008 | 2366 |
sortColorMap |
2367 |
"calculates a new color map for the image, sorting colors" |
|
2368 |
||
2369 |
|depth newColorMap newImage oldImage usedColors oldToNew oldBits newBits tmpBits| |
|
2370 |
||
2371 |
oldImage := self image. |
|
2372 |
depth := oldImage depth. |
|
2373 |
||
2374 |
oldImage photometric ~~ #palette ifTrue:[ |
|
2375 |
self information:'Compress colorMap: Only palette images have colormaps.'. |
|
2376 |
^ self |
|
2377 |
]. |
|
2378 |
||
2379 |
usedColors := oldImage realColorMap. |
|
2380 |
||
2381 |
imageEditView makeUndo. |
|
2382 |
||
2383 |
self withExecuteCursorDo:[ |
|
2384 |
"/ newColorMap := Array new:usedColors size. |
|
2385 |
||
2386 |
"/ translation table |
|
2387 |
oldToNew := ByteArray new:(1 bitShift:depth). |
|
2388 |
newColorMap := usedColors asArray. |
|
2389 |
newColorMap sort:[:a :b | |
|
2390 |
a redByte == b redByte ifTrue:[ |
|
2391 |
a greenByte == b greenByte ifTrue:[ |
|
2392 |
a blueByte < b blueByte |
|
2393 |
] ifFalse:[ |
|
2394 |
a greenByte < b greenByte |
|
2395 |
] |
|
2396 |
] ifFalse:[ |
|
2397 |
a redByte < b redByte |
|
2398 |
] |
|
2399 |
]. |
|
2400 |
||
2401 |
oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr | |
|
2402 |
|newPixel| |
|
2403 |
||
2404 |
(usedColors includes:clr) ifTrue:[ |
|
2405 |
newPixel := newColorMap indexOf:clr. |
|
2406 |
oldToNew at:oldIdx put:newPixel-1. |
|
2407 |
] |
|
2408 |
]. |
|
2409 |
||
2410 |
oldBits := oldImage bits. |
|
2411 |
newBits := ByteArray new:(oldBits size). |
|
2412 |
depth ~~ 8 ifTrue:[ |
|
2413 |
"/ expand/compress can only handle 8bits |
|
2414 |
tmpBits := ByteArray uninitializedNew:(oldImage width*oldImage height). |
|
2415 |
oldBits |
|
2416 |
expandPixels:depth |
|
2417 |
width:oldImage width |
|
2418 |
height:oldImage height |
|
2419 |
into:tmpBits |
|
2420 |
mapping:oldToNew. |
|
2421 |
tmpBits |
|
2422 |
compressPixels:depth |
|
2423 |
width:oldImage width |
|
2424 |
height:oldImage height |
|
2425 |
into:newBits |
|
2426 |
mapping:nil |
|
2427 |
] ifFalse:[ |
|
2428 |
oldBits |
|
2429 |
expandPixels:depth |
|
2430 |
width:oldImage width |
|
2431 |
height:oldImage height |
|
2432 |
into:newBits |
|
2433 |
mapping:oldToNew. |
|
2434 |
]. |
|
2435 |
||
2436 |
newImage := oldImage species new |
|
2437 |
width:oldImage width |
|
2438 |
height:oldImage height |
|
2439 |
depth:depth |
|
2440 |
fromArray:newBits. |
|
2441 |
||
2442 |
newImage colorMap:newColorMap. |
|
2443 |
newImage fileName:oldImage fileName. |
|
2444 |
newImage mask:(oldImage mask copy). |
|
2445 |
||
1054 | 2446 |
(imageEditView image:newImage) notNil ifTrue:[ |
1008 | 2447 |
self listOfColors contents: newImage colorMap. |
2448 |
self findColorMapMode. |
|
2449 |
self updateLabelsAndHistory. |
|
2450 |
] |
|
2451 |
] |
|
2452 |
||
2453 |
"Modified: / 15.9.1998 / 17:53:32 / cg" |
|
2454 |
"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
|
2455 |
! ! |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
2456 |
|
400 | 2457 |
!ImageEditor methodsFor:'user actions - editing'! |
2458 |
||
767 | 2459 |
doBrowseClass |
2460 |
"opens a System Browser on the resourceClass and the resourceSelector" |
|
400 | 2461 |
|
933
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2462 |
|cls| |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2463 |
|
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2464 |
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
|
2465 |
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
|
2466 |
SystemBrowser |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2467 |
openInClass:cls class |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2468 |
selector:(imageEditView resourceSelector) |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2469 |
|
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
2470 |
"Modified: / 31.7.1998 / 02:01:15 / cg" |
400 | 2471 |
! |
2472 |
||
905 | 2473 |
doChangeGridMagnification |
2474 |
"change grid magnification" |
|
2475 |
||
911 | 2476 |
imageEditView changeGridMagnification |
905 | 2477 |
! |
2478 |
||
1045 | 2479 |
doCropAll |
986 | 2480 |
"find all borders and cut them off" |
2481 |
||
1045 | 2482 |
imageEditView cropLeft:true right:true top:true bottom:true. |
986 | 2483 |
self updateInfoLabel |
2484 |
||
2485 |
"Modified: / 7.9.1998 / 14:26:23 / cg" |
|
2486 |
"Created: / 7.9.1998 / 16:33:43 / cg" |
|
2487 |
! |
|
2488 |
||
1045 | 2489 |
doCropBottom |
986 | 2490 |
"find a bottom border and cut it off" |
2491 |
||
1045 | 2492 |
imageEditView cropLeft:false right:false top:false bottom:true. |
986 | 2493 |
self updateInfoLabel |
2494 |
||
2495 |
"Created: / 7.9.1998 / 13:00:20 / cg" |
|
2496 |
"Modified: / 7.9.1998 / 14:26:23 / cg" |
|
2497 |
! |
|
2498 |
||
1045 | 2499 |
doCropLeft |
986 | 2500 |
"find a left border and cut it off" |
2501 |
||
1045 | 2502 |
imageEditView cropLeft:true right:false top:false bottom:false. |
986 | 2503 |
self updateInfoLabel |
2504 |
||
2505 |
"Created: / 7.9.1998 / 13:00:14 / cg" |
|
2506 |
"Modified: / 7.9.1998 / 14:26:34 / cg" |
|
2507 |
! |
|
2508 |
||
1045 | 2509 |
doCropManual |
986 | 2510 |
"let user specify borders and cut them off" |
2511 |
||
2512 |
|bindings left top right bottom| |
|
2513 |
||
2514 |
bindings := IdentityDictionary new. |
|
2515 |
bindings at:#left put:(left := 0 asValue). |
|
2516 |
bindings at:#right put:(right := 0 asValue). |
|
2517 |
bindings at:#top put:(top := 0 asValue). |
|
2518 |
bindings at:#bottom put:(bottom := 0 asValue). |
|
1045 | 2519 |
(self openDialogInterface:#gropDialogSpec withBindings:bindings) |
986 | 2520 |
ifTrue:[ |
2521 |
left := left value. |
|
2522 |
right := right value. |
|
2523 |
top := top value. |
|
2524 |
bottom := bottom value. |
|
2525 |
imageEditView |
|
2526 |
makeSubImageX:left y:top |
|
2527 |
width:(imageEditView image width - left - right) |
|
2528 |
height:(imageEditView image height - top - bottom). |
|
2529 |
self updateInfoLabel |
|
2530 |
]. |
|
2531 |
||
2532 |
"Created: / 7.9.1998 / 18:16:07 / cg" |
|
2533 |
"Modified: / 7.9.1998 / 18:20:42 / cg" |
|
2534 |
! |
|
2535 |
||
1045 | 2536 |
doCropRight |
986 | 2537 |
"find a right border and cut it off" |
2538 |
||
1045 | 2539 |
imageEditView cropLeft:false right:true top:false bottom:false. |
986 | 2540 |
self updateInfoLabel |
2541 |
||
2542 |
"Created: / 7.9.1998 / 13:00:14 / cg" |
|
2543 |
"Modified: / 7.9.1998 / 14:26:44 / cg" |
|
2544 |
! |
|
2545 |
||
1045 | 2546 |
doCropTop |
986 | 2547 |
"find a top border and cut it off" |
2548 |
||
1045 | 2549 |
imageEditView cropLeft:false right:false top:true bottom:false. |
986 | 2550 |
self updateInfoLabel |
2551 |
||
2552 |
"Created: / 7.9.1998 / 13:00:19 / cg" |
|
2553 |
"Modified: / 7.9.1998 / 14:26:52 / cg" |
|
2554 |
! |
|
2555 |
||
767 | 2556 |
doFlipHorizontal |
2557 |
"flips horizontally current image" |
|
400 | 2558 |
|
911 | 2559 |
imageEditView flipHorizontal |
400 | 2560 |
! |
2561 |
||
767 | 2562 |
doFlipVertical |
2563 |
"flips vertically current image" |
|
400 | 2564 |
|
911 | 2565 |
imageEditView flipVertical |
400 | 2566 |
! |
2567 |
||
767 | 2568 |
doMagnifyDown |
2569 |
"magnifies current image one step down" |
|
400 | 2570 |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
2571 |
|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
|
2572 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
2573 |
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
|
2574 |
(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
|
2575 |
magHolder value: mag - 1 |
400 | 2576 |
] |
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
2577 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
2578 |
"Modified: / 26.7.1998 / 20:24:08 / cg" |
400 | 2579 |
! |
2580 |
||
767 | 2581 |
doMagnifyImage |
2582 |
"magnifies current image" |
|
400 | 2583 |
|
911 | 2584 |
imageEditView magnifyImage. |
400 | 2585 |
self updateInfoLabel |
2586 |
! |
|
2587 |
||
767 | 2588 |
doMagnifyUp |
2589 |
"magnifies current image one step up" |
|
400 | 2590 |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
2591 |
|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
|
2592 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
2593 |
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
|
2594 |
(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
|
2595 |
magHolder value: mag + 1 |
400 | 2596 |
] |
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
2597 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
2598 |
"Modified: / 26.7.1998 / 20:23:52 / cg" |
400 | 2599 |
! |
2600 |
||
767 | 2601 |
doNegativeImage |
2602 |
"negates current image by negating the color map" |
|
400 | 2603 |
|
911 | 2604 |
imageEditView negativeImage. |
400 | 2605 |
self listOfColors removeAll. |
901 | 2606 |
self findColorMapMode. |
911 | 2607 |
imageEditView undoImages removeLast |
400 | 2608 |
! |
2609 |
||
767 | 2610 |
doResizeImage |
2611 |
"resizes current image" |
|
400 | 2612 |
|
911 | 2613 |
imageEditView resizeImage. |
400 | 2614 |
self updateInfoLabel |
2615 |
! |
|
2616 |
||
767 | 2617 |
doRotateImage |
2618 |
"rotates current image" |
|
400 | 2619 |
|
911 | 2620 |
imageEditView rotateImage. |
400 | 2621 |
self updateInfoLabel |
2622 |
! |
|
2623 |
||
767 | 2624 |
doUndo |
2625 |
"reverses last edit action" |
|
400 | 2626 |
|
911 | 2627 |
imageEditView undo |
400 | 2628 |
! ! |
2629 |
||
2630 |
!ImageEditor methodsFor:'user actions - loading'! |
|
2631 |
||
767 | 2632 |
doLoadFromClass |
2633 |
"opens a dialog for loading an image from class and a (resource-) selector" |
|
400 | 2634 |
|
1122 | 2635 |
|img| |
2636 |
||
1054 | 2637 |
(imageEditView loadFromClass) notNil ifTrue:[ |
1122 | 2638 |
(img := self image) notNil ifTrue: [ |
2639 |
self listOfColors contents: img usedColors asSet asOrderedCollection. |
|
574 | 2640 |
self findColorMapMode. |
767 | 2641 |
self updateLabelsAndHistory |
1054 | 2642 |
] ifFalse: [ |
2643 |
self updateForNoImage |
|
461 | 2644 |
] |
449 | 2645 |
] |
400 | 2646 |
! |
2647 |
||
767 | 2648 |
doLoadFromFile |
2649 |
"opens a dialog for loading an image from a file" |
|
400 | 2650 |
|
1122 | 2651 |
|img| |
2652 |
||
767 | 2653 |
self loadFromFile: |
2654 |
(FileSelectionBrowser |
|
2655 |
request: 'Load Image From' |
|
1122 | 2656 |
fileName: ((img := self image) notNil ifTrue: [img fileName] ifFalse: [nil]) |
767 | 2657 |
withFileFilters: FileSelectionBrowser loadImageFileNameFilters) |
400 | 2658 |
! |
2659 |
||
767 | 2660 |
doNewImage |
2661 |
"opens a dialog with choices of size and color map for creating a new image" |
|
400 | 2662 |
|
2663 |
|aspects| |
|
767 | 2664 |
|
400 | 2665 |
aspects := IdentityDictionary new |
767 | 2666 |
at:#listOfSizes put: self class listOfDefaultSizes asValue; |
2667 |
at:#listOfColorMaps put: self class listOfColorMaps keys asSortedCollection asValue; |
|
2668 |
at:#selectionOfSize put: self class listOfDefaultSizes first copy asValue; |
|
400 | 2669 |
at:#selectionOfColorMap put: self class listOfColorMaps keys asSortedCollection first asValue; |
2670 |
yourself. |
|
2671 |
||
767 | 2672 |
(self openDialogInterface:#dialogSpecForNewImage withBindings:aspects) |
400 | 2673 |
ifTrue: |
2674 |
[ |
|
2675 |
|width height cMap imageClass image| |
|
767 | 2676 |
|
2677 |
width := 128 min: (Integer readFromString: ((aspects at:#selectionOfSize) value upTo: $x) onError:[24]). |
|
400 | 2678 |
height := 128 min: (Integer readFromString: ((aspects at:#selectionOfSize) value copy reverse upTo: $x) reverse onError:[24]). |
2679 |
||
975 | 2680 |
cMap := (self class listOfColorMaps at: (colorMapMode value: (aspects at:#selectionOfColorMap) value) value). |
400 | 2681 |
imageClass := Image implementorForDepth: ((cMap size log: 2) asInteger). |
767 | 2682 |
image := imageClass width: width height: height fromArray: (ByteArray new: width*height). |
400 | 2683 |
|
975 | 2684 |
(colorMapMode value endsWith: 'mask') |
400 | 2685 |
ifTrue: |
2686 |
[ |
|
767 | 2687 |
image mask: (Depth1Image width: width height: height depth: 1 fromArray: (ByteArray new: width*height)) clearMaskedPixels |
400 | 2688 |
]. |
2689 |
image colorMap: cMap. |
|
2690 |
image fillRectangleX:0 y:0 width:width height:height with:Color white. |
|
911 | 2691 |
(imageEditView image: image) notNil |
400 | 2692 |
ifTrue: |
2693 |
[ |
|
2694 |
self listOfColors contents: cMap. |
|
2695 |
self findColorMapMode. |
|
694 | 2696 |
self updateLabelsAndHistory |
400 | 2697 |
] |
767 | 2698 |
] |
929 | 2699 |
! |
2700 |
||
2701 |
grabScreenImage |
|
2702 |
"let user choose an area and grab that are for editing" |
|
2703 |
||
990
4303f0064410
delay a second before grabbing screen image (to allow for redraws to happen)
Claus Gittinger <cg@exept.de>
parents:
986
diff
changeset
|
2704 |
Processor |
4303f0064410
delay a second before grabbing screen image (to allow for redraws to happen)
Claus Gittinger <cg@exept.de>
parents:
986
diff
changeset
|
2705 |
addTimedBlock:[ |
4303f0064410
delay a second before grabbing screen image (to allow for redraws to happen)
Claus Gittinger <cg@exept.de>
parents:
986
diff
changeset
|
2706 |
|image d8image img| |
929 | 2707 |
|
990
4303f0064410
delay a second before grabbing screen image (to allow for redraws to happen)
Claus Gittinger <cg@exept.de>
parents:
986
diff
changeset
|
2708 |
image := Image fromUser. |
1121 | 2709 |
image isNil ifFalse:[ |
2710 |
image depth > 8 ifTrue:[ |
|
1122 | 2711 |
Object errorSignal handle:[:ex | |sig| |
2712 |
(sig := ex signal) == Object haltSignal ifTrue:[ex reject]. |
|
2713 |
sig == Signal noHandlerSignal ifTrue:[ex reject]. |
|
1121 | 2714 |
|
2715 |
self warn:'Could not convert to depth8 image (too many colors)'. |
|
2716 |
d8image := nil. |
|
2717 |
] do:[ |
|
2718 |
d8image := Depth8Image new. |
|
2719 |
d8image fromImage:image. |
|
2720 |
]. |
|
2721 |
d8image notNil ifTrue:[ |
|
2722 |
image := d8image |
|
2723 |
] |
|
990
4303f0064410
delay a second before grabbing screen image (to allow for redraws to happen)
Claus Gittinger <cg@exept.de>
parents:
986
diff
changeset
|
2724 |
]. |
1121 | 2725 |
(imageEditView image:image) notNil ifTrue:[ |
2726 |
self listOfColors contents:(image colorMap). |
|
2727 |
self findColorMapMode. |
|
2728 |
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
|
2729 |
] |
1121 | 2730 |
] |
2731 |
] |
|
990
4303f0064410
delay a second before grabbing screen image (to allow for redraws to happen)
Claus Gittinger <cg@exept.de>
parents:
986
diff
changeset
|
2732 |
afterSeconds:1 |
929 | 2733 |
|
2734 |
"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
|
2735 |
"Modified: / 10.9.1998 / 16:01:23 / cg" |
400 | 2736 |
! ! |
2737 |
||
2738 |
!ImageEditor methodsFor:'user actions - saving'! |
|
2739 |
||
767 | 2740 |
doPrint |
2741 |
"prints current image on the current printer" |
|
400 | 2742 |
|
911 | 2743 |
imageEditView print |
400 | 2744 |
! |
2745 |
||
767 | 2746 |
doSaveImageFile |
2747 |
"saves current image to current file" |
|
400 | 2748 |
|
911 | 2749 |
imageEditView save |
400 | 2750 |
! |
2751 |
||
767 | 2752 |
doSaveImageFileAs |
2753 |
"opens a dialog for saving current image to a file" |
|
400 | 2754 |
|
911 | 2755 |
imageEditView saveImageFileAs. |
694 | 2756 |
self updateLabelsAndHistory |
400 | 2757 |
! |
2758 |
||
767 | 2759 |
doSaveImageMaskFileAs |
2760 |
"opens a dialog for saving mask of current image to a file" |
|
400 | 2761 |
|
911 | 2762 |
imageEditView saveImageMaskFileAs |
400 | 2763 |
! |
2764 |
||
767 | 2765 |
doSaveMethod |
2766 |
"saves current image on current class and selector" |
|
400 | 2767 |
|
911 | 2768 |
imageEditView saveMethod notNil |
400 | 2769 |
ifTrue: |
2770 |
[ |
|
694 | 2771 |
self updateLabelsAndHistory |
400 | 2772 |
] |
2773 |
! |
|
2774 |
||
767 | 2775 |
doSaveMethodAs |
2776 |
"opens a dialog for saving current image on a class and a selector" |
|
400 | 2777 |
|
911 | 2778 |
imageEditView saveMethodAs notNil |
400 | 2779 |
ifTrue: |
2780 |
[ |
|
694 | 2781 |
self updateLabelsAndHistory |
400 | 2782 |
] |
2783 |
! ! |
|
2784 |
||
2785 |
!ImageEditor class methodsFor:'documentation'! |
|
2786 |
||
2787 |
version |
|
2788 |
^ '$Header$' |
|
2789 |
! ! |