author | Claus Gittinger <cg@exept.de> |
Thu, 30 Jul 1998 11:20:11 +0200 | |
changeset 929 | 7be532d91b87 |
parent 928 | 89bd2304da33 |
child 930 | 4cf126b710b3 |
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 |
|
929 | 14 |
instanceVariableNames:'imageEditView colorMapMode selectedColorIndex postOpenAction' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Interface-UIPainter' |
|
400 | 18 |
! |
19 |
||
20 |
!ImageEditor class methodsFor:'documentation'! |
|
21 |
||
22 |
copyright |
|
23 |
" |
|
767 | 24 |
COPYRIGHT (c) 1997-1998 by eXept Software AG |
400 | 25 |
All Rights Reserved |
26 |
||
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
405 | 29 |
inclusion of the above copyright notice. This software may not |
400 | 30 |
be provided or otherwise made available to, or used by, any |
405 | 31 |
other person. No title to or ownership of the software is |
400 | 32 |
hereby transferred. |
33 |
" |
|
34 |
! |
|
35 |
||
36 |
documentation |
|
37 |
" |
|
737 | 38 |
Image Editor allows you to create, design, modify or just inspect images. |
400 | 39 |
|
40 |
[start with:] |
|
41 |
ImageEditor open |
|
42 |
ImageEditor openOnClass:ImageEditor andSelector:#newImageIcon |
|
43 |
||
44 |
[see also:] |
|
45 |
ImageEditView Image |
|
46 |
||
47 |
[author:] |
|
544 | 48 |
Thomas Zwick, eXept Software AG |
400 | 49 |
" |
50 |
! ! |
|
51 |
||
52 |
!ImageEditor class methodsFor:'instance creation'! |
|
53 |
||
54 |
openModalOnClass: aClass andSelector: aSelector |
|
900 | 55 |
"opens modal a Image Editor on aClass and aSelector" |
767 | 56 |
" |
57 |
self openModalOnClass: self andSelector: #leftMouseKeyIcon |
|
58 |
" |
|
400 | 59 |
|
767 | 60 |
|imageEditor imageEditView className resourceClassName resourceSelector| |
61 |
||
400 | 62 |
imageEditor := self new. |
767 | 63 |
|
900 | 64 |
aClass isClass ifTrue: [className := aClass name]. |
65 |
aClass isString ifTrue: [className := aClass]. |
|
903 | 66 |
aClass isNil ifTrue: [className := '']. |
400 | 67 |
|
688 | 68 |
imageEditor postOpenAction: [imageEditView := imageEditor imageEditView. imageEditor loadFromOrPrepareForMessage: className, ' ', aSelector]. |
400 | 69 |
imageEditor openModal. |
70 |
||
688 | 71 |
resourceClassName := imageEditView resourceClass. |
767 | 72 |
resourceSelector := imageEditView resourceSelector. |
415 | 73 |
|
815 | 74 |
((className asString ~= resourceClassName) |
75 |
or:[aSelector asString ~= resourceSelector]) |
|
415 | 76 |
ifTrue: [^resourceClassName, ' ', resourceSelector] |
77 |
ifFalse:[^nil] |
|
400 | 78 |
! |
79 |
||
80 |
openOnClass: aClass andSelector: aSelector |
|
900 | 81 |
"opens a Image Editor on aClass and aSelector" |
767 | 82 |
" |
83 |
self openOnClass: self andSelector: #leftMouseKeyIcon |
|
84 |
" |
|
400 | 85 |
|
86 |
^self open loadFromMessage: aClass name, ' ', aSelector |
|
87 |
! |
|
88 |
||
767 | 89 |
openOnFile: aFileName |
900 | 90 |
"opens a Image Editor on aFileName" |
767 | 91 |
" |
92 |
self openOnFile: 'bitmaps/SmalltalkX.xbm' |
|
93 |
" |
|
400 | 94 |
|
767 | 95 |
^self open loadFromFile: aFileName |
400 | 96 |
! |
97 |
||
767 | 98 |
openOnImage: anImage |
900 | 99 |
"opens a Image Editor on anImage" |
767 | 100 |
" |
895 | 101 |
self openOnImage: Icon startIcon |
767 | 102 |
" |
400 | 103 |
|
767 | 104 |
^self open loadFromImage: anImage |
400 | 105 |
! ! |
106 |
||
107 |
!ImageEditor class methodsFor:'accessing'! |
|
108 |
||
109 |
listOfColorMaps |
|
767 | 110 |
"returns the list of default color maps for a new image" |
400 | 111 |
|
112 |
|colorMap| |
|
898 | 113 |
|
400 | 114 |
(colorMap := OrderedCollection new) |
115 |
add: Color black; |
|
116 |
add: Color white; |
|
117 |
add: Color red; |
|
118 |
add: Color green; |
|
119 |
add: Color blue; |
|
120 |
add: Color cyan; |
|
121 |
add: Color yellow; |
|
122 |
add: Color magenta; |
|
898 | 123 |
add: (Color redByte: 127 greenByte: 0 blueByte: 0); |
124 |
add: (Color redByte: 0 greenByte: 127 blueByte: 0); |
|
125 |
add: (Color redByte: 0 greenByte: 0 blueByte: 127); |
|
126 |
add: (Color redByte: 0 greenByte: 127 blueByte: 127); |
|
127 |
add: (Color redByte: 127 greenByte: 127 blueByte: 0); |
|
128 |
add: (Color redByte: 127 greenByte: 0 blueByte: 127); |
|
129 |
add: (Color redByte: 127 greenByte: 127 blueByte: 127); |
|
130 |
add: (Color redByte: 170 greenByte: 170 blueByte: 170). |
|
131 |
||
400 | 132 |
0 to: 5 do: |
133 |
[:r| |
|
134 |
0 to: 5 do: |
|
135 |
[:g| |
|
136 |
0 to: 5 do: |
|
137 |
[:b| |
|
898 | 138 |
colorMap add: (Color redByte: (r*255//5) ceiling greenByte: (g*255//5) ceiling blueByte: (b*255//5) ceiling) |
400 | 139 |
] |
140 |
] |
|
141 |
]. |
|
142 |
||
143 |
1 to: 25 do: |
|
144 |
[:g| |
|
898 | 145 |
colorMap add: (Color redByte: (g*255//26) ceiling greenByte: (g*255//26) ceiling blueByte: (g*255//26) ceiling) |
400 | 146 |
]. |
147 |
||
148 |
^Dictionary new |
|
149 |
at: '8-plane' put: colorMap; |
|
150 |
at: '8-plane + mask' put: colorMap; |
|
151 |
at: '4-plane' put: (colorMap copyFrom: 1 to: 16); |
|
152 |
at: '4-plane + mask' put: (colorMap copyFrom: 1 to: 16); |
|
153 |
at: '2-plane' put: (colorMap copyFrom: 1 to: 4); |
|
154 |
at: '2-plane + mask' put: (colorMap copyFrom: 1 to: 4); |
|
155 |
at: '1-plane' put: (colorMap copyFrom: 1 to: 2); |
|
156 |
at: '1-plane + mask' put: (colorMap copyFrom: 1 to: 2); |
|
157 |
yourself |
|
158 |
! |
|
159 |
||
160 |
listOfDefaultSizes |
|
767 | 161 |
"returns the list of default sizes for a new image" |
400 | 162 |
|
767 | 163 |
^#('22x22' '16x16' '32x32') |
400 | 164 |
! ! |
165 |
||
460 | 166 |
!ImageEditor class methodsFor:'help specs'! |
167 |
||
168 |
helpSpec |
|
737 | 169 |
"This resource specification was automatically generated |
170 |
by the UIHelpTool of ST/X." |
|
171 |
||
172 |
"Do not manually edit this!! If it is corrupted, |
|
173 |
the UIHelpTool may not be able to read the specification." |
|
460 | 174 |
|
175 |
" |
|
737 | 176 |
UIHelpTool openOnClass:ImageEditor |
460 | 177 |
" |
178 |
||
737 | 179 |
<resource: #help> |
180 |
||
181 |
^super helpSpec addPairsFrom:#( |
|
460 | 182 |
|
183 |
#colorMap |
|
929 | 184 |
'ColorMap functions.' |
185 |
||
186 |
#colorMap1 |
|
187 |
'Convert to depth-1 image.' |
|
188 |
||
189 |
#colorMap2 |
|
190 |
'Convert to depth-2 image.' |
|
191 |
||
192 |
#colorMap4 |
|
193 |
'Convert to depth-4 image.' |
|
194 |
||
195 |
#colorMap8 |
|
196 |
'Convert to depth-8 image.' |
|
197 |
||
198 |
#colorMap1M |
|
199 |
'Convert to depth-1 image plus mask.' |
|
200 |
||
201 |
#colorMap2M |
|
202 |
'Convert to depth-2 image plus mask.' |
|
203 |
||
204 |
#colorMap4M |
|
205 |
'Convert to depth-4 image plus mask.' |
|
206 |
||
207 |
#colorMap8M |
|
208 |
'Convert to depth-8 image plus mask.' |
|
209 |
||
210 |
#compressColormap |
|
211 |
'Remove unneeded entries from the colorMap.' |
|
460 | 212 |
|
487 | 213 |
#colorMapTable |
675 | 214 |
'Shows a list of used colors of the image.' |
487 | 215 |
|
460 | 216 |
#drawModeBox |
914 | 217 |
'Switches to box-drawing mode.' |
460 | 218 |
|
219 |
#drawModeCopy |
|
914 | 220 |
'Switches to area-copy mode.' |
460 | 221 |
|
222 |
#drawModeFill |
|
914 | 223 |
'Switches to flood-fill mode.' |
460 | 224 |
|
225 |
#drawModeFilledBox |
|
914 | 226 |
'Switches to filled-box drawing mode.' |
460 | 227 |
|
228 |
#drawModePaste |
|
914 | 229 |
'Switches to paste mode.' |
230 |
||
231 |
#drawModePasteUnder |
|
232 |
'Switches to paste under mode.' |
|
460 | 233 |
|
234 |
#drawModePoint |
|
914 | 235 |
'Switches to point-drawing mode.' |
460 | 236 |
|
237 |
#editFlipHorizontal |
|
914 | 238 |
'Flips the image horizontally.' |
460 | 239 |
|
240 |
#editFlipVertical |
|
914 | 241 |
'Flips the image vertically.' |
460 | 242 |
|
243 |
#editMagnifyImage |
|
914 | 244 |
'Magnify the image.' |
460 | 245 |
|
246 |
#editNegate |
|
914 | 247 |
'Invert the images colors.' |
460 | 248 |
|
249 |
#editResize |
|
914 | 250 |
'Resize the image (preserving the old image).' |
460 | 251 |
|
252 |
#editRotate |
|
914 | 253 |
'Rotate the image.' |
460 | 254 |
|
929 | 255 |
#fileGrabImage |
256 |
'Pick an image from the screen.' |
|
257 |
||
460 | 258 |
#fileLoadFromClass |
929 | 259 |
'Select and load an image from a resource method.' |
460 | 260 |
|
261 |
#fileLoadFromFile |
|
929 | 262 |
'Select and load an image from a file.' |
460 | 263 |
|
264 |
#fileNewImage |
|
914 | 265 |
'Create a new image' |
460 | 266 |
|
267 |
#filePrint |
|
268 |
'Print the image on a postscript printer.' |
|
269 |
||
270 |
#fileSaveAs |
|
914 | 271 |
'Save the image to a file.' |
460 | 272 |
|
273 |
#fileSaveMaskAs |
|
914 | 274 |
'Save the mask of the image to a file.' |
460 | 275 |
|
276 |
#fileSaveMethod |
|
914 | 277 |
'Save the image as resource method in the current class and selector.' |
460 | 278 |
|
279 |
#fileSaveMethodAs |
|
914 | 280 |
'Save the image as resource method in a class.' |
460 | 281 |
|
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
282 |
#historyMenuItem |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
283 |
'Edit this image.' |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
284 |
|
487 | 285 |
#magnificationNumber |
914 | 286 |
'Shows the current magnification.' |
487 | 287 |
|
288 |
#magnifyImageDown |
|
914 | 289 |
'Decrease magnification.' |
487 | 290 |
|
291 |
#magnifyImageUp |
|
914 | 292 |
'Increase magnification.' |
487 | 293 |
|
294 |
#mouseKeyColorMode |
|
914 | 295 |
'Toggles between left and right mouse button color.' |
487 | 296 |
|
297 |
#previewView |
|
914 | 298 |
'Shows a preview of the image.' |
487 | 299 |
|
905 | 300 |
#settingsGridMagnification |
914 | 301 |
'Change the grid magnification of the edit view.' |
905 | 302 |
|
460 | 303 |
) |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
304 |
|
929 | 305 |
"Modified: / 29.7.1998 / 22:27:36 / cg" |
460 | 306 |
! ! |
307 |
||
737 | 308 |
!ImageEditor class methodsFor:'image specs'! |
309 |
||
310 |
leftMouseKeyIcon |
|
311 |
"This resource specification was automatically generated |
|
312 |
by the ImageEditor of ST/X." |
|
313 |
||
314 |
"Do not manually edit this!! If it is corrupted, |
|
315 |
the ImageEditor may not be able to read the specification." |
|
316 |
||
317 |
" |
|
318 |
ImageEditor openOnClass:self andSelector:#leftMouseKeyIcon |
|
319 |
" |
|
320 |
||
321 |
<resource: #image> |
|
322 |
||
323 |
^Icon |
|
324 |
constantNamed:#'ImageEditor leftMouseKeyIcon' |
|
325 |
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]! |
|
326 |
||
327 |
rightMouseKeyIcon |
|
328 |
"This resource specification was automatically generated |
|
329 |
by the ImageEditor of ST/X." |
|
330 |
||
331 |
"Do not manually edit this!! If it is corrupted, |
|
332 |
the ImageEditor may not be able to read the specification." |
|
333 |
||
334 |
" |
|
335 |
ImageEditor openOnClass:self andSelector:#rightMouseKeyIcon |
|
336 |
" |
|
337 |
||
338 |
<resource: #image> |
|
339 |
||
340 |
^Icon |
|
341 |
constantNamed:#'ImageEditor rightMouseKeyIcon' |
|
342 |
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]! ! |
|
343 |
||
400 | 344 |
!ImageEditor class methodsFor:'interface specs'! |
345 |
||
767 | 346 |
dialogSpecForNewImage |
737 | 347 |
"This resource specification was automatically generated |
348 |
by the UIPainter of ST/X." |
|
519 | 349 |
|
737 | 350 |
"Do not manually edit this!! If it is corrupted, |
351 |
the UIPainter may not be able to read the specification." |
|
519 | 352 |
|
353 |
" |
|
767 | 354 |
UIPainter new openOnClass:ImageEditor andSelector:#dialogSpecForNewImage |
355 |
ImageEditor new openInterface:#dialogSpecForNewImage |
|
519 | 356 |
" |
357 |
||
358 |
<resource: #canvas> |
|
359 |
||
360 |
^ |
|
361 |
||
362 |
#(#FullSpec |
|
672 | 363 |
#window: |
519 | 364 |
#(#WindowSpec |
672 | 365 |
#name: 'New Image' |
737 | 366 |
#layout: #(#LayoutFrame 240 0 278 0 540 0 382 0) |
672 | 367 |
#label: 'New Image' |
368 |
#min: #(#Point 10 10) |
|
369 |
#max: #(#Point 1152 900) |
|
737 | 370 |
#bounds: #(#Rectangle 240 278 541 383) |
672 | 371 |
#usePreferredExtent: false |
519 | 372 |
) |
672 | 373 |
#component: |
519 | 374 |
#(#SpecCollection |
672 | 375 |
#collection: |
519 | 376 |
#( |
377 |
#(#ViewSpec |
|
672 | 378 |
#name: 'View' |
737 | 379 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -35 1.0) |
672 | 380 |
#component: |
519 | 381 |
#(#SpecCollection |
672 | 382 |
#collection: |
519 | 383 |
#( |
384 |
#(#FramedBoxSpec |
|
672 | 385 |
#name: 'framedBox1' |
737 | 386 |
#layout: #(#LayoutFrame 1 0.0 7 0.0 0 0.4 66 0) |
672 | 387 |
#component: |
519 | 388 |
#(#SpecCollection |
672 | 389 |
#collection: |
519 | 390 |
#( |
391 |
#(#ComboBoxSpec |
|
672 | 392 |
#name: 'defaultSizesComboBox' |
393 |
#layout: #(#LayoutFrame 15 0.0 20 0.0 17 1.0 16 1.0) |
|
394 |
#model: #selectionOfSize |
|
395 |
#type: #string |
|
396 |
#comboList: #listOfDefaultSizes |
|
519 | 397 |
) |
398 |
) |
|
399 |
) |
|
672 | 400 |
#label: 'Size' |
401 |
#labelPosition: #topLeft |
|
402 |
#style: #(#FontDescription #helvetica #medium #roman 12) |
|
519 | 403 |
) |
404 |
#(#FramedBoxSpec |
|
672 | 405 |
#name: 'framedBox2' |
737 | 406 |
#layout: #(#LayoutFrame 0 0.4 7 0.0 -1 1.0 66 0) |
672 | 407 |
#component: |
519 | 408 |
#(#SpecCollection |
672 | 409 |
#collection: |
519 | 410 |
#( |
411 |
#(#ComboListSpec |
|
672 | 412 |
#name: 'colorMapComboBox' |
413 |
#layout: #(#LayoutFrame 15 0.0 20 0.0 18 1.0 16 1.0) |
|
414 |
#model: #selectionOfColorMap |
|
415 |
#comboList: #listOfColorMaps |
|
416 |
#useIndex: false |
|
519 | 417 |
) |
418 |
) |
|
419 |
) |
|
672 | 420 |
#label: 'Color Map' |
421 |
#labelPosition: #topLeft |
|
422 |
#style: #(#FontDescription #helvetica #medium #roman 12) |
|
519 | 423 |
) |
424 |
) |
|
425 |
) |
|
672 | 426 |
#level: 1 |
519 | 427 |
) |
672 | 428 |
#(#UISubSpecification |
429 |
#name: 'UISubSpecification1' |
|
737 | 430 |
#layout: #(#LayoutFrame 2 0.0 -26 1 -2 1.0 -2 1.0) |
672 | 431 |
#majorKey: #ToolApplicationModel |
432 |
#minorKey: #windowSpecForCommitWithoutChannels |
|
519 | 433 |
) |
434 |
) |
|
435 |
) |
|
436 |
) |
|
767 | 437 |
! |
438 |
||
439 |
windowSpec |
|
440 |
"This resource specification was automatically generated |
|
441 |
by the UIPainter of ST/X." |
|
442 |
||
443 |
"Do not manually edit this!! If it is corrupted, |
|
444 |
the UIPainter may not be able to read the specification." |
|
445 |
||
446 |
" |
|
447 |
UIPainter new openOnClass:ImageEditor andSelector:#windowSpec |
|
448 |
ImageEditor new openInterface:#windowSpec |
|
449 |
ImageEditor open |
|
450 |
" |
|
451 |
||
452 |
<resource: #canvas> |
|
453 |
||
454 |
^ |
|
455 |
||
456 |
#(#FullSpec |
|
457 |
#window: |
|
458 |
#(#WindowSpec |
|
459 |
#name: 'Image Editor' |
|
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
460 |
#layout: #(#LayoutFrame 216 0 173 0 715 0 518 0) |
767 | 461 |
#label: 'Image Editor' |
462 |
#min: #(#Point 400 320) |
|
463 |
#max: #(#Point 1152 900) |
|
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
464 |
#bounds: #(#Rectangle 216 173 716 519) |
767 | 465 |
#menu: #menu |
466 |
#usePreferredExtent: false |
|
467 |
) |
|
468 |
#component: |
|
469 |
#(#SpecCollection |
|
470 |
#collection: |
|
471 |
#( |
|
472 |
#(#MenuPanelSpec |
|
473 |
#name: 'menuToolbarView' |
|
474 |
#layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 32 0) |
|
475 |
#menu: #menuToolbar |
|
476 |
#style: #(#FontDescription #helvetica #medium #roman 10) |
|
477 |
#showSeparatingLines: true |
|
478 |
) |
|
479 |
#(#VariableHorizontalPanelSpec |
|
480 |
#name: 'variableHorizontalPanel1' |
|
481 |
#layout: #(#LayoutFrame 0 0.0 34 0.0 0 1.0 -26 1.0) |
|
482 |
#component: |
|
483 |
#(#SpecCollection |
|
484 |
#collection: |
|
485 |
#( |
|
486 |
#(#ViewSpec |
|
487 |
#name: 'view1' |
|
488 |
#component: |
|
489 |
#(#SpecCollection |
|
490 |
#collection: |
|
491 |
#( |
|
492 |
#(#VariableVerticalPanelSpec |
|
493 |
#name: 'VariableVerticalPanel1' |
|
494 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
495 |
#component: |
|
496 |
#(#SpecCollection |
|
497 |
#collection: |
|
498 |
#( |
|
499 |
#(#ViewSpec |
|
500 |
#name: 'View1' |
|
501 |
#component: |
|
502 |
#(#SpecCollection |
|
503 |
#collection: |
|
504 |
#( |
|
505 |
#(#MenuPanelSpec |
|
506 |
#name: 'MouseButtonColorToolBar' |
|
507 |
#layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 24 0) |
|
508 |
#menu: #menuMouseButtonColors |
|
509 |
) |
|
510 |
#(#DataSetSpec |
|
511 |
#name: 'colorDataSetView' |
|
512 |
#layout: #(#LayoutFrame 0 0.0 26 0.0 0 1.0 0 1.0) |
|
513 |
#activeHelpKey: #colorMapTable |
|
514 |
#model: #selectionOfColor |
|
515 |
#style: #(#FontDescription #helvetica #medium #roman 10) |
|
516 |
#hasHorizontalScrollBar: true |
|
517 |
#hasVerticalScrollBar: true |
|
518 |
#miniScrollerHorizontal: true |
|
519 |
#miniScrollerVertical: true |
|
520 |
#dataList: #listOfColors |
|
521 |
#has3Dsepartors: true |
|
905 | 522 |
#has3Dseparators: true |
767 | 523 |
#verticalSpacing: 1 |
524 |
#columns: |
|
525 |
#( |
|
526 |
#(#DataSetColumnSpec |
|
527 |
#rendererType: #rowSelector |
|
528 |
#backgroundSelector: #yourself |
|
529 |
) |
|
530 |
#(#DataSetColumnSpec |
|
531 |
#label: 'R' |
|
532 |
#labelAlignment: #left |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
533 |
#model: #redFromColor: |
767 | 534 |
#canSelect: false |
535 |
) |
|
536 |
#(#DataSetColumnSpec |
|
537 |
#label: 'G' |
|
538 |
#labelAlignment: #left |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
539 |
#model: #greenFromColor: |
767 | 540 |
#canSelect: false |
541 |
) |
|
542 |
#(#DataSetColumnSpec |
|
543 |
#label: 'B' |
|
544 |
#labelAlignment: #left |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
545 |
#model: #blueFromColor: |
767 | 546 |
#canSelect: false |
547 |
) |
|
548 |
) |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
549 |
#columnAdaptor: #colorColumnAdaptor |
767 | 550 |
) |
551 |
) |
|
552 |
) |
|
553 |
) |
|
554 |
#(#ArbitraryComponentSpec |
|
555 |
#name: 'imagePreView' |
|
556 |
#activeHelpKey: #previewView |
|
557 |
#hasHorizontalScrollBar: true |
|
558 |
#hasVerticalScrollBar: true |
|
559 |
#miniScrollerHorizontal: true |
|
560 |
#miniScrollerVertical: true |
|
561 |
#component: #ImageView |
|
562 |
#hasBorder: false |
|
563 |
) |
|
564 |
) |
|
565 |
) |
|
566 |
#handles: #(#Any 0.723776 1.0) |
|
567 |
) |
|
568 |
) |
|
569 |
) |
|
570 |
) |
|
571 |
#(#ViewSpec |
|
572 |
#name: 'view2' |
|
573 |
#component: |
|
574 |
#(#SpecCollection |
|
575 |
#collection: |
|
576 |
#( |
|
577 |
#(#ArbitraryComponentSpec |
|
578 |
#name: 'imageEditView' |
|
579 |
#layout: #(#LayoutFrame 2 0.0 2 0.0 -2 1.0 -24 1.0) |
|
580 |
#hasHorizontalScrollBar: true |
|
581 |
#hasVerticalScrollBar: true |
|
582 |
#component: #ImageEditView |
|
583 |
#hasBorder: false |
|
584 |
) |
|
585 |
#(#LabelSpec |
|
586 |
#name: 'coordLabel' |
|
587 |
#layout: #(#LayoutFrame 2 0.0 -22 1 -83 1.0 0 1.0) |
|
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
588 |
#labelChannel: #imageInfoHolder |
767 | 589 |
#level: -1 |
590 |
#adjust: #left |
|
591 |
#resizeForLabel: false |
|
592 |
) |
|
593 |
#(#ArrowButtonSpec |
|
594 |
#name: 'magnifyDownButton' |
|
595 |
#layout: #(#LayoutFrame -80 1 -22 1 -58 1 0 1) |
|
596 |
#activeHelpKey: #magnifyImageDown |
|
597 |
#model: #doMagnifyDown |
|
598 |
#enableChannel: #imageIsLoaded |
|
599 |
#isTriggerOnDown: true |
|
600 |
#direction: #left |
|
601 |
) |
|
602 |
#(#ArrowButtonSpec |
|
603 |
#name: 'magnifyUpButton' |
|
604 |
#layout: #(#LayoutFrame -24 1 -22 1 -2 1 0 1) |
|
605 |
#activeHelpKey: #magnifyImageUp |
|
606 |
#model: #doMagnifyUp |
|
607 |
#enableChannel: #imageIsLoaded |
|
608 |
#isTriggerOnDown: true |
|
609 |
#direction: #right |
|
610 |
) |
|
611 |
#(#InputFieldSpec |
|
612 |
#name: 'magnificationInputField' |
|
613 |
#layout: #(#LayoutFrame -57 1 -22 1 -26 1 0 1) |
|
614 |
#activeHelpKey: #magnificationNumber |
|
615 |
#enableChannel: #imageIsLoaded |
|
616 |
#model: #valueOfMagnification |
|
905 | 617 |
#type: #numberInRange |
767 | 618 |
#acceptOnReturn: false |
619 |
#acceptOnTab: false |
|
620 |
#numChars: 2 |
|
905 | 621 |
#minValue: 1 |
622 |
#maxValue: 99 |
|
767 | 623 |
) |
624 |
) |
|
625 |
) |
|
626 |
#level: -1 |
|
627 |
) |
|
628 |
) |
|
629 |
) |
|
630 |
#handles: #(#Any 0.276 1.0) |
|
631 |
) |
|
632 |
#(#UISubSpecification |
|
633 |
#name: 'infoBarSubSpec' |
|
634 |
#layout: #(#LayoutFrame 0 0.0 -24 1 0 1.0 0 1.0) |
|
635 |
#majorKey: #ToolApplicationModel |
|
636 |
#minorKey: #windowSpecForInfoBar |
|
637 |
) |
|
638 |
) |
|
639 |
) |
|
640 |
) |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
641 |
|
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
642 |
"Modified: / 29.7.1998 / 18:31:38 / cg" |
519 | 643 |
! ! |
644 |
||
645 |
!ImageEditor class methodsFor:'menu specs'! |
|
646 |
||
400 | 647 |
menu |
737 | 648 |
"This resource specification was automatically generated |
649 |
by the MenuEditor of ST/X." |
|
400 | 650 |
|
737 | 651 |
"Do not manually edit this!! If it is corrupted, |
652 |
the MenuEditor may not be able to read the specification." |
|
400 | 653 |
|
654 |
" |
|
655 |
MenuEditor new openOnClass:ImageEditor andSelector:#menu |
|
656 |
(Menu new fromLiteralArrayEncoding:(ImageEditor menu)) startUp |
|
657 |
" |
|
658 |
||
659 |
<resource: #menu> |
|
660 |
||
661 |
^ |
|
662 |
||
663 |
#(#Menu |
|
664 |
||
665 |
#( |
|
666 |
#(#MenuItem |
|
672 | 667 |
#label: 'About' |
843 | 668 |
#translateLabel: true |
672 | 669 |
#activeHelpKey: #about |
670 |
#labelImage: #(#ResourceRetriever nil #menuIcon) |
|
671 |
#submenuChannel: #menuAbout |
|
400 | 672 |
) |
673 |
#(#MenuItem |
|
672 | 674 |
#label: 'File' |
675 |
#translateLabel: true |
|
676 |
#activeHelpKey: #file |
|
677 |
#submenu: |
|
400 | 678 |
#(#Menu |
679 |
||
680 |
#( |
|
681 |
#(#MenuItem |
|
672 | 682 |
#label: 'New...' |
843 | 683 |
#translateLabel: true |
767 | 684 |
#value: #doNewImage |
672 | 685 |
#activeHelpKey: #fileNewImage |
400 | 686 |
) |
687 |
#(#MenuItem |
|
672 | 688 |
#label: '-' |
400 | 689 |
) |
690 |
#(#MenuItem |
|
672 | 691 |
#label: 'Load...' |
843 | 692 |
#translateLabel: true |
767 | 693 |
#value: #doLoadFromClass |
672 | 694 |
#activeHelpKey: #fileLoadFromClass |
400 | 695 |
) |
696 |
#(#MenuItem |
|
672 | 697 |
#label: 'Load From File...' |
843 | 698 |
#translateLabel: true |
767 | 699 |
#value: #doLoadFromFile |
672 | 700 |
#activeHelpKey: #fileLoadFromFile |
400 | 701 |
) |
702 |
#(#MenuItem |
|
929 | 703 |
#label: 'Grab From Screen' |
704 |
#translateLabel: true |
|
705 |
#value: #grabScreenImage |
|
706 |
#activeHelpKey: #fileGrabImage |
|
707 |
) |
|
708 |
#(#MenuItem |
|
672 | 709 |
#label: '-' |
400 | 710 |
) |
711 |
#(#MenuItem |
|
672 | 712 |
#label: 'Save' |
843 | 713 |
#translateLabel: true |
767 | 714 |
#value: #doSaveMethod |
672 | 715 |
#activeHelpKey: #fileSaveMethod |
716 |
#enabled: #imageIsLoaded |
|
400 | 717 |
) |
718 |
#(#MenuItem |
|
672 | 719 |
#label: 'Save As...' |
843 | 720 |
#translateLabel: true |
767 | 721 |
#value: #doSaveMethodAs |
672 | 722 |
#activeHelpKey: #fileSaveMethodAs |
723 |
#enabled: #imageIsLoaded |
|
724 |
) |
|
725 |
#(#MenuItem |
|
726 |
#label: '-' |
|
400 | 727 |
) |
728 |
#(#MenuItem |
|
672 | 729 |
#label: 'Save To File...' |
843 | 730 |
#translateLabel: true |
767 | 731 |
#value: #doSaveImageFileAs |
672 | 732 |
#activeHelpKey: #fileSaveAs |
733 |
#enabled: #imageIsLoaded |
|
400 | 734 |
) |
735 |
#(#MenuItem |
|
672 | 736 |
#label: 'Save Mask To File...' |
843 | 737 |
#translateLabel: true |
767 | 738 |
#value: #doSaveImageMaskFileAs |
672 | 739 |
#activeHelpKey: #fileSaveMaskAs |
740 |
#enabled: #imageIsLoaded |
|
400 | 741 |
) |
742 |
#(#MenuItem |
|
672 | 743 |
#label: '-' |
400 | 744 |
) |
745 |
#(#MenuItem |
|
672 | 746 |
#label: 'Print' |
843 | 747 |
#translateLabel: true |
767 | 748 |
#value: #doPrint |
672 | 749 |
#activeHelpKey: #filePrint |
750 |
#enabled: #imageIsLoaded |
|
400 | 751 |
) |
752 |
#(#MenuItem |
|
672 | 753 |
#label: '-' |
400 | 754 |
) |
755 |
#(#MenuItem |
|
672 | 756 |
#label: 'Browse Class' |
843 | 757 |
#translateLabel: true |
767 | 758 |
#value: #doBrowseClass |
672 | 759 |
#activeHelpKey: #fileBrowseClass |
760 |
#enabled: #imageIsLoaded |
|
400 | 761 |
) |
762 |
#(#MenuItem |
|
672 | 763 |
#label: '-' |
400 | 764 |
) |
765 |
#(#MenuItem |
|
672 | 766 |
#label: 'Exit' |
767 |
#translateLabel: true |
|
768 |
#value: #closeRequest |
|
769 |
#activeHelpKey: #fileExit |
|
400 | 770 |
) |
771 |
) nil |
|
772 |
nil |
|
773 |
) |
|
774 |
) |
|
775 |
#(#MenuItem |
|
672 | 776 |
#label: 'Edit' |
843 | 777 |
#translateLabel: true |
672 | 778 |
#activeHelpKey: #edit |
779 |
#enabled: #imageIsLoaded |
|
780 |
#submenu: |
|
400 | 781 |
#(#Menu |
782 |
||
783 |
#( |
|
784 |
#(#MenuItem |
|
672 | 785 |
#label: 'Undo' |
843 | 786 |
#translateLabel: true |
767 | 787 |
#value: #doUndo |
672 | 788 |
#activeHelpKey: #editUndo |
789 |
#enabled: #valueOfCanUndo |
|
400 | 790 |
) |
791 |
#(#MenuItem |
|
672 | 792 |
#label: '-' |
400 | 793 |
) |
794 |
#(#MenuItem |
|
672 | 795 |
#label: 'Flip - Vertical' |
843 | 796 |
#translateLabel: true |
767 | 797 |
#value: #doFlipVertical |
672 | 798 |
#activeHelpKey: #editFlipVertical |
400 | 799 |
) |
800 |
#(#MenuItem |
|
672 | 801 |
#label: 'Flip - Horizontal' |
843 | 802 |
#translateLabel: true |
767 | 803 |
#value: #doFlipHorizontal |
672 | 804 |
#activeHelpKey: #editFlipHorizontal |
400 | 805 |
) |
806 |
#(#MenuItem |
|
672 | 807 |
#label: '-' |
400 | 808 |
) |
809 |
#(#MenuItem |
|
672 | 810 |
#label: 'Resize...' |
843 | 811 |
#translateLabel: true |
767 | 812 |
#value: #doResizeImage |
672 | 813 |
#activeHelpKey: #editResize |
400 | 814 |
) |
815 |
#(#MenuItem |
|
672 | 816 |
#label: 'Magnify...' |
843 | 817 |
#translateLabel: true |
767 | 818 |
#value: #doMagnifyImage |
672 | 819 |
#activeHelpKey: #editMagnifyImage |
400 | 820 |
) |
821 |
#(#MenuItem |
|
672 | 822 |
#label: 'Rotate...' |
843 | 823 |
#translateLabel: true |
767 | 824 |
#value: #doRotateImage |
672 | 825 |
#activeHelpKey: #editRotate |
400 | 826 |
) |
827 |
) nil |
|
828 |
nil |
|
829 |
) |
|
830 |
) |
|
831 |
#(#MenuItem |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
832 |
#label: 'ColorMap' |
843 | 833 |
#translateLabel: true |
672 | 834 |
#activeHelpKey: #colorMap |
835 |
#enabled: #imageIsLoaded |
|
836 |
#submenu: |
|
400 | 837 |
#(#Menu |
838 |
||
839 |
#( |
|
840 |
#(#MenuItem |
|
672 | 841 |
#label: '8-Plane' |
843 | 842 |
#translateLabel: true |
929 | 843 |
#activeHelpKey: #colorMap8 |
672 | 844 |
#argument: '8-plane' |
845 |
#indication: #colorMapMode:value: |
|
846 |
) |
|
847 |
#(#MenuItem |
|
848 |
#label: '4-Plane' |
|
843 | 849 |
#translateLabel: true |
929 | 850 |
#activeHelpKey: #colorMap4 |
672 | 851 |
#argument: '4-plane' |
852 |
#indication: #colorMapMode:value: |
|
400 | 853 |
) |
854 |
#(#MenuItem |
|
672 | 855 |
#label: '2-Plane' |
843 | 856 |
#translateLabel: true |
929 | 857 |
#activeHelpKey: #colorMap2 |
672 | 858 |
#argument: '2-plane' |
859 |
#indication: #colorMapMode:value: |
|
400 | 860 |
) |
861 |
#(#MenuItem |
|
672 | 862 |
#label: '1-Plane' |
843 | 863 |
#translateLabel: true |
929 | 864 |
#activeHelpKey: #colorMap1 |
672 | 865 |
#argument: '1-plane' |
866 |
#indication: #colorMapMode:value: |
|
400 | 867 |
) |
868 |
#(#MenuItem |
|
672 | 869 |
#label: '-' |
870 |
) |
|
871 |
#(#MenuItem |
|
872 |
#label: '8-Plane + Mask' |
|
843 | 873 |
#translateLabel: true |
929 | 874 |
#activeHelpKey: #colorMap8M |
672 | 875 |
#argument: '8-plane + mask' |
876 |
#indication: #colorMapMode:value: |
|
400 | 877 |
) |
878 |
#(#MenuItem |
|
672 | 879 |
#label: '4-Plane + Mask' |
843 | 880 |
#translateLabel: true |
929 | 881 |
#activeHelpKey: #colorMap4M |
672 | 882 |
#argument: '4-plane + mask' |
883 |
#indication: #colorMapMode:value: |
|
400 | 884 |
) |
885 |
#(#MenuItem |
|
672 | 886 |
#label: '2-Plane + Mask' |
843 | 887 |
#translateLabel: true |
929 | 888 |
#activeHelpKey: #colorMap2M |
672 | 889 |
#argument: '2-plane + mask' |
890 |
#indication: #colorMapMode:value: |
|
891 |
) |
|
892 |
#(#MenuItem |
|
893 |
#label: '1-Plane + Mask' |
|
843 | 894 |
#translateLabel: true |
929 | 895 |
#activeHelpKey: #colorMap1M |
672 | 896 |
#argument: '1-plane + mask' |
897 |
#indication: #colorMapMode:value: |
|
400 | 898 |
) |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
899 |
#(#MenuItem |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
900 |
#label: '-' |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
901 |
) |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
902 |
#(#MenuItem |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
903 |
#label: 'Compress colormap' |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
904 |
#translateLabel: true |
929 | 905 |
#activeHelpKey: #compressColormap |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
906 |
#value: #compressColorMap |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
907 |
) |
400 | 908 |
) nil |
909 |
nil |
|
910 |
) |
|
911 |
) |
|
912 |
#(#MenuItem |
|
737 | 913 |
#label: 'Settings' |
843 | 914 |
#translateLabel: true |
737 | 915 |
#submenu: |
916 |
#(#Menu |
|
917 |
||
918 |
#( |
|
919 |
#(#MenuItem |
|
905 | 920 |
#label: 'Grid Magnification...' |
921 |
#translateLabel: true |
|
922 |
#value: #doChangeGridMagnification |
|
923 |
#activeHelpKey: #settingsGridMagnification |
|
924 |
) |
|
925 |
#(#MenuItem |
|
926 |
#label: '-' |
|
927 |
) |
|
928 |
#(#MenuItem |
|
737 | 929 |
#label: 'Fonts' |
843 | 930 |
#translateLabel: true |
737 | 931 |
#submenuChannel: #menuFont |
932 |
) |
|
933 |
) nil |
|
934 |
nil |
|
935 |
) |
|
936 |
) |
|
937 |
#(#MenuItem |
|
756 | 938 |
#label: 'History' |
843 | 939 |
#translateLabel: true |
756 | 940 |
#activeHelpKey: #history |
941 |
#submenuChannel: #menuHistory |
|
942 |
) |
|
943 |
#(#MenuItem |
|
672 | 944 |
#label: 'Help' |
843 | 945 |
#translateLabel: true |
672 | 946 |
#startGroup: #right |
947 |
#activeHelpKey: #help |
|
948 |
#submenuChannel: #menuHelp |
|
400 | 949 |
) |
950 |
) nil |
|
951 |
nil |
|
952 |
) |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
953 |
|
929 | 954 |
"Modified: / 29.7.1998 / 22:26:55 / cg" |
400 | 955 |
! |
956 |
||
679 | 957 |
menuMouseButtonColors |
737 | 958 |
"This resource specification was automatically generated |
959 |
by the MenuEditor of ST/X." |
|
679 | 960 |
|
737 | 961 |
"Do not manually edit this!! If it is corrupted, |
962 |
the MenuEditor may not be able to read the specification." |
|
679 | 963 |
|
964 |
" |
|
965 |
MenuEditor new openOnClass:ImageEditor andSelector:#menuMouseButtonColors |
|
966 |
(Menu new fromLiteralArrayEncoding:(ImageEditor menuMouseButtonColors)) startUp |
|
967 |
" |
|
968 |
||
969 |
<resource: #menu> |
|
970 |
||
971 |
^ |
|
972 |
||
973 |
#(#Menu |
|
974 |
||
975 |
#( |
|
976 |
#(#MenuItem |
|
977 |
#label: 'Left Mouse Button' |
|
978 |
#nameKey: #leftMouseKeyButton |
|
979 |
#activeHelpKey: #mouseKeyColorMode |
|
980 |
#argument: '1' |
|
981 |
#labelImage: #(#ResourceRetriever nil #leftMouseKeyIcon) |
|
982 |
#indication: #mouseKeyColorMode:value: |
|
983 |
) |
|
984 |
#(#MenuItem |
|
985 |
#label: 'Right Mouse Button' |
|
986 |
#nameKey: #rightMouseKeyButton |
|
987 |
#activeHelpKey: #mouseKeyColorMode |
|
988 |
#argument: '2' |
|
989 |
#labelImage: #(#ResourceRetriever nil #rightMouseKeyIcon) |
|
990 |
#indication: #mouseKeyColorMode:value: |
|
991 |
) |
|
992 |
) nil |
|
993 |
nil |
|
994 |
) |
|
995 |
! |
|
996 |
||
400 | 997 |
menuToolbar |
737 | 998 |
"This resource specification was automatically generated |
999 |
by the MenuEditor of ST/X." |
|
400 | 1000 |
|
737 | 1001 |
"Do not manually edit this!! If it is corrupted, |
1002 |
the MenuEditor may not be able to read the specification." |
|
400 | 1003 |
|
1004 |
" |
|
1005 |
MenuEditor new openOnClass:ImageEditor andSelector:#menuToolbar |
|
1006 |
(Menu new fromLiteralArrayEncoding:(ImageEditor menuToolbar)) startUp |
|
1007 |
" |
|
1008 |
||
1009 |
<resource: #menu> |
|
1010 |
||
1011 |
^ |
|
1012 |
||
1013 |
#(#Menu |
|
1014 |
||
1015 |
#( |
|
1016 |
#(#MenuItem |
|
672 | 1017 |
#label: 'newImage' |
1018 |
#isButton: true |
|
767 | 1019 |
#value: #doNewImage |
672 | 1020 |
#activeHelpKey: #fileNewImage |
880 | 1021 |
#labelImage: #(#ResourceRetriever #Icon #newIcon) |
400 | 1022 |
) |
1023 |
#(#MenuItem |
|
672 | 1024 |
#label: 'loadFromClass' |
1025 |
#isButton: true |
|
767 | 1026 |
#value: #doLoadFromClass |
672 | 1027 |
#activeHelpKey: #fileLoadFromClass |
880 | 1028 |
#labelImage: #(#ResourceRetriever #Icon #loadIcon) |
672 | 1029 |
) |
1030 |
#(#MenuItem |
|
1031 |
#label: 'saveMethod' |
|
1032 |
#isButton: true |
|
767 | 1033 |
#value: #doSaveMethod |
672 | 1034 |
#activeHelpKey: #fileSaveMethod |
1035 |
#enabled: #imageIsLoaded |
|
880 | 1036 |
#labelImage: #(#ResourceRetriever #Icon #saveIcon) |
400 | 1037 |
) |
1038 |
#(#MenuItem |
|
672 | 1039 |
#label: '' |
400 | 1040 |
) |
1041 |
#(#MenuItem |
|
672 | 1042 |
#label: '' |
1043 |
) |
|
1044 |
#(#MenuItem |
|
1045 |
#label: '' |
|
1046 |
) |
|
1047 |
#(#MenuItem |
|
1048 |
#label: '' |
|
400 | 1049 |
) |
1050 |
#(#MenuItem |
|
672 | 1051 |
#label: 'Point' |
1052 |
#activeHelpKey: #drawModePoint |
|
1053 |
#enabled: #imageIsLoaded |
|
1054 |
#argument: 'point' |
|
1055 |
#indication: #editMode:value: |
|
400 | 1056 |
) |
1057 |
#(#MenuItem |
|
672 | 1058 |
#label: 'Box' |
1059 |
#activeHelpKey: #drawModeBox |
|
1060 |
#enabled: #imageIsLoaded |
|
1061 |
#argument: 'box' |
|
1062 |
#indication: #editMode:value: |
|
400 | 1063 |
) |
1064 |
#(#MenuItem |
|
672 | 1065 |
#label: 'Filled Box' |
1066 |
#activeHelpKey: #drawModeFilledBox |
|
1067 |
#enabled: #imageIsLoaded |
|
1068 |
#argument: 'filledBox' |
|
1069 |
#indication: #editMode:value: |
|
400 | 1070 |
) |
1071 |
#(#MenuItem |
|
672 | 1072 |
#label: 'Fill' |
1073 |
#activeHelpKey: #drawModeFill |
|
1074 |
#enabled: #imageIsLoaded |
|
1075 |
#argument: 'fill' |
|
1076 |
#indication: #editMode:value: |
|
400 | 1077 |
) |
1078 |
#(#MenuItem |
|
672 | 1079 |
#label: 'Copy' |
1080 |
#activeHelpKey: #drawModeCopy |
|
1081 |
#enabled: #imageIsLoaded |
|
1082 |
#argument: 'copy' |
|
1083 |
#indication: #editMode:value: |
|
400 | 1084 |
) |
1085 |
#(#MenuItem |
|
672 | 1086 |
#label: 'Paste' |
1087 |
#activeHelpKey: #drawModePaste |
|
1088 |
#enabled: #imageIsLoaded |
|
1089 |
#argument: 'paste' |
|
1090 |
#indication: #editMode:value: |
|
400 | 1091 |
) |
914 | 1092 |
#(#MenuItem |
1093 |
#label: 'Paste Under' |
|
1094 |
#activeHelpKey: #drawModePasteUnder |
|
1095 |
#enabled: #imageIsLoaded |
|
1096 |
#argument: 'pasteUnder' |
|
1097 |
#indication: #editMode:value: |
|
1098 |
) |
|
400 | 1099 |
) nil |
1100 |
nil |
|
1101 |
) |
|
1102 |
! ! |
|
1103 |
||
1104 |
!ImageEditor methodsFor:'accessing'! |
|
1105 |
||
1106 |
image |
|
767 | 1107 |
"returns the current editing image" |
400 | 1108 |
|
911 | 1109 |
^imageEditView image |
400 | 1110 |
! |
1111 |
||
1112 |
postOpenAction: anAction |
|
767 | 1113 |
"sets an action which is evaluated after opening" |
400 | 1114 |
|
1115 |
postOpenAction := anAction |
|
1116 |
! ! |
|
1117 |
||
1118 |
!ImageEditor methodsFor:'accessing - views'! |
|
1119 |
||
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1120 |
colorDataSetView |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1121 |
"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
|
1122 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1123 |
^(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
|
1124 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1125 |
"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
|
1126 |
! |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1127 |
|
487 | 1128 |
coordLabel |
767 | 1129 |
"returns the view the coord label" |
487 | 1130 |
|
1131 |
^builder componentAt: #coordLabel |
|
1132 |
! |
|
1133 |
||
400 | 1134 |
imageEditView |
911 | 1135 |
"returns the view of the image" |
400 | 1136 |
|
911 | 1137 |
^imageEditView := (builder componentAt: #imageEditView) subViews first |
400 | 1138 |
! |
1139 |
||
1140 |
imagePreView |
|
767 | 1141 |
"returns the preview of the image" |
400 | 1142 |
|
1143 |
^(builder componentAt: #imagePreView) subViews first |
|
475 | 1144 |
! ! |
1145 |
||
400 | 1146 |
!ImageEditor methodsFor:'aspects'! |
1147 |
||
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1148 |
activityInfoHolder |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1149 |
^ self valueOfInfoLabel |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1150 |
|
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1151 |
"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
|
1152 |
! |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1153 |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1154 |
colorColumnAdaptor |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1155 |
^ self |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1156 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1157 |
"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
|
1158 |
! |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1159 |
|
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1160 |
imageInfoHolder |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1161 |
|holder| |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1162 |
(holder := builder bindingAt:#imageInfoHolder) isNil ifTrue:[ |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1163 |
builder aspectAt:#imageInfoHolder put:(holder := '' asValue). |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1164 |
]. |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1165 |
^ holder |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1166 |
|
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1167 |
"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
|
1168 |
! |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1169 |
|
400 | 1170 |
imageIsLoaded |
767 | 1171 |
"returns whether an image is loaded as value holder" |
400 | 1172 |
|
1173 |
|holder| |
|
1174 |
(holder := builder bindingAt:#imageIsLoaded) isNil ifTrue:[ |
|
1175 |
builder aspectAt:#imageIsLoaded put:(holder := false asValue). |
|
1176 |
]. |
|
1177 |
^ holder |
|
1178 |
! |
|
1179 |
||
1180 |
listOfColors |
|
767 | 1181 |
"returns the list of colors in a List" |
400 | 1182 |
|
1183 |
|holder| |
|
1184 |
(holder := builder bindingAt:#listOfColors) isNil ifTrue:[ |
|
1185 |
builder aspectAt:#listOfColors put:(holder := List new). |
|
1186 |
]. |
|
1187 |
^ holder |
|
1188 |
! |
|
1189 |
||
1190 |
selectionOfColor |
|
767 | 1191 |
"returns current selection of the edit color as an AspectAdaptor" |
400 | 1192 |
|
1193 |
|holder| |
|
1194 |
(holder := builder bindingAt:#selectionOfColor) isNil ifTrue:[ |
|
1195 |
builder aspectAt:#selectionOfColor put:( |
|
1196 |
holder := AspectAdaptor new subject:self; forAspect:#selectedColorIndex). |
|
1197 |
]. |
|
1198 |
^ holder |
|
1199 |
! |
|
1200 |
||
1201 |
valueOfMagnification |
|
767 | 1202 |
"returns current magnification of the image as an AspectAdaptor" |
400 | 1203 |
|
1204 |
|holder| |
|
1205 |
(holder := builder bindingAt:#valueOfMagnification) isNil ifTrue:[ |
|
1206 |
builder aspectAt:#valueOfMagnification put:( |
|
1207 |
holder := AspectAdaptor new subject:self; forAspect:#magnification) |
|
1208 |
]. |
|
1209 |
^ holder |
|
1210 |
! ! |
|
1211 |
||
767 | 1212 |
!ImageEditor methodsFor:'change & update'! |
1213 |
||
1214 |
findColorMapMode |
|
899 | 1215 |
"finds the colorMapMode for a new image" |
767 | 1216 |
|
1217 |
self image depth > 8 ifTrue: [colorMapMode := ''. self listOfColors removeAll. ^nil]. |
|
1218 |
colorMapMode := self image depth printString, '-plane'. |
|
1219 |
self listOfColors isEmpty |
|
1220 |
ifTrue: |
|
1221 |
[ |
|
1222 |
self colorMapMode: colorMapMode value: nil |
|
1223 |
]. |
|
911 | 1224 |
imageEditView selectColors: (Array with: (self listOfColors at: 1) with: (self listOfColors at: 2 ifAbsent: [self listOfColors at: 1])). |
898 | 1225 |
|
1226 |
self image mask notNil |
|
767 | 1227 |
ifTrue: |
1228 |
[ |
|
1229 |
colorMapMode := colorMapMode, ' + mask'. |
|
898 | 1230 |
(self listOfColors detect: [:clr| clr = (Color basicNew setColorId:0)] ifNone: nil) isNil |
1231 |
ifTrue: |
|
1232 |
[ |
|
1233 |
self listOfColors addFirst: (Color basicNew setColorId:0). |
|
911 | 1234 |
imageEditView selectColors: (Array with: (self listOfColors at: 2 ifAbsent: [self listOfColors at: 1]) with: (self listOfColors at: 1)). |
898 | 1235 |
] |
767 | 1236 |
]. |
1237 |
self selectionOfColor value: 0. |
|
911 | 1238 |
self selectionOfColor value: (self listOfColors indexOf: imageEditView selectedColor). |
767 | 1239 |
! |
1240 |
||
1241 |
updateForNoneImage |
|
1242 |
"updates channels and view, if image is loaded" |
|
1243 |
||
1244 |
self imageIsLoaded value: false. |
|
1245 |
self listOfColors removeAll. |
|
1246 |
self imagePreView image: nil |
|
1247 |
||
1248 |
||
1249 |
||
1250 |
||
1251 |
! |
|
1252 |
||
1253 |
updateLabelsAndHistory |
|
1254 |
"updates labels and history, if something has changed" |
|
1255 |
||
1256 |
self imageIsLoaded value: self image notNil. |
|
1257 |
||
1258 |
self image isNil ifTrue: [^nil]. |
|
1259 |
||
1260 |
self updateInfoLabel. |
|
1261 |
||
911 | 1262 |
imageEditView resourceMessage asCollectionOfWords size = 2 |
1263 |
ifTrue: [self addToHistory: imageEditView resourceMessage -> #loadFromMessage:]. |
|
767 | 1264 |
|
1265 |
self image fileName notNil |
|
1266 |
ifTrue: [self addToHistory: self image fileName -> #loadFromFile:]. |
|
1267 |
||
1268 |
||
1269 |
||
1270 |
! ! |
|
1271 |
||
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1272 |
!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
|
1273 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1274 |
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
|
1275 |
"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
|
1276 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1277 |
^ 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
|
1278 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1279 |
"Created: / 26.7.1998 / 12:30:35 / cg" |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1280 |
! |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1281 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1282 |
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
|
1283 |
"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
|
1284 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1285 |
^ 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
|
1286 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1287 |
"Created: / 26.7.1998 / 12:30:29 / cg" |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1288 |
! |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1289 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1290 |
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
|
1291 |
"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
|
1292 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1293 |
^ 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
|
1294 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1295 |
"Modified: / 26.7.1998 / 12:30:22 / cg" |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1296 |
! ! |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1297 |
|
672 | 1298 |
!ImageEditor methodsFor:'help'! |
1299 |
||
1300 |
defaultInfoLabel |
|
767 | 1301 |
"returns the default info label" |
672 | 1302 |
|
911 | 1303 |
(imageEditView resourceClass isSymbol and: [(Smalltalk at: imageEditView resourceClass) isClass]) |
672 | 1304 |
ifTrue: |
1305 |
[ |
|
911 | 1306 |
^imageEditView resourceClass, ' >> ', imageEditView resourceSelector |
672 | 1307 |
]. |
767 | 1308 |
^'No class and selector defined.' |
674 | 1309 |
! |
1310 |
||
702 | 1311 |
openDocumentation |
767 | 1312 |
"opens the documentation file of the Image Editor" |
674 | 1313 |
|
763 | 1314 |
self openHTMLDocument: 'tools/uipainter/ImageEditor.html' |
1315 |
||
672 | 1316 |
! ! |
1317 |
||
767 | 1318 |
!ImageEditor methodsFor:'loading'! |
1319 |
||
1320 |
loadFromFile: aFileName |
|
1321 |
"loads an image from aFileName and sets up color map list and other info labels" |
|
1322 |
||
911 | 1323 |
(imageEditView loadFromFile: aFileName) notNil |
767 | 1324 |
ifTrue: |
1325 |
[ |
|
1326 |
self image notNil |
|
1327 |
ifTrue: |
|
1328 |
[ |
|
1329 |
self image colorMap notNil |
|
1330 |
ifTrue: |
|
1331 |
[ |
|
1332 |
self listOfColors contents: self image usedColors asSet. |
|
1333 |
] |
|
1334 |
ifFalse: |
|
1335 |
[ |
|
1336 |
self listOfColors removeAll. |
|
1337 |
]. |
|
1338 |
self findColorMapMode. |
|
1339 |
self updateLabelsAndHistory. |
|
1340 |
] |
|
1341 |
ifFalse: |
|
1342 |
[ |
|
1343 |
self updateForNoneImage |
|
1344 |
] |
|
1345 |
] |
|
1346 |
! |
|
1347 |
||
1348 |
loadFromImage: anImage |
|
1349 |
"loads an image from anImage and sets up color map list and other info labels" |
|
1350 |
||
911 | 1351 |
imageEditView image: anImage. |
767 | 1352 |
self image notNil |
1353 |
ifTrue: |
|
1354 |
[ |
|
1355 |
self image colorMap notNil |
|
1356 |
ifTrue: |
|
1357 |
[ |
|
1358 |
self listOfColors contents: self image usedColors asSet asOrderedCollection. |
|
1359 |
] |
|
1360 |
ifFalse: |
|
1361 |
[ |
|
1362 |
self listOfColors removeAll. |
|
1363 |
]. |
|
1364 |
self findColorMapMode. |
|
1365 |
self updateLabelsAndHistory. |
|
1366 |
] |
|
1367 |
ifFalse: |
|
1368 |
[ |
|
1369 |
self updateForNoneImage |
|
1370 |
] |
|
1371 |
! |
|
1372 |
||
1373 |
loadFromMessage: aMessage |
|
1374 |
"loads an image by evaluating aMessage and sets up color map list and other info labels" |
|
1375 |
||
911 | 1376 |
(imageEditView loadFromMessage: aMessage) notNil |
767 | 1377 |
ifTrue: |
1378 |
[ |
|
1379 |
self image notNil |
|
1380 |
ifTrue: |
|
1381 |
[ |
|
1382 |
self listOfColors contents: self image usedColors asSet asOrderedCollection. |
|
1383 |
self findColorMapMode. |
|
1384 |
self updateLabelsAndHistory. |
|
1385 |
] |
|
1386 |
ifFalse: |
|
1387 |
[ |
|
1388 |
self updateForNoneImage |
|
1389 |
] |
|
1390 |
] |
|
1391 |
! |
|
1392 |
||
1393 |
loadFromOrPrepareForMessage: aMessage |
|
1394 |
"loads an image by evaluating aMessage; |
|
1395 |
if no image could extract from aMessage; do set the class and the selector from |
|
1396 |
the aMessage for a saving at the end of editing" |
|
1397 |
||
911 | 1398 |
(imageEditView loadFromMessage: aMessage) notNil |
767 | 1399 |
ifTrue: |
1400 |
[ |
|
1401 |
self listOfColors contents: self image usedColors asSet asOrderedCollection. |
|
1402 |
self findColorMapMode. |
|
1403 |
] |
|
1404 |
ifFalse: |
|
1405 |
[ |
|
911 | 1406 |
imageEditView resourceMessage: aMessage. |
767 | 1407 |
]. |
1408 |
self updateLabelsAndHistory. |
|
1409 |
! ! |
|
1410 |
||
400 | 1411 |
!ImageEditor methodsFor:'menu modes'! |
1412 |
||
1413 |
colorMapMode: aMode |
|
767 | 1414 |
"returns whether colorMapMode is equal to aMode" |
400 | 1415 |
|
1416 |
^colorMapMode = aMode |
|
1417 |
! |
|
1418 |
||
1419 |
editMode: aMode |
|
767 | 1420 |
"returns whether editMode is equal to aMode" |
400 | 1421 |
|
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1422 |
^ imageEditView notNil and:[imageEditView editMode = aMode] |
400 | 1423 |
! |
1424 |
||
1425 |
editMode: aMode value: aValue |
|
767 | 1426 |
"sets the editMode to aMode" |
400 | 1427 |
|
911 | 1428 |
imageEditView editMode: aMode |
400 | 1429 |
! |
1430 |
||
1431 |
mouseKeyColorMode: aMode |
|
767 | 1432 |
"sets the mouseKeyColorMode to aMode" |
400 | 1433 |
|
911 | 1434 |
^imageEditView mouseKeyColorMode = aMode |
400 | 1435 |
! |
1436 |
||
1437 |
mouseKeyColorMode: aMode value: aValue |
|
767 | 1438 |
"sets the mouseKeyColorMode to aMode" |
400 | 1439 |
|
911 | 1440 |
imageEditView mouseKeyColorMode: aMode. |
400 | 1441 |
|
911 | 1442 |
self selectionOfColor value: (self listOfColors indexOf: imageEditView selectedColor). |
400 | 1443 |
! ! |
1444 |
||
535 | 1445 |
!ImageEditor methodsFor:'queries'! |
1446 |
||
1447 |
preferredExtent |
|
767 | 1448 |
"returns the preferred extent" |
535 | 1449 |
|
1450 |
^super preferredExtent max: (Screen current width//3)@(Screen current height//3.5) |
|
1451 |
||
1452 |
||
1453 |
! ! |
|
1454 |
||
400 | 1455 |
!ImageEditor methodsFor:'selection'! |
1456 |
||
1457 |
magnification |
|
767 | 1458 |
"returns the magnification of the image" |
400 | 1459 |
|
911 | 1460 |
self imageEditView isNil ifTrue: [^1]. |
1461 |
^imageEditView magnification x |
|
400 | 1462 |
! |
1463 |
||
1464 |
magnification: aValue |
|
767 | 1465 |
"sets the magnification of the image" |
400 | 1466 |
|
905 | 1467 |
|magnification| |
1468 |
magnification := (aValue ? 1) asPoint. |
|
911 | 1469 |
(magnification = imageEditView magnification or: [magnification = (0@0)]) ifTrue: [^nil]. |
1470 |
imageEditView magnification: magnification |
|
400 | 1471 |
! |
1472 |
||
1473 |
selectedColorIndex |
|
767 | 1474 |
"returns the index of the selected color" |
400 | 1475 |
|
1476 |
^selectedColorIndex |
|
1477 |
! |
|
1478 |
||
1479 |
selectedColorIndex: anIndex |
|
767 | 1480 |
"sets the index of the selected color" |
400 | 1481 |
|
1482 |
selectedColorIndex := anIndex. |
|
911 | 1483 |
imageEditView selectedColor: (self listOfColors at: anIndex ifAbsent: [^nil]) |
400 | 1484 |
|
1485 |
! ! |
|
1486 |
||
1487 |
!ImageEditor methodsFor:'startup / release'! |
|
1488 |
||
1489 |
closeRequest |
|
767 | 1490 |
"close request" |
400 | 1491 |
|
911 | 1492 |
imageEditView checkModified ifTrue:[super closeRequest] |
400 | 1493 |
|
1494 |
! |
|
1495 |
||
1496 |
open |
|
767 | 1497 |
"after opening, sets the masterApplication of the imageEditView to self" |
400 | 1498 |
|
1499 |
super open. |
|
444 | 1500 |
|
911 | 1501 |
imageEditView := (builder componentAt: #imageEditView) subViews first. |
1502 |
imageEditView masterApplication: self |
|
400 | 1503 |
! |
1504 |
||
1505 |
postOpenWith:aBuilder |
|
767 | 1506 |
"after opening, sets the masterApplication of the imageEditView to self; |
1507 |
evaluate the postOpenAction" |
|
400 | 1508 |
|
911 | 1509 |
imageEditView masterApplication: self. |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1510 |
imageEditView imageInfoHolder:(self imageInfoHolder). |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1511 |
imageEditView activityInfoHolder:(self activityInfoHolder). |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1512 |
|
400 | 1513 |
postOpenAction notNil ifTrue: [postOpenAction value]. |
1514 |
||
767 | 1515 |
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
|
1516 |
|
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1517 |
"Modified: / 29.7.1998 / 18:49:20 / cg" |
400 | 1518 |
! ! |
1519 |
||
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1520 |
!ImageEditor methodsFor:'user actions - colormap'! |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1521 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1522 |
colorMapMode:aMode value: aValue |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1523 |
"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
|
1524 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1525 |
|depth numColors newColorMap newImage |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1526 |
oldImage image newColors realColorMap oldFileName |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1527 |
usedColors useNearest usageCounts tmpBits tmpMap quest| |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1528 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1529 |
self withExecuteCursorDo:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1530 |
oldImage := self image. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1531 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1532 |
newColorMap := self class listOfColorMaps at:aMode. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1533 |
depth := (newColorMap size log: 2) asInteger. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1534 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1535 |
useNearest := false. |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1536 |
depth == 1 ifTrue:[ |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1537 |
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
|
1538 |
] ifFalse:[ |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1539 |
quest := 'Keep colormap (or use standard)' |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1540 |
]. |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1541 |
(self confirm:(resources string:quest)) ifTrue:[ |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1542 |
"/ keep the colormap |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1543 |
depth > oldImage depth ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1544 |
"/ easy - simply copy the part |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1545 |
numColors := 1 bitShift:oldImage depth. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1546 |
0 to:numColors-1 do:[:pixel | |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1547 |
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
|
1548 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1549 |
] ifFalse:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1550 |
"/ see if all used color fit the new colormap |
920 | 1551 |
usedColors := oldImage usedColors asArray. |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1552 |
usedColors size <= (1 bitShift:depth) ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1553 |
"/ yea - just install them |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1554 |
usedColors keysAndValuesDo:[:idx :clr | |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1555 |
newColorMap at:idx put:clr |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1556 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1557 |
] ifFalse:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1558 |
"/ copy over those that are most often used. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1559 |
oldImage depth ~~ 8 ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1560 |
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
|
1561 |
oldImage bits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1562 |
expandPixels:(oldImage depth) |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1563 |
width:oldImage width |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1564 |
height:oldImage height |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1565 |
into:tmpBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1566 |
mapping:nil. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1567 |
] ifFalse:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1568 |
tmpBits := oldImage bits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1569 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1570 |
usageCounts := tmpBits usageCounts. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1571 |
tmpMap := Array new:usageCounts size. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1572 |
oldImage colorMap asArray keysAndValuesDo:[:i :clr | |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1573 |
tmpMap at:i put:clr |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1574 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1575 |
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
|
1576 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1577 |
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
|
1578 |
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
|
1579 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1580 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1581 |
useNearest := Dialog |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1582 |
confirmWithCancel:(resources |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1583 |
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
|
1584 |
with:usedColors size |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1585 |
with:(1 bitShift:depth)) withCRs |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1586 |
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
|
1587 |
useNearest isNil ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1588 |
^ self "/ cancel |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1589 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1590 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1591 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1592 |
] ifFalse:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1593 |
"/ standard colormap |
921
a5aca21ea803
also allow nearest-color mode for standard colormap.
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
1594 |
usedColors := oldImage usedColors. |
a5aca21ea803
also allow nearest-color mode for standard colormap.
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
1595 |
(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
|
1596 |
useNearest := Dialog |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1597 |
confirmWithCancel:(resources |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1598 |
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
|
1599 |
) withCRs |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1600 |
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
|
1601 |
useNearest isNil ifTrue:[ |
a5aca21ea803
also allow nearest-color mode for standard colormap.
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
1602 |
^ self "/ cancel |
a5aca21ea803
also allow nearest-color mode for standard colormap.
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
1603 |
]. |
a5aca21ea803
also allow nearest-color mode for standard colormap.
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
1604 |
]. |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1605 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1606 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1607 |
imageEditView makeUndo. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1608 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1609 |
newImage := (Image implementorForDepth: depth) new. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1610 |
oldFileName := oldImage fileName. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1611 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1612 |
Object errorSignal handle: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1613 |
[:ex| |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1614 |
Object errorSignal handle: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1615 |
[:ex| |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1616 |
imageEditView undo. |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1617 |
^self warn:(resources string:'Conversion failed !!') |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1618 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1619 |
do: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1620 |
[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1621 |
newImage := (Image implementorForDepth: depth) new. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1622 |
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
|
1623 |
newImage colorMap:newColorMap. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1624 |
newImage photometric:#palette. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1625 |
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
|
1626 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1627 |
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
|
1628 |
[:x :y :clr | |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1629 |
|newColor| |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1630 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1631 |
(newColorMap includes:clr) |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1632 |
ifTrue: [newColor := clr] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1633 |
ifFalse: [ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1634 |
useNearest ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1635 |
newColor := clr nearestIn:newColorMap |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1636 |
] ifFalse:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1637 |
newColor := oldImage colorMap first |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1638 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1639 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1640 |
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
|
1641 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1642 |
image := newImage |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1643 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1644 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1645 |
do: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1646 |
[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1647 |
image := newImage fromImage: oldImage |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1648 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1649 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1650 |
(String fromString: aMode) reverse readStream nextWord reverse = 'mask' |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1651 |
ifTrue: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1652 |
[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1653 |
image mask isNil |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1654 |
ifTrue: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1655 |
[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1656 |
image mask: (Depth1Image fromImage: (image asThresholdMonochromeImage: 0.1)). |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1657 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1658 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1659 |
ifFalse: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1660 |
[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1661 |
image mask: nil. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1662 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1663 |
realColorMap := OrderedCollection new. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1664 |
image realColorMap do: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1665 |
[:clr| |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1666 |
(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
|
1667 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1668 |
newColors := realColorMap copyFrom: 1 to: (newColorMap size min: realColorMap size). |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1669 |
newColorMap do: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1670 |
[:clr| |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1671 |
((newColors size < newColorMap size) and: [(newColors includes: clr) not]) |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1672 |
ifTrue: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1673 |
[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1674 |
newColors add: clr |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1675 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1676 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1677 |
image colorMap: newColors. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1678 |
colorMapMode := aMode. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1679 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1680 |
(imageEditView image: image) notNil ifTrue: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1681 |
[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1682 |
image fileName: oldFileName. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1683 |
self listOfColors contents: image colorMap. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1684 |
self findColorMapMode. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1685 |
self updateLabelsAndHistory. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1686 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1687 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1688 |
|
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1689 |
"Modified: / 29.7.1998 / 18:15:10 / cg" |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1690 |
! |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1691 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1692 |
compressColorMap |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1693 |
"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
|
1694 |
|
927 | 1695 |
|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
|
1696 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1697 |
oldImage := self image. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1698 |
depth := oldImage depth. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1699 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1700 |
oldImage photometric ~~ #palette ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1701 |
self information:'Only palette images have colormaps.'. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1702 |
^ self |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1703 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1704 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1705 |
usedColors := oldImage usedColors. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1706 |
usedColors size == (1 bitShift:depth) ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1707 |
self information:'All colors are used - no compression.'. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1708 |
^ self |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1709 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1710 |
usedColors size == oldImage colorMap size ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1711 |
self information:'Colormap already compressed - no compression.'. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1712 |
^ self |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1713 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1714 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1715 |
imageEditView makeUndo. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1716 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1717 |
self information:('%1 colors used.' bindWith:usedColors size). |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1718 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1719 |
self withExecuteCursorDo:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1720 |
newColorMap := Array new:usedColors size. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1721 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1722 |
"/ translation table |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1723 |
oldToNew := ByteArray new:(1 bitShift:depth). |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1724 |
newColorMap := usedColors asArray. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1725 |
oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr | |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1726 |
|newPixel| |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1727 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1728 |
(usedColors includes:clr) ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1729 |
newPixel := newColorMap indexOf:clr. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1730 |
oldToNew at:oldIdx put:newPixel-1. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1731 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1732 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1733 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1734 |
oldBits := oldImage bits. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1735 |
newBits := ByteArray new:(oldBits size). |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1736 |
depth ~~ 8 ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1737 |
"/ expand/compress can only handle 8bits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1738 |
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
|
1739 |
oldBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1740 |
expandPixels:depth |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1741 |
width:oldImage width |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1742 |
height:oldImage height |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1743 |
into:tmpBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1744 |
mapping:oldToNew. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1745 |
tmpBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1746 |
compressPixels:depth |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1747 |
width:oldImage width |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1748 |
height:oldImage height |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1749 |
into:newBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1750 |
mapping:nil |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1751 |
] ifFalse:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1752 |
oldBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1753 |
expandPixels:depth |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1754 |
width:oldImage width |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1755 |
height:oldImage height |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1756 |
into:newBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1757 |
mapping:oldToNew. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1758 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1759 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1760 |
newImage := oldImage species new |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1761 |
width:oldImage width |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1762 |
height:oldImage height |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1763 |
depth:depth |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1764 |
fromArray:newBits. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1765 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1766 |
newImage colorMap:newColorMap. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1767 |
newImage fileName:oldImage fileName. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1768 |
newImage mask:(oldImage mask copy). |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1769 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1770 |
(imageEditView image:newImage) notNil ifTrue: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1771 |
[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1772 |
self listOfColors contents: newImage colorMap. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1773 |
self findColorMapMode. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1774 |
self updateLabelsAndHistory. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1775 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1776 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1777 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1778 |
"Created: / 28.7.1998 / 20:03:11 / cg" |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1779 |
"Modified: / 28.7.1998 / 21:36:17 / cg" |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1780 |
! ! |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1781 |
|
400 | 1782 |
!ImageEditor methodsFor:'user actions - editing'! |
1783 |
||
767 | 1784 |
doBrowseClass |
1785 |
"opens a System Browser on the resourceClass and the resourceSelector" |
|
400 | 1786 |
|
911 | 1787 |
SystemBrowser openInClass: (Smalltalk at: imageEditView resourceClass ifAbsent: [^nil]) class selector: imageEditView resourceSelector |
400 | 1788 |
! |
1789 |
||
905 | 1790 |
doChangeGridMagnification |
1791 |
"change grid magnification" |
|
1792 |
||
911 | 1793 |
imageEditView changeGridMagnification |
905 | 1794 |
! |
1795 |
||
767 | 1796 |
doFlipHorizontal |
1797 |
"flips horizontally current image" |
|
400 | 1798 |
|
911 | 1799 |
imageEditView flipHorizontal |
400 | 1800 |
! |
1801 |
||
767 | 1802 |
doFlipVertical |
1803 |
"flips vertically current image" |
|
400 | 1804 |
|
911 | 1805 |
imageEditView flipVertical |
400 | 1806 |
! |
1807 |
||
767 | 1808 |
doMagnifyDown |
1809 |
"magnifies current image one step down" |
|
400 | 1810 |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1811 |
|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
|
1812 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1813 |
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
|
1814 |
(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
|
1815 |
magHolder value: mag - 1 |
400 | 1816 |
] |
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1817 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1818 |
"Modified: / 26.7.1998 / 20:24:08 / cg" |
400 | 1819 |
! |
1820 |
||
767 | 1821 |
doMagnifyImage |
1822 |
"magnifies current image" |
|
400 | 1823 |
|
911 | 1824 |
imageEditView magnifyImage. |
400 | 1825 |
self updateInfoLabel |
1826 |
! |
|
1827 |
||
767 | 1828 |
doMagnifyUp |
1829 |
"magnifies current image one step up" |
|
400 | 1830 |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1831 |
|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
|
1832 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1833 |
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
|
1834 |
(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
|
1835 |
magHolder value: mag + 1 |
400 | 1836 |
] |
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1837 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1838 |
"Modified: / 26.7.1998 / 20:23:52 / cg" |
400 | 1839 |
! |
1840 |
||
767 | 1841 |
doNegativeImage |
1842 |
"negates current image by negating the color map" |
|
400 | 1843 |
|
911 | 1844 |
imageEditView negativeImage. |
400 | 1845 |
self listOfColors removeAll. |
901 | 1846 |
self findColorMapMode. |
911 | 1847 |
imageEditView undoImages removeLast |
400 | 1848 |
! |
1849 |
||
767 | 1850 |
doResizeImage |
1851 |
"resizes current image" |
|
400 | 1852 |
|
911 | 1853 |
imageEditView resizeImage. |
400 | 1854 |
self updateInfoLabel |
1855 |
! |
|
1856 |
||
767 | 1857 |
doRotateImage |
1858 |
"rotates current image" |
|
400 | 1859 |
|
911 | 1860 |
imageEditView rotateImage. |
400 | 1861 |
self updateInfoLabel |
1862 |
! |
|
1863 |
||
767 | 1864 |
doUndo |
1865 |
"reverses last edit action" |
|
400 | 1866 |
|
911 | 1867 |
imageEditView undo |
400 | 1868 |
! ! |
1869 |
||
1870 |
!ImageEditor methodsFor:'user actions - loading'! |
|
1871 |
||
767 | 1872 |
doLoadFromClass |
1873 |
"opens a dialog for loading an image from class and a (resource-) selector" |
|
400 | 1874 |
|
911 | 1875 |
(imageEditView loadFromClass) notNil |
574 | 1876 |
ifTrue: |
1877 |
[ |
|
1878 |
self image notNil |
|
1879 |
ifTrue: |
|
1880 |
[ |
|
1881 |
self listOfColors contents: self image usedColors asSet asOrderedCollection. |
|
1882 |
self findColorMapMode. |
|
767 | 1883 |
self updateLabelsAndHistory |
400 | 1884 |
] |
1885 |
ifFalse: |
|
1886 |
[ |
|
461 | 1887 |
self updateForNoneImage |
1888 |
] |
|
449 | 1889 |
] |
400 | 1890 |
! |
1891 |
||
767 | 1892 |
doLoadFromFile |
1893 |
"opens a dialog for loading an image from a file" |
|
400 | 1894 |
|
767 | 1895 |
self loadFromFile: |
1896 |
(FileSelectionBrowser |
|
1897 |
request: 'Load Image From' |
|
1898 |
fileName: (self image notNil ifTrue: [self image fileName] ifFalse: [nil]) |
|
1899 |
withFileFilters: FileSelectionBrowser loadImageFileNameFilters) |
|
400 | 1900 |
! |
1901 |
||
767 | 1902 |
doNewImage |
1903 |
"opens a dialog with choices of size and color map for creating a new image" |
|
400 | 1904 |
|
1905 |
|aspects| |
|
767 | 1906 |
|
400 | 1907 |
aspects := IdentityDictionary new |
767 | 1908 |
at:#listOfSizes put: self class listOfDefaultSizes asValue; |
1909 |
at:#listOfColorMaps put: self class listOfColorMaps keys asSortedCollection asValue; |
|
1910 |
at:#selectionOfSize put: self class listOfDefaultSizes first copy asValue; |
|
400 | 1911 |
at:#selectionOfColorMap put: self class listOfColorMaps keys asSortedCollection first asValue; |
1912 |
yourself. |
|
1913 |
||
767 | 1914 |
(self openDialogInterface:#dialogSpecForNewImage withBindings:aspects) |
400 | 1915 |
ifTrue: |
1916 |
[ |
|
1917 |
|width height cMap imageClass image| |
|
767 | 1918 |
|
1919 |
width := 128 min: (Integer readFromString: ((aspects at:#selectionOfSize) value upTo: $x) onError:[24]). |
|
400 | 1920 |
height := 128 min: (Integer readFromString: ((aspects at:#selectionOfSize) value copy reverse upTo: $x) reverse onError:[24]). |
1921 |
||
767 | 1922 |
cMap := (self class listOfColorMaps at: (colorMapMode := (aspects at:#selectionOfColorMap) value)). |
400 | 1923 |
imageClass := Image implementorForDepth: ((cMap size log: 2) asInteger). |
767 | 1924 |
image := imageClass width: width height: height fromArray: (ByteArray new: width*height). |
400 | 1925 |
|
1926 |
(colorMapMode copy reverse readStream nextWord reverse = 'mask') |
|
1927 |
ifTrue: |
|
1928 |
[ |
|
767 | 1929 |
image mask: (Depth1Image width: width height: height depth: 1 fromArray: (ByteArray new: width*height)) clearMaskedPixels |
400 | 1930 |
]. |
1931 |
image colorMap: cMap. |
|
1932 |
image fillRectangleX:0 y:0 width:width height:height with:Color white. |
|
911 | 1933 |
(imageEditView image: image) notNil |
400 | 1934 |
ifTrue: |
1935 |
[ |
|
1936 |
self listOfColors contents: cMap. |
|
1937 |
self findColorMapMode. |
|
694 | 1938 |
self updateLabelsAndHistory |
400 | 1939 |
] |
767 | 1940 |
] |
929 | 1941 |
! |
1942 |
||
1943 |
grabScreenImage |
|
1944 |
"let user choose an area and grab that are for editing" |
|
1945 |
||
1946 |
|image img| |
|
1947 |
||
1948 |
image := Image fromUser. |
|
1949 |
||
1950 |
image depth > 8 ifTrue:[ |
|
1951 |
image := Depth8Image fromImage:image. |
|
1952 |
]. |
|
1953 |
(imageEditView image: image) notNil |
|
1954 |
ifTrue: |
|
1955 |
[ |
|
1956 |
self listOfColors contents:(image colorMap). |
|
1957 |
self findColorMapMode. |
|
1958 |
self updateLabelsAndHistory |
|
1959 |
] |
|
1960 |
||
1961 |
"Created: / 29.7.1998 / 21:24:42 / cg" |
|
400 | 1962 |
! ! |
1963 |
||
1964 |
!ImageEditor methodsFor:'user actions - saving'! |
|
1965 |
||
767 | 1966 |
doPrint |
1967 |
"prints current image on the current printer" |
|
400 | 1968 |
|
911 | 1969 |
imageEditView print |
400 | 1970 |
! |
1971 |
||
767 | 1972 |
doSaveImageFile |
1973 |
"saves current image to current file" |
|
400 | 1974 |
|
911 | 1975 |
imageEditView save |
400 | 1976 |
! |
1977 |
||
767 | 1978 |
doSaveImageFileAs |
1979 |
"opens a dialog for saving current image to a file" |
|
400 | 1980 |
|
911 | 1981 |
imageEditView saveImageFileAs. |
694 | 1982 |
self updateLabelsAndHistory |
400 | 1983 |
! |
1984 |
||
767 | 1985 |
doSaveImageMaskFileAs |
1986 |
"opens a dialog for saving mask of current image to a file" |
|
400 | 1987 |
|
911 | 1988 |
imageEditView saveImageMaskFileAs |
400 | 1989 |
! |
1990 |
||
767 | 1991 |
doSaveMethod |
1992 |
"saves current image on current class and selector" |
|
400 | 1993 |
|
911 | 1994 |
imageEditView saveMethod notNil |
400 | 1995 |
ifTrue: |
1996 |
[ |
|
694 | 1997 |
self updateLabelsAndHistory |
400 | 1998 |
] |
1999 |
! |
|
2000 |
||
767 | 2001 |
doSaveMethodAs |
2002 |
"opens a dialog for saving current image on a class and a selector" |
|
400 | 2003 |
|
911 | 2004 |
imageEditView saveMethodAs notNil |
400 | 2005 |
ifTrue: |
2006 |
[ |
|
694 | 2007 |
self updateLabelsAndHistory |
400 | 2008 |
] |
2009 |
! ! |
|
2010 |
||
2011 |
!ImageEditor class methodsFor:'documentation'! |
|
2012 |
||
2013 |
version |
|
2014 |
^ '$Header$' |
|
2015 |
! ! |