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