author | Claus Gittinger <cg@exept.de> |
Tue, 18 Aug 1998 18:19:58 +0200 | |
changeset 960 | 6196f12b97f6 |
parent 958 | 14088f998b72 |
child 975 | ede3746e0dea |
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 |
|
941 | 42 |
ImageEditor openOnClass:Icon andSelector:#startIcon |
400 | 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' |
951
457d94e33e93
fixed layout (change with framedBox - sigh)
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
368 |
#layout: #(#LayoutFrame 216 0 173 0 516 0 291 0) |
672 | 369 |
#label: 'New Image' |
370 |
#min: #(#Point 10 10) |
|
371 |
#max: #(#Point 1152 900) |
|
951
457d94e33e93
fixed layout (change with framedBox - sigh)
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
372 |
#bounds: #(#Rectangle 216 173 517 292) |
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' |
951
457d94e33e93
fixed layout (change with framedBox - sigh)
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
395 |
#layout: #(#LayoutFrame -8 0.0 13 0.0 89 0.0 36 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' |
951
457d94e33e93
fixed layout (change with framedBox - sigh)
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
415 |
#layout: #(#LayoutFrame -4 0.0 12 0.0 144 0.0 35 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 |
|
951
457d94e33e93
fixed layout (change with framedBox - sigh)
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
440 |
"Modified: / 13.8.1998 / 19:56:22 / 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' |
|
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
464 |
#layout: #(#LayoutFrame 176 0 156 0 675 0 501 0) |
767 | 465 |
#label: 'Image Editor' |
466 |
#min: #(#Point 400 320) |
|
467 |
#max: #(#Point 1152 900) |
|
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
468 |
#bounds: #(#Rectangle 176 156 676 502) |
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 |
|
942 | 537 |
#columnAlignment: #right |
538 |
#editorType: #InputField |
|
539 |
#type: #number |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
540 |
#model: #redFromColor: |
942 | 541 |
#writeSelector: #redAtColor:put: |
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
542 |
#selectSelector: #canSelectRedInColor: |
767 | 543 |
) |
544 |
#(#DataSetColumnSpec |
|
545 |
#label: 'G' |
|
546 |
#labelAlignment: #left |
|
942 | 547 |
#columnAlignment: #right |
548 |
#editorType: #InputField |
|
549 |
#type: #number |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
550 |
#model: #greenFromColor: |
942 | 551 |
#writeSelector: #greenAtColor:put: |
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
552 |
#selectSelector: #canSelectGreenInColor: |
767 | 553 |
) |
554 |
#(#DataSetColumnSpec |
|
555 |
#label: 'B' |
|
556 |
#labelAlignment: #left |
|
942 | 557 |
#columnAlignment: #right |
558 |
#editorType: #InputField |
|
559 |
#type: #number |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
560 |
#model: #blueFromColor: |
942 | 561 |
#writeSelector: #blueAtColor:put: |
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
562 |
#selectSelector: #canSelectBlueInColor: |
767 | 563 |
) |
564 |
) |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
565 |
#columnAdaptor: #colorColumnAdaptor |
767 | 566 |
) |
567 |
) |
|
568 |
) |
|
569 |
) |
|
570 |
#(#ArbitraryComponentSpec |
|
571 |
#name: 'imagePreView' |
|
572 |
#activeHelpKey: #previewView |
|
573 |
#hasHorizontalScrollBar: true |
|
574 |
#hasVerticalScrollBar: true |
|
575 |
#miniScrollerHorizontal: true |
|
576 |
#miniScrollerVertical: true |
|
577 |
#component: #ImageView |
|
578 |
#hasBorder: false |
|
579 |
) |
|
580 |
) |
|
581 |
) |
|
582 |
#handles: #(#Any 0.723776 1.0) |
|
583 |
) |
|
584 |
) |
|
585 |
) |
|
586 |
) |
|
587 |
#(#ViewSpec |
|
588 |
#name: 'view2' |
|
589 |
#component: |
|
590 |
#(#SpecCollection |
|
591 |
#collection: |
|
592 |
#( |
|
593 |
#(#ArbitraryComponentSpec |
|
594 |
#name: 'imageEditView' |
|
595 |
#layout: #(#LayoutFrame 2 0.0 2 0.0 -2 1.0 -24 1.0) |
|
596 |
#hasHorizontalScrollBar: true |
|
597 |
#hasVerticalScrollBar: true |
|
598 |
#component: #ImageEditView |
|
599 |
#hasBorder: false |
|
600 |
) |
|
601 |
#(#LabelSpec |
|
602 |
#name: 'coordLabel' |
|
603 |
#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
|
604 |
#labelChannel: #imageInfoHolder |
767 | 605 |
#level: -1 |
606 |
#adjust: #left |
|
607 |
#resizeForLabel: false |
|
608 |
) |
|
609 |
#(#ArrowButtonSpec |
|
610 |
#name: 'magnifyDownButton' |
|
611 |
#layout: #(#LayoutFrame -80 1 -22 1 -58 1 0 1) |
|
612 |
#activeHelpKey: #magnifyImageDown |
|
613 |
#model: #doMagnifyDown |
|
614 |
#enableChannel: #imageIsLoaded |
|
615 |
#isTriggerOnDown: true |
|
616 |
#direction: #left |
|
617 |
) |
|
618 |
#(#ArrowButtonSpec |
|
619 |
#name: 'magnifyUpButton' |
|
620 |
#layout: #(#LayoutFrame -24 1 -22 1 -2 1 0 1) |
|
621 |
#activeHelpKey: #magnifyImageUp |
|
622 |
#model: #doMagnifyUp |
|
623 |
#enableChannel: #imageIsLoaded |
|
624 |
#isTriggerOnDown: true |
|
625 |
#direction: #right |
|
626 |
) |
|
627 |
#(#InputFieldSpec |
|
628 |
#name: 'magnificationInputField' |
|
629 |
#layout: #(#LayoutFrame -57 1 -22 1 -26 1 0 1) |
|
630 |
#activeHelpKey: #magnificationNumber |
|
631 |
#enableChannel: #imageIsLoaded |
|
632 |
#model: #valueOfMagnification |
|
905 | 633 |
#type: #numberInRange |
767 | 634 |
#acceptOnReturn: false |
635 |
#acceptOnTab: false |
|
636 |
#numChars: 2 |
|
905 | 637 |
#minValue: 1 |
638 |
#maxValue: 99 |
|
767 | 639 |
) |
640 |
) |
|
641 |
) |
|
642 |
#level: -1 |
|
643 |
) |
|
644 |
) |
|
645 |
) |
|
646 |
#handles: #(#Any 0.276 1.0) |
|
647 |
) |
|
648 |
#(#UISubSpecification |
|
649 |
#name: 'infoBarSubSpec' |
|
650 |
#layout: #(#LayoutFrame 0 0.0 -24 1 0 1.0 0 1.0) |
|
651 |
#majorKey: #ToolApplicationModel |
|
652 |
#minorKey: #windowSpecForInfoBar |
|
653 |
) |
|
654 |
) |
|
655 |
) |
|
656 |
) |
|
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
657 |
|
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
658 |
"Modified: / 7.8.1998 / 22:52:28 / cg" |
519 | 659 |
! ! |
660 |
||
661 |
!ImageEditor class methodsFor:'menu specs'! |
|
662 |
||
400 | 663 |
menu |
737 | 664 |
"This resource specification was automatically generated |
665 |
by the MenuEditor of ST/X." |
|
400 | 666 |
|
737 | 667 |
"Do not manually edit this!! If it is corrupted, |
668 |
the MenuEditor may not be able to read the specification." |
|
400 | 669 |
|
670 |
" |
|
671 |
MenuEditor new openOnClass:ImageEditor andSelector:#menu |
|
672 |
(Menu new fromLiteralArrayEncoding:(ImageEditor menu)) startUp |
|
673 |
" |
|
674 |
||
675 |
<resource: #menu> |
|
676 |
||
677 |
^ |
|
678 |
||
679 |
#(#Menu |
|
680 |
||
681 |
#( |
|
682 |
#(#MenuItem |
|
672 | 683 |
#label: 'About' |
843 | 684 |
#translateLabel: true |
672 | 685 |
#activeHelpKey: #about |
686 |
#labelImage: #(#ResourceRetriever nil #menuIcon) |
|
687 |
#submenuChannel: #menuAbout |
|
400 | 688 |
) |
689 |
#(#MenuItem |
|
672 | 690 |
#label: 'File' |
691 |
#translateLabel: true |
|
692 |
#activeHelpKey: #file |
|
693 |
#submenu: |
|
400 | 694 |
#(#Menu |
695 |
||
696 |
#( |
|
697 |
#(#MenuItem |
|
672 | 698 |
#label: 'New...' |
843 | 699 |
#translateLabel: true |
767 | 700 |
#value: #doNewImage |
672 | 701 |
#activeHelpKey: #fileNewImage |
400 | 702 |
) |
703 |
#(#MenuItem |
|
672 | 704 |
#label: '-' |
400 | 705 |
) |
706 |
#(#MenuItem |
|
672 | 707 |
#label: 'Load...' |
843 | 708 |
#translateLabel: true |
767 | 709 |
#value: #doLoadFromClass |
672 | 710 |
#activeHelpKey: #fileLoadFromClass |
400 | 711 |
) |
712 |
#(#MenuItem |
|
672 | 713 |
#label: 'Load From File...' |
843 | 714 |
#translateLabel: true |
767 | 715 |
#value: #doLoadFromFile |
672 | 716 |
#activeHelpKey: #fileLoadFromFile |
400 | 717 |
) |
718 |
#(#MenuItem |
|
929 | 719 |
#label: 'Grab From Screen' |
720 |
#translateLabel: true |
|
721 |
#value: #grabScreenImage |
|
722 |
#activeHelpKey: #fileGrabImage |
|
723 |
) |
|
724 |
#(#MenuItem |
|
672 | 725 |
#label: '-' |
400 | 726 |
) |
727 |
#(#MenuItem |
|
672 | 728 |
#label: 'Save' |
843 | 729 |
#translateLabel: true |
767 | 730 |
#value: #doSaveMethod |
672 | 731 |
#activeHelpKey: #fileSaveMethod |
933
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
732 |
#enabled: #imageIsLoadedAndClassDefined |
400 | 733 |
) |
734 |
#(#MenuItem |
|
672 | 735 |
#label: 'Save As...' |
843 | 736 |
#translateLabel: true |
767 | 737 |
#value: #doSaveMethodAs |
672 | 738 |
#activeHelpKey: #fileSaveMethodAs |
739 |
#enabled: #imageIsLoaded |
|
740 |
) |
|
741 |
#(#MenuItem |
|
742 |
#label: '-' |
|
400 | 743 |
) |
744 |
#(#MenuItem |
|
672 | 745 |
#label: 'Save To File...' |
843 | 746 |
#translateLabel: true |
767 | 747 |
#value: #doSaveImageFileAs |
672 | 748 |
#activeHelpKey: #fileSaveAs |
749 |
#enabled: #imageIsLoaded |
|
400 | 750 |
) |
751 |
#(#MenuItem |
|
672 | 752 |
#label: 'Save Mask To File...' |
843 | 753 |
#translateLabel: true |
767 | 754 |
#value: #doSaveImageMaskFileAs |
672 | 755 |
#activeHelpKey: #fileSaveMaskAs |
756 |
#enabled: #imageIsLoaded |
|
400 | 757 |
) |
758 |
#(#MenuItem |
|
672 | 759 |
#label: '-' |
400 | 760 |
) |
761 |
#(#MenuItem |
|
672 | 762 |
#label: 'Print' |
843 | 763 |
#translateLabel: true |
767 | 764 |
#value: #doPrint |
672 | 765 |
#activeHelpKey: #filePrint |
766 |
#enabled: #imageIsLoaded |
|
400 | 767 |
) |
768 |
#(#MenuItem |
|
672 | 769 |
#label: '-' |
400 | 770 |
) |
771 |
#(#MenuItem |
|
672 | 772 |
#label: 'Browse Class' |
843 | 773 |
#translateLabel: true |
767 | 774 |
#value: #doBrowseClass |
672 | 775 |
#activeHelpKey: #fileBrowseClass |
933
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
776 |
#enabled: #hasClassDefined |
400 | 777 |
) |
778 |
#(#MenuItem |
|
672 | 779 |
#label: '-' |
400 | 780 |
) |
781 |
#(#MenuItem |
|
672 | 782 |
#label: 'Exit' |
783 |
#translateLabel: true |
|
784 |
#value: #closeRequest |
|
785 |
#activeHelpKey: #fileExit |
|
400 | 786 |
) |
787 |
) nil |
|
788 |
nil |
|
789 |
) |
|
790 |
) |
|
791 |
#(#MenuItem |
|
672 | 792 |
#label: 'Edit' |
843 | 793 |
#translateLabel: true |
672 | 794 |
#activeHelpKey: #edit |
795 |
#enabled: #imageIsLoaded |
|
796 |
#submenu: |
|
400 | 797 |
#(#Menu |
798 |
||
799 |
#( |
|
800 |
#(#MenuItem |
|
672 | 801 |
#label: 'Undo' |
843 | 802 |
#translateLabel: true |
767 | 803 |
#value: #doUndo |
672 | 804 |
#activeHelpKey: #editUndo |
805 |
#enabled: #valueOfCanUndo |
|
400 | 806 |
) |
807 |
#(#MenuItem |
|
672 | 808 |
#label: '-' |
400 | 809 |
) |
810 |
#(#MenuItem |
|
672 | 811 |
#label: 'Flip - Vertical' |
843 | 812 |
#translateLabel: true |
767 | 813 |
#value: #doFlipVertical |
672 | 814 |
#activeHelpKey: #editFlipVertical |
400 | 815 |
) |
816 |
#(#MenuItem |
|
672 | 817 |
#label: 'Flip - Horizontal' |
843 | 818 |
#translateLabel: true |
767 | 819 |
#value: #doFlipHorizontal |
672 | 820 |
#activeHelpKey: #editFlipHorizontal |
400 | 821 |
) |
822 |
#(#MenuItem |
|
672 | 823 |
#label: '-' |
400 | 824 |
) |
825 |
#(#MenuItem |
|
672 | 826 |
#label: 'Resize...' |
843 | 827 |
#translateLabel: true |
767 | 828 |
#value: #doResizeImage |
672 | 829 |
#activeHelpKey: #editResize |
400 | 830 |
) |
831 |
#(#MenuItem |
|
672 | 832 |
#label: 'Magnify...' |
843 | 833 |
#translateLabel: true |
767 | 834 |
#value: #doMagnifyImage |
672 | 835 |
#activeHelpKey: #editMagnifyImage |
400 | 836 |
) |
837 |
#(#MenuItem |
|
672 | 838 |
#label: 'Rotate...' |
843 | 839 |
#translateLabel: true |
767 | 840 |
#value: #doRotateImage |
672 | 841 |
#activeHelpKey: #editRotate |
400 | 842 |
) |
843 |
) nil |
|
844 |
nil |
|
845 |
) |
|
846 |
) |
|
847 |
#(#MenuItem |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
848 |
#label: 'ColorMap' |
843 | 849 |
#translateLabel: true |
672 | 850 |
#activeHelpKey: #colorMap |
851 |
#enabled: #imageIsLoaded |
|
852 |
#submenu: |
|
400 | 853 |
#(#Menu |
854 |
||
855 |
#( |
|
856 |
#(#MenuItem |
|
672 | 857 |
#label: '8-Plane' |
843 | 858 |
#translateLabel: true |
929 | 859 |
#activeHelpKey: #colorMap8 |
672 | 860 |
#argument: '8-plane' |
861 |
#indication: #colorMapMode:value: |
|
862 |
) |
|
863 |
#(#MenuItem |
|
864 |
#label: '4-Plane' |
|
843 | 865 |
#translateLabel: true |
929 | 866 |
#activeHelpKey: #colorMap4 |
672 | 867 |
#argument: '4-plane' |
868 |
#indication: #colorMapMode:value: |
|
400 | 869 |
) |
870 |
#(#MenuItem |
|
672 | 871 |
#label: '2-Plane' |
843 | 872 |
#translateLabel: true |
929 | 873 |
#activeHelpKey: #colorMap2 |
672 | 874 |
#argument: '2-plane' |
875 |
#indication: #colorMapMode:value: |
|
400 | 876 |
) |
877 |
#(#MenuItem |
|
672 | 878 |
#label: '1-Plane' |
843 | 879 |
#translateLabel: true |
929 | 880 |
#activeHelpKey: #colorMap1 |
672 | 881 |
#argument: '1-plane' |
882 |
#indication: #colorMapMode:value: |
|
400 | 883 |
) |
884 |
#(#MenuItem |
|
672 | 885 |
#label: '-' |
886 |
) |
|
887 |
#(#MenuItem |
|
888 |
#label: '8-Plane + Mask' |
|
843 | 889 |
#translateLabel: true |
929 | 890 |
#activeHelpKey: #colorMap8M |
672 | 891 |
#argument: '8-plane + mask' |
892 |
#indication: #colorMapMode:value: |
|
400 | 893 |
) |
894 |
#(#MenuItem |
|
672 | 895 |
#label: '4-Plane + Mask' |
843 | 896 |
#translateLabel: true |
929 | 897 |
#activeHelpKey: #colorMap4M |
672 | 898 |
#argument: '4-plane + mask' |
899 |
#indication: #colorMapMode:value: |
|
400 | 900 |
) |
901 |
#(#MenuItem |
|
672 | 902 |
#label: '2-Plane + Mask' |
843 | 903 |
#translateLabel: true |
929 | 904 |
#activeHelpKey: #colorMap2M |
672 | 905 |
#argument: '2-plane + mask' |
906 |
#indication: #colorMapMode:value: |
|
907 |
) |
|
908 |
#(#MenuItem |
|
909 |
#label: '1-Plane + Mask' |
|
843 | 910 |
#translateLabel: true |
929 | 911 |
#activeHelpKey: #colorMap1M |
672 | 912 |
#argument: '1-plane + mask' |
913 |
#indication: #colorMapMode:value: |
|
400 | 914 |
) |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
915 |
#(#MenuItem |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
916 |
#label: '-' |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
917 |
) |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
918 |
#(#MenuItem |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
919 |
#label: 'Compress colormap' |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
920 |
#translateLabel: true |
933
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
921 |
#value: #compressColorMap |
929 | 922 |
#activeHelpKey: #compressColormap |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
923 |
) |
400 | 924 |
) nil |
925 |
nil |
|
926 |
) |
|
927 |
) |
|
928 |
#(#MenuItem |
|
737 | 929 |
#label: 'Settings' |
843 | 930 |
#translateLabel: true |
737 | 931 |
#submenu: |
932 |
#(#Menu |
|
933 |
||
934 |
#( |
|
935 |
#(#MenuItem |
|
905 | 936 |
#label: 'Grid Magnification...' |
937 |
#translateLabel: true |
|
938 |
#value: #doChangeGridMagnification |
|
939 |
#activeHelpKey: #settingsGridMagnification |
|
940 |
) |
|
941 |
#(#MenuItem |
|
942 |
#label: '-' |
|
943 |
) |
|
944 |
#(#MenuItem |
|
737 | 945 |
#label: 'Fonts' |
843 | 946 |
#translateLabel: true |
737 | 947 |
#submenuChannel: #menuFont |
948 |
) |
|
949 |
) nil |
|
950 |
nil |
|
951 |
) |
|
952 |
) |
|
953 |
#(#MenuItem |
|
756 | 954 |
#label: 'History' |
843 | 955 |
#translateLabel: true |
756 | 956 |
#activeHelpKey: #history |
957 |
#submenuChannel: #menuHistory |
|
958 |
) |
|
959 |
#(#MenuItem |
|
672 | 960 |
#label: 'Help' |
843 | 961 |
#translateLabel: true |
672 | 962 |
#startGroup: #right |
963 |
#activeHelpKey: #help |
|
964 |
#submenuChannel: #menuHelp |
|
400 | 965 |
) |
966 |
) nil |
|
967 |
nil |
|
968 |
) |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
969 |
|
933
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
970 |
"Modified: / 31.7.1998 / 02:04:49 / cg" |
400 | 971 |
! |
972 |
||
679 | 973 |
menuMouseButtonColors |
737 | 974 |
"This resource specification was automatically generated |
975 |
by the MenuEditor of ST/X." |
|
679 | 976 |
|
737 | 977 |
"Do not manually edit this!! If it is corrupted, |
978 |
the MenuEditor may not be able to read the specification." |
|
679 | 979 |
|
980 |
" |
|
981 |
MenuEditor new openOnClass:ImageEditor andSelector:#menuMouseButtonColors |
|
982 |
(Menu new fromLiteralArrayEncoding:(ImageEditor menuMouseButtonColors)) startUp |
|
983 |
" |
|
984 |
||
985 |
<resource: #menu> |
|
986 |
||
987 |
^ |
|
988 |
||
989 |
#(#Menu |
|
990 |
||
991 |
#( |
|
992 |
#(#MenuItem |
|
993 |
#label: 'Left Mouse Button' |
|
994 |
#nameKey: #leftMouseKeyButton |
|
995 |
#activeHelpKey: #mouseKeyColorMode |
|
996 |
#argument: '1' |
|
997 |
#labelImage: #(#ResourceRetriever nil #leftMouseKeyIcon) |
|
998 |
#indication: #mouseKeyColorMode:value: |
|
999 |
) |
|
1000 |
#(#MenuItem |
|
1001 |
#label: 'Right Mouse Button' |
|
1002 |
#nameKey: #rightMouseKeyButton |
|
1003 |
#activeHelpKey: #mouseKeyColorMode |
|
1004 |
#argument: '2' |
|
1005 |
#labelImage: #(#ResourceRetriever nil #rightMouseKeyIcon) |
|
1006 |
#indication: #mouseKeyColorMode:value: |
|
1007 |
) |
|
1008 |
) nil |
|
1009 |
nil |
|
1010 |
) |
|
1011 |
! |
|
1012 |
||
400 | 1013 |
menuToolbar |
737 | 1014 |
"This resource specification was automatically generated |
1015 |
by the MenuEditor of ST/X." |
|
400 | 1016 |
|
737 | 1017 |
"Do not manually edit this!! If it is corrupted, |
1018 |
the MenuEditor may not be able to read the specification." |
|
400 | 1019 |
|
1020 |
" |
|
1021 |
MenuEditor new openOnClass:ImageEditor andSelector:#menuToolbar |
|
1022 |
(Menu new fromLiteralArrayEncoding:(ImageEditor menuToolbar)) startUp |
|
1023 |
" |
|
1024 |
||
1025 |
<resource: #menu> |
|
1026 |
||
1027 |
^ |
|
1028 |
||
1029 |
#(#Menu |
|
1030 |
||
1031 |
#( |
|
1032 |
#(#MenuItem |
|
672 | 1033 |
#label: 'newImage' |
1034 |
#isButton: true |
|
767 | 1035 |
#value: #doNewImage |
672 | 1036 |
#activeHelpKey: #fileNewImage |
880 | 1037 |
#labelImage: #(#ResourceRetriever #Icon #newIcon) |
400 | 1038 |
) |
1039 |
#(#MenuItem |
|
672 | 1040 |
#label: 'loadFromClass' |
1041 |
#isButton: true |
|
767 | 1042 |
#value: #doLoadFromClass |
672 | 1043 |
#activeHelpKey: #fileLoadFromClass |
880 | 1044 |
#labelImage: #(#ResourceRetriever #Icon #loadIcon) |
672 | 1045 |
) |
1046 |
#(#MenuItem |
|
1047 |
#label: 'saveMethod' |
|
1048 |
#isButton: true |
|
767 | 1049 |
#value: #doSaveMethod |
672 | 1050 |
#activeHelpKey: #fileSaveMethod |
1051 |
#enabled: #imageIsLoaded |
|
880 | 1052 |
#labelImage: #(#ResourceRetriever #Icon #saveIcon) |
400 | 1053 |
) |
1054 |
#(#MenuItem |
|
672 | 1055 |
#label: '' |
400 | 1056 |
) |
1057 |
#(#MenuItem |
|
672 | 1058 |
#label: '' |
1059 |
) |
|
1060 |
#(#MenuItem |
|
1061 |
#label: '' |
|
1062 |
) |
|
1063 |
#(#MenuItem |
|
1064 |
#label: '' |
|
400 | 1065 |
) |
1066 |
#(#MenuItem |
|
672 | 1067 |
#label: 'Point' |
1068 |
#activeHelpKey: #drawModePoint |
|
1069 |
#enabled: #imageIsLoaded |
|
1070 |
#argument: 'point' |
|
1071 |
#indication: #editMode:value: |
|
400 | 1072 |
) |
1073 |
#(#MenuItem |
|
672 | 1074 |
#label: 'Box' |
1075 |
#activeHelpKey: #drawModeBox |
|
1076 |
#enabled: #imageIsLoaded |
|
1077 |
#argument: 'box' |
|
1078 |
#indication: #editMode:value: |
|
400 | 1079 |
) |
1080 |
#(#MenuItem |
|
672 | 1081 |
#label: 'Filled Box' |
1082 |
#activeHelpKey: #drawModeFilledBox |
|
1083 |
#enabled: #imageIsLoaded |
|
1084 |
#argument: 'filledBox' |
|
1085 |
#indication: #editMode:value: |
|
400 | 1086 |
) |
1087 |
#(#MenuItem |
|
672 | 1088 |
#label: 'Fill' |
1089 |
#activeHelpKey: #drawModeFill |
|
1090 |
#enabled: #imageIsLoaded |
|
1091 |
#argument: 'fill' |
|
1092 |
#indication: #editMode:value: |
|
400 | 1093 |
) |
1094 |
#(#MenuItem |
|
672 | 1095 |
#label: 'Copy' |
1096 |
#activeHelpKey: #drawModeCopy |
|
1097 |
#enabled: #imageIsLoaded |
|
1098 |
#argument: 'copy' |
|
1099 |
#indication: #editMode:value: |
|
400 | 1100 |
) |
1101 |
#(#MenuItem |
|
672 | 1102 |
#label: 'Paste' |
1103 |
#activeHelpKey: #drawModePaste |
|
1104 |
#enabled: #imageIsLoaded |
|
1105 |
#argument: 'paste' |
|
1106 |
#indication: #editMode:value: |
|
400 | 1107 |
) |
914 | 1108 |
#(#MenuItem |
1109 |
#label: 'Paste Under' |
|
1110 |
#activeHelpKey: #drawModePasteUnder |
|
1111 |
#enabled: #imageIsLoaded |
|
1112 |
#argument: 'pasteUnder' |
|
1113 |
#indication: #editMode:value: |
|
1114 |
) |
|
400 | 1115 |
) nil |
1116 |
nil |
|
1117 |
) |
|
1118 |
! ! |
|
1119 |
||
1120 |
!ImageEditor methodsFor:'accessing'! |
|
1121 |
||
1122 |
image |
|
767 | 1123 |
"returns the current editing image" |
400 | 1124 |
|
911 | 1125 |
^imageEditView image |
400 | 1126 |
! |
1127 |
||
1128 |
postOpenAction: anAction |
|
767 | 1129 |
"sets an action which is evaluated after opening" |
400 | 1130 |
|
1131 |
postOpenAction := anAction |
|
1132 |
! ! |
|
1133 |
||
1134 |
!ImageEditor methodsFor:'accessing - views'! |
|
1135 |
||
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1136 |
colorDataSetView |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1137 |
"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
|
1138 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1139 |
^(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
|
1140 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1141 |
"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
|
1142 |
! |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1143 |
|
487 | 1144 |
coordLabel |
767 | 1145 |
"returns the view the coord label" |
487 | 1146 |
|
1147 |
^builder componentAt: #coordLabel |
|
1148 |
! |
|
1149 |
||
400 | 1150 |
imageEditView |
911 | 1151 |
"returns the view of the image" |
400 | 1152 |
|
911 | 1153 |
^imageEditView := (builder componentAt: #imageEditView) subViews first |
400 | 1154 |
! |
1155 |
||
1156 |
imagePreView |
|
767 | 1157 |
"returns the preview of the image" |
400 | 1158 |
|
1159 |
^(builder componentAt: #imagePreView) subViews first |
|
475 | 1160 |
! ! |
1161 |
||
400 | 1162 |
!ImageEditor methodsFor:'aspects'! |
1163 |
||
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1164 |
activityInfoHolder |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1165 |
^ self valueOfInfoLabel |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1166 |
|
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1167 |
"Modified: / 29.7.1998 / 18:49:03 / cg" |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1168 |
! |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1169 |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1170 |
colorColumnAdaptor |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1171 |
^ self |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1172 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1173 |
"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
|
1174 |
! |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1175 |
|
933
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1176 |
hasClassAndSelectorDefined |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1177 |
^ [(Smalltalk at:(imageEditView resourceClass) ifAbsent:nil) notNil |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1178 |
and:[imageEditView resourceSelector notNil]] |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1179 |
|
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1180 |
"Created: / 31.7.1998 / 02:02:54 / cg" |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1181 |
! |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1182 |
|
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1183 |
hasClassDefined |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1184 |
^ [(Smalltalk at:(imageEditView resourceClass) ifAbsent:nil) notNil] |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1185 |
|
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1186 |
"Created: / 31.7.1998 / 02:02:22 / cg" |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1187 |
! |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1188 |
|
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1189 |
imageInfoHolder |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1190 |
|holder| |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1191 |
(holder := builder bindingAt:#imageInfoHolder) isNil ifTrue:[ |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1192 |
builder aspectAt:#imageInfoHolder put:(holder := '' asValue). |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1193 |
]. |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1194 |
^ holder |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1195 |
|
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1196 |
"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
|
1197 |
! |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1198 |
|
400 | 1199 |
imageIsLoaded |
767 | 1200 |
"returns whether an image is loaded as value holder" |
400 | 1201 |
|
1202 |
|holder| |
|
1203 |
(holder := builder bindingAt:#imageIsLoaded) isNil ifTrue:[ |
|
1204 |
builder aspectAt:#imageIsLoaded put:(holder := false asValue). |
|
1205 |
]. |
|
1206 |
^ holder |
|
1207 |
! |
|
1208 |
||
933
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1209 |
imageIsLoadedAndClassDefined |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1210 |
"returns whether an image is loaded as value holder" |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1211 |
|
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1212 |
^ [self hasClassAndSelectorDefined value |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1213 |
and:[self imageIsLoaded value]] |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1214 |
|
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1215 |
"Created: / 31.7.1998 / 02:04:18 / cg" |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1216 |
! |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1217 |
|
400 | 1218 |
listOfColors |
767 | 1219 |
"returns the list of colors in a List" |
400 | 1220 |
|
1221 |
|holder| |
|
1222 |
(holder := builder bindingAt:#listOfColors) isNil ifTrue:[ |
|
1223 |
builder aspectAt:#listOfColors put:(holder := List new). |
|
942 | 1224 |
holder addDependent:self. |
400 | 1225 |
]. |
1226 |
^ holder |
|
1227 |
! |
|
1228 |
||
1229 |
selectionOfColor |
|
767 | 1230 |
"returns current selection of the edit color as an AspectAdaptor" |
400 | 1231 |
|
1232 |
|holder| |
|
1233 |
(holder := builder bindingAt:#selectionOfColor) isNil ifTrue:[ |
|
1234 |
builder aspectAt:#selectionOfColor put:( |
|
1235 |
holder := AspectAdaptor new subject:self; forAspect:#selectedColorIndex). |
|
1236 |
]. |
|
1237 |
^ holder |
|
1238 |
! |
|
1239 |
||
1240 |
valueOfMagnification |
|
767 | 1241 |
"returns current magnification of the image as an AspectAdaptor" |
400 | 1242 |
|
1243 |
|holder| |
|
1244 |
(holder := builder bindingAt:#valueOfMagnification) isNil ifTrue:[ |
|
1245 |
builder aspectAt:#valueOfMagnification put:( |
|
1246 |
holder := AspectAdaptor new subject:self; forAspect:#magnification) |
|
1247 |
]. |
|
1248 |
^ holder |
|
1249 |
! ! |
|
1250 |
||
767 | 1251 |
!ImageEditor methodsFor:'change & update'! |
1252 |
||
1253 |
findColorMapMode |
|
899 | 1254 |
"finds the colorMapMode for a new image" |
767 | 1255 |
|
1256 |
self image depth > 8 ifTrue: [colorMapMode := ''. self listOfColors removeAll. ^nil]. |
|
1257 |
colorMapMode := self image depth printString, '-plane'. |
|
1258 |
self listOfColors isEmpty |
|
1259 |
ifTrue: |
|
1260 |
[ |
|
1261 |
self colorMapMode: colorMapMode value: nil |
|
1262 |
]. |
|
911 | 1263 |
imageEditView selectColors: (Array with: (self listOfColors at: 1) with: (self listOfColors at: 2 ifAbsent: [self listOfColors at: 1])). |
898 | 1264 |
|
1265 |
self image mask notNil |
|
767 | 1266 |
ifTrue: |
1267 |
[ |
|
1268 |
colorMapMode := colorMapMode, ' + mask'. |
|
898 | 1269 |
(self listOfColors detect: [:clr| clr = (Color basicNew setColorId:0)] ifNone: nil) isNil |
1270 |
ifTrue: |
|
1271 |
[ |
|
1272 |
self listOfColors addFirst: (Color basicNew setColorId:0). |
|
911 | 1273 |
imageEditView selectColors: (Array with: (self listOfColors at: 2 ifAbsent: [self listOfColors at: 1]) with: (self listOfColors at: 1)). |
898 | 1274 |
] |
767 | 1275 |
]. |
1276 |
self selectionOfColor value: 0. |
|
911 | 1277 |
self selectionOfColor value: (self listOfColors indexOf: imageEditView selectedColor). |
767 | 1278 |
! |
1279 |
||
942 | 1280 |
update:something with:aParameter from:changedObject |
960 | 1281 |
|clrIndex| |
1282 |
||
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1283 |
changedObject == self listOfColors ifTrue:[ |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1284 |
something == #at: ifTrue:[ |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1285 |
"/ colormap entry changed at aParameter |
960 | 1286 |
|
1287 |
clrIndex := aParameter. |
|
1288 |
(self hasMask) ifTrue:[ |
|
1289 |
clrIndex := clrIndex - 1. |
|
1290 |
]. |
|
1291 |
||
1292 |
self image colorMap at:clrIndex put:(changedObject at:aParameter). |
|
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1293 |
self colorMapChanged. |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1294 |
^ self |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1295 |
]. |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1296 |
]. |
942 | 1297 |
super update:something with:aParameter from:changedObject |
1298 |
||
960 | 1299 |
"Modified: / 18.8.1998 / 17:18:42 / cg" |
942 | 1300 |
! |
1301 |
||
767 | 1302 |
updateForNoneImage |
1303 |
"updates channels and view, if image is loaded" |
|
1304 |
||
1305 |
self imageIsLoaded value: false. |
|
1306 |
self listOfColors removeAll. |
|
1307 |
self imagePreView image: nil |
|
1308 |
||
1309 |
||
1310 |
||
1311 |
||
1312 |
! |
|
1313 |
||
1314 |
updateLabelsAndHistory |
|
1315 |
"updates labels and history, if something has changed" |
|
1316 |
||
1317 |
self imageIsLoaded value: self image notNil. |
|
1318 |
||
1319 |
self image isNil ifTrue: [^nil]. |
|
1320 |
||
1321 |
self updateInfoLabel. |
|
1322 |
||
911 | 1323 |
imageEditView resourceMessage asCollectionOfWords size = 2 |
1324 |
ifTrue: [self addToHistory: imageEditView resourceMessage -> #loadFromMessage:]. |
|
767 | 1325 |
|
1326 |
self image fileName notNil |
|
1327 |
ifTrue: [self addToHistory: self image fileName -> #loadFromFile:]. |
|
1328 |
||
1329 |
||
1330 |
||
1331 |
! ! |
|
1332 |
||
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1333 |
!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
|
1334 |
|
942 | 1335 |
blueAtColor:aColor put:newBlue |
1336 |
"helper used to return a new row element, when blue is changed" |
|
1337 |
||
1338 |
|byte| |
|
1339 |
||
1340 |
aColor isNil ifTrue:[^ aColor]. "/ mask cannot be changed |
|
1341 |
byte := newBlue clampBetween:0 and:255. |
|
960 | 1342 |
byte = aColor blueByte ifTrue:[^ aColor]. |
942 | 1343 |
^ Color redByte:(aColor redByte) greenByte:(aColor greenByte) blueByte:byte |
960 | 1344 |
|
1345 |
"Modified: / 18.8.1998 / 17:00:12 / cg" |
|
942 | 1346 |
! |
1347 |
||
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1348 |
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
|
1349 |
"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
|
1350 |
|
930 | 1351 |
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
|
1352 |
^ 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
|
1353 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1354 |
"Created: / 26.7.1998 / 12:30:35 / cg" |
930 | 1355 |
"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
|
1356 |
! |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1357 |
|
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1358 |
canSelectBlueInColor:aColor |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1359 |
^ aColor blueByte notNil |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1360 |
|
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1361 |
"Created: / 7.8.1998 / 22:50:34 / cg" |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1362 |
"Modified: / 7.8.1998 / 22:52:57 / cg" |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1363 |
! |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1364 |
|
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1365 |
canSelectGreenInColor:aColor |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1366 |
^ aColor greenByte notNil |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1367 |
|
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1368 |
"Created: / 7.8.1998 / 22:50:22 / cg" |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1369 |
"Modified: / 7.8.1998 / 22:52:46 / cg" |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1370 |
! |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1371 |
|
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1372 |
canSelectRedInColor:aColor |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1373 |
^ aColor redByte notNil |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1374 |
|
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1375 |
"Created: / 7.8.1998 / 22:50:00 / cg" |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1376 |
"Modified: / 7.8.1998 / 22:51:03 / cg" |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1377 |
! |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1378 |
|
942 | 1379 |
greenAtColor:aColor put:newGreen |
1380 |
"helper used to return a new row element, when green is changed" |
|
1381 |
||
1382 |
|byte| |
|
1383 |
||
1384 |
aColor isNil ifTrue:[^ aColor]. "/ mask cannot be changed |
|
1385 |
byte := newGreen clampBetween:0 and:255. |
|
960 | 1386 |
byte = aColor greenByte ifTrue:[^ aColor]. |
942 | 1387 |
^ Color redByte:(aColor redByte) greenByte:byte blueByte:(aColor blueByte) |
960 | 1388 |
|
1389 |
"Modified: / 18.8.1998 / 17:00:38 / cg" |
|
942 | 1390 |
! |
1391 |
||
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1392 |
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
|
1393 |
"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
|
1394 |
|
930 | 1395 |
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
|
1396 |
^ 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
|
1397 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1398 |
"Created: / 26.7.1998 / 12:30:29 / cg" |
930 | 1399 |
"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
|
1400 |
! |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1401 |
|
942 | 1402 |
redAtColor:aColor put:newRed |
1403 |
"helper used to return a new row element, when red is changed" |
|
1404 |
||
1405 |
|byte| |
|
1406 |
||
1407 |
aColor isNil ifTrue:[^ aColor]. "/ mask cannot be changed |
|
1408 |
byte := newRed clampBetween:0 and:255. |
|
960 | 1409 |
byte = aColor redByte ifTrue:[^ aColor]. |
942 | 1410 |
^ Color redByte:byte greenByte:(aColor greenByte) blueByte:(aColor blueByte) |
960 | 1411 |
|
1412 |
"Modified: / 18.8.1998 / 17:00:49 / cg" |
|
942 | 1413 |
! |
1414 |
||
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1415 |
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
|
1416 |
"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
|
1417 |
|
930 | 1418 |
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
|
1419 |
^ 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
|
1420 |
|
930 | 1421 |
"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
|
1422 |
! ! |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1423 |
|
672 | 1424 |
!ImageEditor methodsFor:'help'! |
1425 |
||
1426 |
defaultInfoLabel |
|
767 | 1427 |
"returns the default info label" |
672 | 1428 |
|
911 | 1429 |
(imageEditView resourceClass isSymbol and: [(Smalltalk at: imageEditView resourceClass) isClass]) |
672 | 1430 |
ifTrue: |
1431 |
[ |
|
911 | 1432 |
^imageEditView resourceClass, ' >> ', imageEditView resourceSelector |
672 | 1433 |
]. |
767 | 1434 |
^'No class and selector defined.' |
674 | 1435 |
! |
1436 |
||
702 | 1437 |
openDocumentation |
767 | 1438 |
"opens the documentation file of the Image Editor" |
674 | 1439 |
|
763 | 1440 |
self openHTMLDocument: 'tools/uipainter/ImageEditor.html' |
1441 |
||
672 | 1442 |
! ! |
1443 |
||
767 | 1444 |
!ImageEditor methodsFor:'loading'! |
1445 |
||
1446 |
loadFromFile: aFileName |
|
1447 |
"loads an image from aFileName and sets up color map list and other info labels" |
|
1448 |
||
960 | 1449 |
|img| |
1450 |
||
1451 |
(imageEditView loadFromFile: aFileName) notNil ifTrue:[ |
|
1452 |
(img := self image) notNil ifTrue:[ |
|
1453 |
img colorMap notNil ifTrue:[ |
|
1454 |
self listOfColors contents:(img usedColors asSet asOrderedCollection). |
|
1455 |
] ifFalse:[ |
|
767 | 1456 |
self listOfColors removeAll. |
1457 |
]. |
|
1458 |
self findColorMapMode. |
|
1459 |
self updateLabelsAndHistory. |
|
960 | 1460 |
] ifFalse:[ |
767 | 1461 |
self updateForNoneImage |
1462 |
] |
|
1463 |
] |
|
960 | 1464 |
|
1465 |
"Modified: / 18.8.1998 / 17:03:54 / cg" |
|
767 | 1466 |
! |
1467 |
||
960 | 1468 |
loadFromImage:anImage |
767 | 1469 |
"loads an image from anImage and sets up color map list and other info labels" |
1470 |
||
960 | 1471 |
|img| |
1472 |
||
1473 |
imageEditView image:anImage. |
|
1474 |
(img := self image) notNil ifTrue:[ |
|
1475 |
img colorMap notNil ifTrue:[ |
|
1476 |
self listOfColors contents:(img usedColors asSet asOrderedCollection). |
|
1477 |
] ifFalse:[ |
|
767 | 1478 |
self listOfColors removeAll. |
1479 |
]. |
|
1480 |
self findColorMapMode. |
|
1481 |
self updateLabelsAndHistory. |
|
960 | 1482 |
] ifFalse:[ |
767 | 1483 |
self updateForNoneImage |
1484 |
] |
|
960 | 1485 |
|
1486 |
"Modified: / 18.8.1998 / 17:04:46 / cg" |
|
767 | 1487 |
! |
1488 |
||
1489 |
loadFromMessage: aMessage |
|
1490 |
"loads an image by evaluating aMessage and sets up color map list and other info labels" |
|
1491 |
||
960 | 1492 |
|img| |
1493 |
||
1494 |
(imageEditView loadFromMessage: aMessage) notNil ifTrue:[ |
|
1495 |
(img := self image) notNil ifTrue:[ |
|
1496 |
self listOfColors contents:(img usedColors asSet asOrderedCollection). |
|
767 | 1497 |
self findColorMapMode. |
1498 |
self updateLabelsAndHistory. |
|
960 | 1499 |
] ifFalse:[ |
767 | 1500 |
self updateForNoneImage |
1501 |
] |
|
1502 |
] |
|
960 | 1503 |
|
1504 |
"Modified: / 18.8.1998 / 17:03:01 / cg" |
|
767 | 1505 |
! |
1506 |
||
1507 |
loadFromOrPrepareForMessage: aMessage |
|
1508 |
"loads an image by evaluating aMessage; |
|
1509 |
if no image could extract from aMessage; do set the class and the selector from |
|
1510 |
the aMessage for a saving at the end of editing" |
|
1511 |
||
911 | 1512 |
(imageEditView loadFromMessage: aMessage) notNil |
767 | 1513 |
ifTrue: |
1514 |
[ |
|
1515 |
self listOfColors contents: self image usedColors asSet asOrderedCollection. |
|
1516 |
self findColorMapMode. |
|
1517 |
] |
|
1518 |
ifFalse: |
|
1519 |
[ |
|
911 | 1520 |
imageEditView resourceMessage: aMessage. |
767 | 1521 |
]. |
1522 |
self updateLabelsAndHistory. |
|
1523 |
! ! |
|
1524 |
||
400 | 1525 |
!ImageEditor methodsFor:'menu modes'! |
1526 |
||
1527 |
colorMapMode: aMode |
|
767 | 1528 |
"returns whether colorMapMode is equal to aMode" |
400 | 1529 |
|
1530 |
^colorMapMode = aMode |
|
1531 |
! |
|
1532 |
||
1533 |
editMode: aMode |
|
767 | 1534 |
"returns whether editMode is equal to aMode" |
400 | 1535 |
|
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1536 |
^ imageEditView notNil and:[imageEditView editMode = aMode] |
400 | 1537 |
! |
1538 |
||
1539 |
editMode: aMode value: aValue |
|
767 | 1540 |
"sets the editMode to aMode" |
400 | 1541 |
|
911 | 1542 |
imageEditView editMode: aMode |
400 | 1543 |
! |
1544 |
||
1545 |
mouseKeyColorMode: aMode |
|
767 | 1546 |
"sets the mouseKeyColorMode to aMode" |
400 | 1547 |
|
956 | 1548 |
imageEditView isNil ifTrue:[ |
1549 |
^ true |
|
1550 |
]. |
|
911 | 1551 |
^imageEditView mouseKeyColorMode = aMode |
400 | 1552 |
! |
1553 |
||
1554 |
mouseKeyColorMode: aMode value: aValue |
|
767 | 1555 |
"sets the mouseKeyColorMode to aMode" |
400 | 1556 |
|
911 | 1557 |
imageEditView mouseKeyColorMode: aMode. |
400 | 1558 |
|
911 | 1559 |
self selectionOfColor value: (self listOfColors indexOf: imageEditView selectedColor). |
400 | 1560 |
! ! |
1561 |
||
535 | 1562 |
!ImageEditor methodsFor:'queries'! |
1563 |
||
960 | 1564 |
hasMask |
1565 |
^ colorMapMode notNil and:[colorMapMode endsWith:'mask'] |
|
1566 |
||
1567 |
"Created: / 18.8.1998 / 17:17:38 / cg" |
|
1568 |
! |
|
1569 |
||
535 | 1570 |
preferredExtent |
767 | 1571 |
"returns the preferred extent" |
535 | 1572 |
|
1573 |
^super preferredExtent max: (Screen current width//3)@(Screen current height//3.5) |
|
1574 |
||
1575 |
||
1576 |
! ! |
|
1577 |
||
400 | 1578 |
!ImageEditor methodsFor:'selection'! |
1579 |
||
1580 |
magnification |
|
767 | 1581 |
"returns the magnification of the image" |
400 | 1582 |
|
911 | 1583 |
self imageEditView isNil ifTrue: [^1]. |
1584 |
^imageEditView magnification x |
|
400 | 1585 |
! |
1586 |
||
1587 |
magnification: aValue |
|
767 | 1588 |
"sets the magnification of the image" |
400 | 1589 |
|
905 | 1590 |
|magnification| |
1591 |
magnification := (aValue ? 1) asPoint. |
|
911 | 1592 |
(magnification = imageEditView magnification or: [magnification = (0@0)]) ifTrue: [^nil]. |
1593 |
imageEditView magnification: magnification |
|
400 | 1594 |
! |
1595 |
||
1596 |
selectedColorIndex |
|
767 | 1597 |
"returns the index of the selected color" |
400 | 1598 |
|
1599 |
^selectedColorIndex |
|
1600 |
! |
|
1601 |
||
1602 |
selectedColorIndex: anIndex |
|
767 | 1603 |
"sets the index of the selected color" |
400 | 1604 |
|
1605 |
selectedColorIndex := anIndex. |
|
911 | 1606 |
imageEditView selectedColor: (self listOfColors at: anIndex ifAbsent: [^nil]) |
400 | 1607 |
|
1608 |
! ! |
|
1609 |
||
1610 |
!ImageEditor methodsFor:'startup / release'! |
|
1611 |
||
1612 |
closeRequest |
|
767 | 1613 |
"close request" |
400 | 1614 |
|
911 | 1615 |
imageEditView checkModified ifTrue:[super closeRequest] |
400 | 1616 |
|
1617 |
! |
|
1618 |
||
1619 |
open |
|
767 | 1620 |
"after opening, sets the masterApplication of the imageEditView to self" |
400 | 1621 |
|
1622 |
super open. |
|
444 | 1623 |
|
911 | 1624 |
imageEditView := (builder componentAt: #imageEditView) subViews first. |
1625 |
imageEditView masterApplication: self |
|
400 | 1626 |
! |
1627 |
||
1628 |
postOpenWith:aBuilder |
|
767 | 1629 |
"after opening, sets the masterApplication of the imageEditView to self; |
1630 |
evaluate the postOpenAction" |
|
400 | 1631 |
|
911 | 1632 |
imageEditView masterApplication: self. |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1633 |
imageEditView imageInfoHolder:(self imageInfoHolder). |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1634 |
imageEditView activityInfoHolder:(self activityInfoHolder). |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1635 |
|
400 | 1636 |
postOpenAction notNil ifTrue: [postOpenAction value]. |
1637 |
||
767 | 1638 |
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
|
1639 |
|
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1640 |
"Modified: / 29.7.1998 / 18:49:20 / cg" |
400 | 1641 |
! ! |
1642 |
||
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1643 |
!ImageEditor methodsFor:'user actions - colormap'! |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1644 |
|
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1645 |
colorMapChanged |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1646 |
|img| |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1647 |
|
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1648 |
img := self image. |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1649 |
img release. |
960 | 1650 |
imageEditView invalidate. |
1651 |
self imagePreView invalidate. |
|
1652 |
||
1653 |
"/ (imageEditView image:img) notNil ifTrue:[ |
|
1654 |
"/ self updateLabelsAndHistory. |
|
1655 |
"/ self imagePreView image:img |
|
1656 |
"/ ] |
|
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1657 |
|
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1658 |
"Created: / 7.8.1998 / 22:26:10 / cg" |
960 | 1659 |
"Modified: / 18.8.1998 / 17:08:55 / cg" |
945
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1660 |
! |
cb689f3971ab
allow editing of color values;
Claus Gittinger <cg@exept.de>
parents:
942
diff
changeset
|
1661 |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1662 |
colorMapMode:aMode value: aValue |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1663 |
"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
|
1664 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1665 |
|depth numColors newColorMap newImage |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1666 |
oldImage image newColors realColorMap oldFileName |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1667 |
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
|
1668 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1669 |
self withExecuteCursorDo:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1670 |
oldImage := self image. |
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 |
newColorMap := self class listOfColorMaps at:aMode. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1673 |
depth := (newColorMap size log: 2) asInteger. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1674 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1675 |
useNearest := false. |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1676 |
depth == 1 ifTrue:[ |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1677 |
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
|
1678 |
] ifFalse:[ |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1679 |
quest := 'Keep colormap (or use standard)' |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1680 |
]. |
958 | 1681 |
((colorMapMode == aMode) |
1682 |
or:[self confirm:(resources string:quest)]) ifTrue:[ |
|
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1683 |
"/ keep the colormap |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1684 |
depth > oldImage depth ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1685 |
"/ easy - simply copy the part |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1686 |
numColors := 1 bitShift:oldImage depth. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1687 |
0 to:numColors-1 do:[:pixel | |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1688 |
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
|
1689 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1690 |
] ifFalse:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1691 |
"/ see if all used color fit the new colormap |
920 | 1692 |
usedColors := oldImage usedColors asArray. |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1693 |
usedColors size <= (1 bitShift:depth) ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1694 |
"/ yea - just install them |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1695 |
usedColors keysAndValuesDo:[:idx :clr | |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1696 |
newColorMap at:idx put:clr |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1697 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1698 |
] ifFalse:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1699 |
"/ 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
|
1700 |
oldImage depth ~~ 8 ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1701 |
tmpBits := ByteArray uninitializedNew:(oldImage width*oldImage height). |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1702 |
oldImage bits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1703 |
expandPixels:(oldImage depth) |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1704 |
width:oldImage width |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1705 |
height:oldImage height |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1706 |
into:tmpBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1707 |
mapping:nil. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1708 |
] ifFalse:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1709 |
tmpBits := oldImage bits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1710 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1711 |
usageCounts := tmpBits usageCounts. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1712 |
tmpMap := Array new:usageCounts size. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1713 |
oldImage colorMap asArray keysAndValuesDo:[:i :clr | |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1714 |
tmpMap at:i put:clr |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1715 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1716 |
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
|
1717 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1718 |
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
|
1719 |
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
|
1720 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1721 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1722 |
useNearest := Dialog |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1723 |
confirmWithCancel:(resources |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1724 |
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
|
1725 |
with:usedColors size |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1726 |
with:(1 bitShift:depth)) withCRs |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1727 |
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
|
1728 |
useNearest isNil ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1729 |
^ self "/ cancel |
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 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1732 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1733 |
] ifFalse:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1734 |
"/ standard colormap |
921
a5aca21ea803
also allow nearest-color mode for standard colormap.
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
1735 |
usedColors := oldImage usedColors. |
a5aca21ea803
also allow nearest-color mode for standard colormap.
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
1736 |
(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
|
1737 |
useNearest := Dialog |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1738 |
confirmWithCancel:(resources |
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1739 |
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
|
1740 |
) withCRs |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1741 |
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
|
1742 |
useNearest isNil ifTrue:[ |
a5aca21ea803
also allow nearest-color mode for standard colormap.
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
1743 |
^ self "/ cancel |
a5aca21ea803
also allow nearest-color mode for standard colormap.
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
1744 |
]. |
a5aca21ea803
also allow nearest-color mode for standard colormap.
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
1745 |
]. |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1746 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1747 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1748 |
imageEditView makeUndo. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1749 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1750 |
newImage := (Image implementorForDepth: depth) new. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1751 |
oldFileName := oldImage fileName. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1752 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1753 |
Object errorSignal handle: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1754 |
[:ex| |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1755 |
Object errorSignal handle: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1756 |
[:ex| |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1757 |
imageEditView undo. |
928
89bd2304da33
cleaned up imageEitViews interface to my infoPanel
Claus Gittinger <cg@exept.de>
parents:
927
diff
changeset
|
1758 |
^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
|
1759 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1760 |
do: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1761 |
[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1762 |
newImage := (Image implementorForDepth: depth) new. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1763 |
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
|
1764 |
newImage colorMap:newColorMap. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1765 |
newImage photometric:#palette. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1766 |
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
|
1767 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1768 |
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
|
1769 |
[:x :y :clr | |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1770 |
|newColor| |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1771 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1772 |
(newColorMap includes:clr) |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1773 |
ifTrue: [newColor := clr] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1774 |
ifFalse: [ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1775 |
useNearest ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1776 |
newColor := clr nearestIn:newColorMap |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1777 |
] ifFalse:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1778 |
newColor := oldImage colorMap first |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1779 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1780 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1781 |
newImage colorAtX:x y:y put:newColor. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1782 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1783 |
image := newImage |
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 |
do: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1787 |
[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1788 |
image := newImage fromImage: oldImage |
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 |
|
937 | 1791 |
(aMode asString endsWith:'mask') |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1792 |
ifTrue: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1793 |
[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1794 |
image mask isNil |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1795 |
ifTrue: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1796 |
[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1797 |
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
|
1798 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1799 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1800 |
ifFalse: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1801 |
[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1802 |
image mask: nil. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1803 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1804 |
realColorMap := OrderedCollection new. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1805 |
image realColorMap do: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1806 |
[:clr| |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1807 |
(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
|
1808 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1809 |
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
|
1810 |
newColorMap do: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1811 |
[:clr| |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1812 |
((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
|
1813 |
ifTrue: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1814 |
[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1815 |
newColors add: clr |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1816 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1817 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1818 |
image colorMap: newColors. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1819 |
colorMapMode := aMode. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1820 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1821 |
(imageEditView image: image) notNil ifTrue: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1822 |
[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1823 |
image fileName: oldFileName. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1824 |
self listOfColors contents: image colorMap. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1825 |
self findColorMapMode. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1826 |
self updateLabelsAndHistory. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1827 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1828 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1829 |
|
958 | 1830 |
"Modified: / 17.8.1998 / 10:22:15 / cg" |
919
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1831 |
! |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1832 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1833 |
compressColorMap |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1834 |
"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
|
1835 |
|
927 | 1836 |
|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
|
1837 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1838 |
oldImage := self image. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1839 |
depth := oldImage depth. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1840 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1841 |
oldImage photometric ~~ #palette ifTrue:[ |
930 | 1842 |
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
|
1843 |
^ self |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1844 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1845 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1846 |
usedColors := oldImage usedColors. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1847 |
usedColors size == (1 bitShift:depth) ifTrue:[ |
930 | 1848 |
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
|
1849 |
^ self |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1850 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1851 |
usedColors size == oldImage colorMap size ifTrue:[ |
930 | 1852 |
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
|
1853 |
^ self |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1854 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1855 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1856 |
imageEditView makeUndo. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1857 |
|
930 | 1858 |
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
|
1859 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1860 |
self withExecuteCursorDo:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1861 |
newColorMap := Array new:usedColors size. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1862 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1863 |
"/ translation table |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1864 |
oldToNew := ByteArray new:(1 bitShift:depth). |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1865 |
newColorMap := usedColors asArray. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1866 |
oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr | |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1867 |
|newPixel| |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1868 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1869 |
(usedColors includes:clr) ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1870 |
newPixel := newColorMap indexOf:clr. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1871 |
oldToNew at:oldIdx put:newPixel-1. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1872 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1873 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1874 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1875 |
oldBits := oldImage bits. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1876 |
newBits := ByteArray new:(oldBits size). |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1877 |
depth ~~ 8 ifTrue:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1878 |
"/ expand/compress can only handle 8bits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1879 |
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
|
1880 |
oldBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1881 |
expandPixels:depth |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1882 |
width:oldImage width |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1883 |
height:oldImage height |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1884 |
into:tmpBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1885 |
mapping:oldToNew. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1886 |
tmpBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1887 |
compressPixels:depth |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1888 |
width:oldImage width |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1889 |
height:oldImage height |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1890 |
into:newBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1891 |
mapping:nil |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1892 |
] ifFalse:[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1893 |
oldBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1894 |
expandPixels:depth |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1895 |
width:oldImage width |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1896 |
height:oldImage height |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1897 |
into:newBits |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1898 |
mapping:oldToNew. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1899 |
]. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1900 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1901 |
newImage := oldImage species new |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1902 |
width:oldImage width |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1903 |
height:oldImage height |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1904 |
depth:depth |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1905 |
fromArray:newBits. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1906 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1907 |
newImage colorMap:newColorMap. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1908 |
newImage fileName:oldImage fileName. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1909 |
newImage mask:(oldImage mask copy). |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1910 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1911 |
(imageEditView image:newImage) notNil ifTrue: |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1912 |
[ |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1913 |
self listOfColors contents: newImage colorMap. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1914 |
self findColorMapMode. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1915 |
self updateLabelsAndHistory. |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1916 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1917 |
] |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1918 |
|
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1919 |
"Created: / 28.7.1998 / 20:03:11 / cg" |
930 | 1920 |
"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
|
1921 |
! ! |
4e50c3164625
more options (preserving colorMap) when changing the colorMapMode;
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1922 |
|
400 | 1923 |
!ImageEditor methodsFor:'user actions - editing'! |
1924 |
||
767 | 1925 |
doBrowseClass |
1926 |
"opens a System Browser on the resourceClass and the resourceSelector" |
|
400 | 1927 |
|
933
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1928 |
|cls| |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1929 |
|
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1930 |
cls := Smalltalk at:(imageEditView resourceClass) ifAbsent:nil. |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1931 |
cls isNil ifTrue:[^ self warn:'No Class specified']. |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1932 |
SystemBrowser |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1933 |
openInClass:cls class |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1934 |
selector:(imageEditView resourceSelector) |
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1935 |
|
f090206aadff
disable some menu items if no class/selector is defined
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
1936 |
"Modified: / 31.7.1998 / 02:01:15 / cg" |
400 | 1937 |
! |
1938 |
||
905 | 1939 |
doChangeGridMagnification |
1940 |
"change grid magnification" |
|
1941 |
||
911 | 1942 |
imageEditView changeGridMagnification |
905 | 1943 |
! |
1944 |
||
767 | 1945 |
doFlipHorizontal |
1946 |
"flips horizontally current image" |
|
400 | 1947 |
|
911 | 1948 |
imageEditView flipHorizontal |
400 | 1949 |
! |
1950 |
||
767 | 1951 |
doFlipVertical |
1952 |
"flips vertically current image" |
|
400 | 1953 |
|
911 | 1954 |
imageEditView flipVertical |
400 | 1955 |
! |
1956 |
||
767 | 1957 |
doMagnifyDown |
1958 |
"magnifies current image one step down" |
|
400 | 1959 |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1960 |
|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
|
1961 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1962 |
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
|
1963 |
(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
|
1964 |
magHolder value: mag - 1 |
400 | 1965 |
] |
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1966 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1967 |
"Modified: / 26.7.1998 / 20:24:08 / cg" |
400 | 1968 |
! |
1969 |
||
767 | 1970 |
doMagnifyImage |
1971 |
"magnifies current image" |
|
400 | 1972 |
|
911 | 1973 |
imageEditView magnifyImage. |
400 | 1974 |
self updateInfoLabel |
1975 |
! |
|
1976 |
||
767 | 1977 |
doMagnifyUp |
1978 |
"magnifies current image one step up" |
|
400 | 1979 |
|
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1980 |
|magHolder mag| |
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1981 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1982 |
magHolder := 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
|
1983 |
(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
|
1984 |
magHolder value: mag + 1 |
400 | 1985 |
] |
915
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1986 |
|
99f8e19aab3a
better use a columnAdaptor to fetch r/g/b values from a color.
Claus Gittinger <cg@exept.de>
parents:
914
diff
changeset
|
1987 |
"Modified: / 26.7.1998 / 20:23:52 / cg" |
400 | 1988 |
! |
1989 |
||
767 | 1990 |
doNegativeImage |
1991 |
"negates current image by negating the color map" |
|
400 | 1992 |
|
911 | 1993 |
imageEditView negativeImage. |
400 | 1994 |
self listOfColors removeAll. |
901 | 1995 |
self findColorMapMode. |
911 | 1996 |
imageEditView undoImages removeLast |
400 | 1997 |
! |
1998 |
||
767 | 1999 |
doResizeImage |
2000 |
"resizes current image" |
|
400 | 2001 |
|
911 | 2002 |
imageEditView resizeImage. |
400 | 2003 |
self updateInfoLabel |
2004 |
! |
|
2005 |
||
767 | 2006 |
doRotateImage |
2007 |
"rotates current image" |
|
400 | 2008 |
|
911 | 2009 |
imageEditView rotateImage. |
400 | 2010 |
self updateInfoLabel |
2011 |
! |
|
2012 |
||
767 | 2013 |
doUndo |
2014 |
"reverses last edit action" |
|
400 | 2015 |
|
911 | 2016 |
imageEditView undo |
400 | 2017 |
! ! |
2018 |
||
2019 |
!ImageEditor methodsFor:'user actions - loading'! |
|
2020 |
||
767 | 2021 |
doLoadFromClass |
2022 |
"opens a dialog for loading an image from class and a (resource-) selector" |
|
400 | 2023 |
|
911 | 2024 |
(imageEditView loadFromClass) notNil |
574 | 2025 |
ifTrue: |
2026 |
[ |
|
2027 |
self image notNil |
|
2028 |
ifTrue: |
|
2029 |
[ |
|
2030 |
self listOfColors contents: self image usedColors asSet asOrderedCollection. |
|
2031 |
self findColorMapMode. |
|
767 | 2032 |
self updateLabelsAndHistory |
400 | 2033 |
] |
2034 |
ifFalse: |
|
2035 |
[ |
|
461 | 2036 |
self updateForNoneImage |
2037 |
] |
|
449 | 2038 |
] |
400 | 2039 |
! |
2040 |
||
767 | 2041 |
doLoadFromFile |
2042 |
"opens a dialog for loading an image from a file" |
|
400 | 2043 |
|
767 | 2044 |
self loadFromFile: |
2045 |
(FileSelectionBrowser |
|
2046 |
request: 'Load Image From' |
|
2047 |
fileName: (self image notNil ifTrue: [self image fileName] ifFalse: [nil]) |
|
2048 |
withFileFilters: FileSelectionBrowser loadImageFileNameFilters) |
|
400 | 2049 |
! |
2050 |
||
767 | 2051 |
doNewImage |
2052 |
"opens a dialog with choices of size and color map for creating a new image" |
|
400 | 2053 |
|
2054 |
|aspects| |
|
767 | 2055 |
|
400 | 2056 |
aspects := IdentityDictionary new |
767 | 2057 |
at:#listOfSizes put: self class listOfDefaultSizes asValue; |
2058 |
at:#listOfColorMaps put: self class listOfColorMaps keys asSortedCollection asValue; |
|
2059 |
at:#selectionOfSize put: self class listOfDefaultSizes first copy asValue; |
|
400 | 2060 |
at:#selectionOfColorMap put: self class listOfColorMaps keys asSortedCollection first asValue; |
2061 |
yourself. |
|
2062 |
||
767 | 2063 |
(self openDialogInterface:#dialogSpecForNewImage withBindings:aspects) |
400 | 2064 |
ifTrue: |
2065 |
[ |
|
2066 |
|width height cMap imageClass image| |
|
767 | 2067 |
|
2068 |
width := 128 min: (Integer readFromString: ((aspects at:#selectionOfSize) value upTo: $x) onError:[24]). |
|
400 | 2069 |
height := 128 min: (Integer readFromString: ((aspects at:#selectionOfSize) value copy reverse upTo: $x) reverse onError:[24]). |
2070 |
||
767 | 2071 |
cMap := (self class listOfColorMaps at: (colorMapMode := (aspects at:#selectionOfColorMap) value)). |
400 | 2072 |
imageClass := Image implementorForDepth: ((cMap size log: 2) asInteger). |
767 | 2073 |
image := imageClass width: width height: height fromArray: (ByteArray new: width*height). |
400 | 2074 |
|
2075 |
(colorMapMode copy reverse readStream nextWord reverse = 'mask') |
|
2076 |
ifTrue: |
|
2077 |
[ |
|
767 | 2078 |
image mask: (Depth1Image width: width height: height depth: 1 fromArray: (ByteArray new: width*height)) clearMaskedPixels |
400 | 2079 |
]. |
2080 |
image colorMap: cMap. |
|
2081 |
image fillRectangleX:0 y:0 width:width height:height with:Color white. |
|
911 | 2082 |
(imageEditView image: image) notNil |
400 | 2083 |
ifTrue: |
2084 |
[ |
|
2085 |
self listOfColors contents: cMap. |
|
2086 |
self findColorMapMode. |
|
694 | 2087 |
self updateLabelsAndHistory |
400 | 2088 |
] |
767 | 2089 |
] |
929 | 2090 |
! |
2091 |
||
2092 |
grabScreenImage |
|
2093 |
"let user choose an area and grab that are for editing" |
|
2094 |
||
2095 |
|image img| |
|
2096 |
||
2097 |
image := Image fromUser. |
|
2098 |
||
2099 |
image depth > 8 ifTrue:[ |
|
930 | 2100 |
Object errorSignal handle:[:ex | |
2101 |
self warn:'Could not convert to depth8 image (too many colors)'. |
|
2102 |
^ self |
|
2103 |
] do:[ |
|
2104 |
image := Depth8Image fromImage:image. |
|
2105 |
] |
|
929 | 2106 |
]. |
2107 |
(imageEditView image: image) notNil |
|
2108 |
ifTrue: |
|
2109 |
[ |
|
2110 |
self listOfColors contents:(image colorMap). |
|
2111 |
self findColorMapMode. |
|
930 | 2112 |
self updateLabelsAndHistory. |
929 | 2113 |
] |
2114 |
||
2115 |
"Created: / 29.7.1998 / 21:24:42 / cg" |
|
930 | 2116 |
"Modified: / 31.7.1998 / 01:14:33 / cg" |
400 | 2117 |
! ! |
2118 |
||
2119 |
!ImageEditor methodsFor:'user actions - saving'! |
|
2120 |
||
767 | 2121 |
doPrint |
2122 |
"prints current image on the current printer" |
|
400 | 2123 |
|
911 | 2124 |
imageEditView print |
400 | 2125 |
! |
2126 |
||
767 | 2127 |
doSaveImageFile |
2128 |
"saves current image to current file" |
|
400 | 2129 |
|
911 | 2130 |
imageEditView save |
400 | 2131 |
! |
2132 |
||
767 | 2133 |
doSaveImageFileAs |
2134 |
"opens a dialog for saving current image to a file" |
|
400 | 2135 |
|
911 | 2136 |
imageEditView saveImageFileAs. |
694 | 2137 |
self updateLabelsAndHistory |
400 | 2138 |
! |
2139 |
||
767 | 2140 |
doSaveImageMaskFileAs |
2141 |
"opens a dialog for saving mask of current image to a file" |
|
400 | 2142 |
|
911 | 2143 |
imageEditView saveImageMaskFileAs |
400 | 2144 |
! |
2145 |
||
767 | 2146 |
doSaveMethod |
2147 |
"saves current image on current class and selector" |
|
400 | 2148 |
|
911 | 2149 |
imageEditView saveMethod notNil |
400 | 2150 |
ifTrue: |
2151 |
[ |
|
694 | 2152 |
self updateLabelsAndHistory |
400 | 2153 |
] |
2154 |
! |
|
2155 |
||
767 | 2156 |
doSaveMethodAs |
2157 |
"opens a dialog for saving current image on a class and a selector" |
|
400 | 2158 |
|
911 | 2159 |
imageEditView saveMethodAs notNil |
400 | 2160 |
ifTrue: |
2161 |
[ |
|
694 | 2162 |
self updateLabelsAndHistory |
400 | 2163 |
] |
2164 |
! ! |
|
2165 |
||
2166 |
!ImageEditor class methodsFor:'documentation'! |
|
2167 |
||
2168 |
version |
|
2169 |
^ '$Header$' |
|
2170 |
! ! |