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