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