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