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