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