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