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