400
|
1 |
"
|
503
|
2 |
COPYRIGHT (c) 1997 by eXept Software AG
|
400
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
405
|
7 |
inclusion of the above copyright notice. This software may not
|
400
|
8 |
be provided or otherwise made available to, or used by, any
|
405
|
9 |
other person. No title to or ownership of the software is
|
400
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
ToolApplicationModel subclass:#ImageEditor
|
|
14 |
instanceVariableNames:'colorMapMode selectedColorIndex postOpenAction'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
617
|
17 |
category:'Interface-UIPainter'
|
400
|
18 |
!
|
|
19 |
|
|
20 |
!ImageEditor class methodsFor:'documentation'!
|
|
21 |
|
|
22 |
copyright
|
|
23 |
"
|
503
|
24 |
COPYRIGHT (c) 1997 by eXept Software AG
|
400
|
25 |
All Rights Reserved
|
|
26 |
|
|
27 |
This software is furnished under a license and may be used
|
|
28 |
only in accordance with the terms of that license and with the
|
405
|
29 |
inclusion of the above copyright notice. This software may not
|
400
|
30 |
be provided or otherwise made available to, or used by, any
|
405
|
31 |
other person. No title to or ownership of the software is
|
400
|
32 |
hereby transferred.
|
|
33 |
"
|
|
34 |
!
|
|
35 |
|
|
36 |
documentation
|
|
37 |
"
|
737
|
38 |
Image Editor allows you to create, design, modify or just inspect images.
|
400
|
39 |
|
|
40 |
[start with:]
|
|
41 |
ImageEditor open
|
|
42 |
ImageEditor openOnClass:ImageEditor andSelector:#newImageIcon
|
|
43 |
|
|
44 |
[see also:]
|
|
45 |
ImageEditView Image
|
|
46 |
|
|
47 |
[author:]
|
544
|
48 |
Thomas Zwick, eXept Software AG
|
400
|
49 |
"
|
679
|
50 |
!
|
|
51 |
|
|
52 |
listOfColors
|
|
53 |
|
|
54 |
^List new
|
|
55 |
|
400
|
56 |
! !
|
|
57 |
|
|
58 |
!ImageEditor class methodsFor:'instance creation'!
|
|
59 |
|
|
60 |
openModalOnClass: aClass andSelector: aSelector
|
|
61 |
|
756
|
62 |
"self openModalOnClass: self andSelector: #leftMouseKeyIcon"
|
400
|
63 |
|
688
|
64 |
|imageEditor imageEditView className resourceClassName resourceSelector|
|
400
|
65 |
imageEditor := self new.
|
|
66 |
aClass isClass ifTrue: [className := aClass name].
|
|
67 |
aClass isString ifTrue: [className := aClass].
|
|
68 |
|
688
|
69 |
imageEditor postOpenAction: [imageEditView := imageEditor imageEditView. imageEditor loadFromOrPrepareForMessage: className, ' ', aSelector].
|
400
|
70 |
imageEditor openModal.
|
|
71 |
|
688
|
72 |
resourceClassName := imageEditView resourceClass.
|
|
73 |
resourceSelector := imageEditView resourceSelector.
|
415
|
74 |
|
|
75 |
(className asString ~= resourceClassName) | (aSelector asString ~= resourceSelector)
|
|
76 |
ifTrue: [^resourceClassName, ' ', resourceSelector]
|
|
77 |
ifFalse:[^nil]
|
400
|
78 |
!
|
|
79 |
|
|
80 |
openOnClass: aClass andSelector: aSelector
|
|
81 |
|
756
|
82 |
"self openOnClass: self andSelector: #leftMouseKeyIcon"
|
400
|
83 |
|
|
84 |
^self open loadFromMessage: aClass name, ' ', aSelector
|
|
85 |
!
|
|
86 |
|
|
87 |
openOnFile: image
|
|
88 |
|
|
89 |
"self openOnFile: 'bitmaps/SmalltalkX.xbm'"
|
|
90 |
|
|
91 |
^self open loadFromFile: image
|
|
92 |
!
|
|
93 |
|
|
94 |
openOnImage: image
|
|
95 |
|
|
96 |
"self openOnImage: self stxIcon"
|
|
97 |
|
|
98 |
^self open loadFromImage: image
|
|
99 |
! !
|
|
100 |
|
|
101 |
!ImageEditor class methodsFor:'accessing'!
|
|
102 |
|
|
103 |
listOfColorMaps
|
|
104 |
|
|
105 |
|colorMap|
|
|
106 |
(colorMap := OrderedCollection new)
|
|
107 |
add: Color black;
|
|
108 |
add: Color white;
|
|
109 |
add: Color red;
|
|
110 |
add: Color green;
|
|
111 |
add: Color blue;
|
|
112 |
add: Color cyan;
|
|
113 |
add: Color yellow;
|
|
114 |
add: Color magenta;
|
|
115 |
add: (Color red: 50 green: 0 blue: 0);
|
|
116 |
add: (Color red: 0 green: 50 blue: 0);
|
|
117 |
add: (Color red: 0 green: 0 blue: 50);
|
|
118 |
add: (Color red: 0 green: 50 blue: 50);
|
|
119 |
add: (Color red: 50 green: 50 blue: 0);
|
|
120 |
add: (Color red: 50 green: 0 blue: 50);
|
|
121 |
add: Color gray;
|
|
122 |
add: Color lightGray.
|
|
123 |
0 to: 5 do:
|
|
124 |
[:r|
|
|
125 |
0 to: 5 do:
|
|
126 |
[:g|
|
|
127 |
0 to: 5 do:
|
|
128 |
[:b|
|
|
129 |
colorMap add: (Color red: (r*100//5) ceiling green: (g*100//5) ceiling blue: (b*100//5) ceiling)
|
|
130 |
]
|
|
131 |
]
|
|
132 |
].
|
|
133 |
|
|
134 |
1 to: 25 do:
|
|
135 |
[:g|
|
|
136 |
colorMap add: (Color gray: (g*100//26) ceiling)
|
|
137 |
].
|
|
138 |
|
|
139 |
^Dictionary new
|
|
140 |
at: '8-plane' put: colorMap;
|
|
141 |
at: '8-plane + mask' put: colorMap;
|
|
142 |
at: '4-plane' put: (colorMap copyFrom: 1 to: 16);
|
|
143 |
at: '4-plane + mask' put: (colorMap copyFrom: 1 to: 16);
|
|
144 |
at: '2-plane' put: (colorMap copyFrom: 1 to: 4);
|
|
145 |
at: '2-plane + mask' put: (colorMap copyFrom: 1 to: 4);
|
|
146 |
at: '1-plane' put: (colorMap copyFrom: 1 to: 2);
|
|
147 |
at: '1-plane + mask' put: (colorMap copyFrom: 1 to: 2);
|
|
148 |
yourself
|
|
149 |
!
|
|
150 |
|
|
151 |
listOfDefaultSizes
|
|
152 |
|
|
153 |
^#('24x24' '16x16' '32x32')
|
|
154 |
! !
|
|
155 |
|
460
|
156 |
!ImageEditor class methodsFor:'help specs'!
|
|
157 |
|
|
158 |
helpSpec
|
737
|
159 |
"This resource specification was automatically generated
|
|
160 |
by the UIHelpTool of ST/X."
|
|
161 |
|
|
162 |
"Do not manually edit this!! If it is corrupted,
|
|
163 |
the UIHelpTool may not be able to read the specification."
|
460
|
164 |
|
|
165 |
"
|
737
|
166 |
UIHelpTool openOnClass:ImageEditor
|
460
|
167 |
"
|
|
168 |
|
737
|
169 |
<resource: #help>
|
|
170 |
|
|
171 |
^super helpSpec addPairsFrom:#(
|
460
|
172 |
|
|
173 |
#colorMap
|
|
174 |
'Increases or reduces size of color map of the image.'
|
|
175 |
|
487
|
176 |
#colorMapTable
|
675
|
177 |
'Shows a list of used colors of the image.'
|
487
|
178 |
|
460
|
179 |
#drawModeBox
|
|
180 |
'Switches to mode drawing boxes.'
|
|
181 |
|
|
182 |
#drawModeCopy
|
|
183 |
'Switches to mode copying areas.'
|
|
184 |
|
|
185 |
#drawModeFill
|
|
186 |
'Switches to mode filling areas around selected point.'
|
|
187 |
|
|
188 |
#drawModeFilledBox
|
|
189 |
'Switches to mode drawing filled boxes.'
|
|
190 |
|
|
191 |
#drawModePaste
|
|
192 |
'Switches to mode pasting areas at selected point.'
|
|
193 |
|
|
194 |
#drawModePoint
|
|
195 |
'Switches to mode drawing points.'
|
|
196 |
|
|
197 |
#editFlipHorizontal
|
|
198 |
'Flips horizontally the image.'
|
|
199 |
|
|
200 |
#editFlipVertical
|
|
201 |
'Flips vertically the image.'
|
|
202 |
|
|
203 |
#editMagnifyImage
|
|
204 |
'Opens a dialog to magnify the image.'
|
|
205 |
|
|
206 |
#editNegate
|
|
207 |
'Convertes colors of image by negating them.'
|
|
208 |
|
|
209 |
#editResize
|
|
210 |
'Opens a dialog to resize the image with preserving the old image.'
|
|
211 |
|
|
212 |
#editRotate
|
|
213 |
'Opens a dialog to rotate the image in degrees.'
|
|
214 |
|
|
215 |
#fileLoadFromClass
|
651
|
216 |
'Opens a dialog for selecting and loading an image from resource method of a class.'
|
460
|
217 |
|
|
218 |
#fileLoadFromFile
|
651
|
219 |
'Opens a dialog for selecting and loading an image from a file.'
|
460
|
220 |
|
|
221 |
#fileNewImage
|
651
|
222 |
'Opens a dialog with choices of size and color depth to create an new image.'
|
460
|
223 |
|
|
224 |
#filePrint
|
|
225 |
'Print the image on a postscript printer.'
|
|
226 |
|
|
227 |
#fileSaveAs
|
675
|
228 |
'Opens a dialog to save the image to a file.'
|
460
|
229 |
|
|
230 |
#fileSaveMaskAs
|
675
|
231 |
'Opens a dialog to save the mask of the image to a file.'
|
460
|
232 |
|
|
233 |
#fileSaveMethod
|
675
|
234 |
'Saves the image on current class and selector.'
|
460
|
235 |
|
|
236 |
#fileSaveMethodAs
|
675
|
237 |
'Opens a dialog for selecting and saving the image in a resource method of a class.'
|
460
|
238 |
|
487
|
239 |
#magnificationNumber
|
|
240 |
'Shows current number of magnification.'
|
|
241 |
|
|
242 |
#magnifyImageDown
|
675
|
243 |
'Magnifies down the image.'
|
487
|
244 |
|
|
245 |
#magnifyImageUp
|
675
|
246 |
'Magnifies up the image.'
|
487
|
247 |
|
|
248 |
#mouseKeyColorMode
|
675
|
249 |
'Switches between left and right mouse button color.'
|
487
|
250 |
|
|
251 |
#previewView
|
675
|
252 |
'Shows preview of the image.'
|
487
|
253 |
|
460
|
254 |
)
|
|
255 |
! !
|
|
256 |
|
737
|
257 |
!ImageEditor class methodsFor:'image specs'!
|
|
258 |
|
|
259 |
leftMouseKeyIcon
|
|
260 |
"This resource specification was automatically generated
|
|
261 |
by the ImageEditor of ST/X."
|
|
262 |
|
|
263 |
"Do not manually edit this!! If it is corrupted,
|
|
264 |
the ImageEditor may not be able to read the specification."
|
|
265 |
|
|
266 |
"
|
|
267 |
ImageEditor openOnClass:self andSelector:#leftMouseKeyIcon
|
|
268 |
"
|
|
269 |
|
|
270 |
<resource: #image>
|
|
271 |
|
|
272 |
^Icon
|
|
273 |
constantNamed:#'ImageEditor leftMouseKeyIcon'
|
|
274 |
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]!
|
|
275 |
|
|
276 |
rightMouseKeyIcon
|
|
277 |
"This resource specification was automatically generated
|
|
278 |
by the ImageEditor of ST/X."
|
|
279 |
|
|
280 |
"Do not manually edit this!! If it is corrupted,
|
|
281 |
the ImageEditor may not be able to read the specification."
|
|
282 |
|
|
283 |
"
|
|
284 |
ImageEditor openOnClass:self andSelector:#rightMouseKeyIcon
|
|
285 |
"
|
|
286 |
|
|
287 |
<resource: #image>
|
|
288 |
|
|
289 |
^Icon
|
|
290 |
constantNamed:#'ImageEditor rightMouseKeyIcon'
|
|
291 |
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]! !
|
|
292 |
|
400
|
293 |
!ImageEditor class methodsFor:'interface specs'!
|
|
294 |
|
519
|
295 |
windowSpec
|
737
|
296 |
"This resource specification was automatically generated
|
|
297 |
by the UIPainter of ST/X."
|
519
|
298 |
|
737
|
299 |
"Do not manually edit this!! If it is corrupted,
|
|
300 |
the UIPainter may not be able to read the specification."
|
519
|
301 |
|
|
302 |
"
|
|
303 |
UIPainter new openOnClass:ImageEditor andSelector:#windowSpec
|
|
304 |
ImageEditor new openInterface:#windowSpec
|
737
|
305 |
ImageEditor open
|
519
|
306 |
"
|
|
307 |
|
|
308 |
<resource: #canvas>
|
|
309 |
|
|
310 |
^
|
|
311 |
|
|
312 |
#(#FullSpec
|
672
|
313 |
#window:
|
519
|
314 |
#(#WindowSpec
|
672
|
315 |
#name: 'Image Editor'
|
756
|
316 |
#layout: #(#LayoutFrame 188 0 318 0 687 0 663 0)
|
672
|
317 |
#label: 'Image Editor'
|
|
318 |
#min: #(#Point 400 320)
|
|
319 |
#max: #(#Point 1152 900)
|
756
|
320 |
#bounds: #(#Rectangle 188 318 688 664)
|
672
|
321 |
#menu: #menu
|
|
322 |
#usePreferredExtent: false
|
519
|
323 |
)
|
672
|
324 |
#component:
|
519
|
325 |
#(#SpecCollection
|
672
|
326 |
#collection:
|
519
|
327 |
#(
|
|
328 |
#(#MenuPanelSpec
|
672
|
329 |
#name: 'menuToolbarView'
|
|
330 |
#layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 32 0)
|
|
331 |
#menu: #menuToolbar
|
|
332 |
#style: #(#FontDescription #helvetica #medium #roman 10)
|
|
333 |
#showSeparatingLines: true
|
519
|
334 |
)
|
|
335 |
#(#VariableHorizontalPanelSpec
|
672
|
336 |
#name: 'variableHorizontalPanel1'
|
|
337 |
#layout: #(#LayoutFrame 0 0.0 34 0.0 0 1.0 -26 1.0)
|
|
338 |
#component:
|
519
|
339 |
#(#SpecCollection
|
672
|
340 |
#collection:
|
519
|
341 |
#(
|
|
342 |
#(#ViewSpec
|
672
|
343 |
#name: 'view1'
|
|
344 |
#component:
|
519
|
345 |
#(#SpecCollection
|
672
|
346 |
#collection:
|
519
|
347 |
#(
|
672
|
348 |
#(#VariableVerticalPanelSpec
|
|
349 |
#name: 'VariableVerticalPanel1'
|
|
350 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
|
|
351 |
#component:
|
519
|
352 |
#(#SpecCollection
|
672
|
353 |
#collection:
|
519
|
354 |
#(
|
679
|
355 |
#(#ViewSpec
|
|
356 |
#name: 'View1'
|
|
357 |
#component:
|
|
358 |
#(#SpecCollection
|
|
359 |
#collection:
|
|
360 |
#(
|
688
|
361 |
#(#MenuPanelSpec
|
732
|
362 |
#name: 'MouseButtonColorToolBar'
|
688
|
363 |
#layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 24 0)
|
|
364 |
#menu: #menuMouseButtonColors
|
|
365 |
)
|
679
|
366 |
#(#DataSetSpec
|
|
367 |
#name: 'colorDataSetView'
|
688
|
368 |
#layout: #(#LayoutFrame 0 0.0 26 0.0 0 1.0 0 1.0)
|
679
|
369 |
#activeHelpKey: #colorMapTable
|
|
370 |
#model: #selectionOfColor
|
|
371 |
#style: #(#FontDescription #helvetica #medium #roman 10)
|
|
372 |
#hasHorizontalScrollBar: true
|
|
373 |
#hasVerticalScrollBar: true
|
|
374 |
#miniScrollerHorizontal: true
|
|
375 |
#miniScrollerVertical: true
|
756
|
376 |
#level: -1
|
679
|
377 |
#dataList: #listOfColors
|
|
378 |
#has3Dsepartors: true
|
|
379 |
#verticalSpacing: 1
|
|
380 |
#columns:
|
|
381 |
#(
|
|
382 |
#(#DataSetColumnSpec
|
|
383 |
#rendererType: #rowSelector
|
|
384 |
#backgroundSelector: #yourself
|
|
385 |
)
|
|
386 |
#(#DataSetColumnSpec
|
|
387 |
#label: 'R'
|
|
388 |
#model: #rowRedByte
|
|
389 |
#canSelect: false
|
|
390 |
)
|
|
391 |
#(#DataSetColumnSpec
|
|
392 |
#label: 'G'
|
|
393 |
#model: #rowGreenByte
|
|
394 |
#canSelect: false
|
|
395 |
)
|
|
396 |
#(#DataSetColumnSpec
|
|
397 |
#label: 'B'
|
|
398 |
#model: #rowBlueByte
|
|
399 |
#canSelect: false
|
|
400 |
)
|
|
401 |
)
|
|
402 |
)
|
|
403 |
)
|
672
|
404 |
)
|
519
|
405 |
)
|
676
|
406 |
#(#ArbitraryComponentSpec
|
|
407 |
#name: 'imagePreView'
|
|
408 |
#activeHelpKey: #previewView
|
|
409 |
#hasHorizontalScrollBar: true
|
|
410 |
#hasVerticalScrollBar: true
|
|
411 |
#miniScrollerHorizontal: true
|
|
412 |
#miniScrollerVertical: true
|
|
413 |
#component: #ImageView
|
688
|
414 |
#hasBorder: false
|
676
|
415 |
)
|
519
|
416 |
)
|
|
417 |
)
|
688
|
418 |
#handles: #(#Any 0.723776 1.0)
|
519
|
419 |
)
|
|
420 |
)
|
|
421 |
)
|
|
422 |
)
|
|
423 |
#(#ViewSpec
|
672
|
424 |
#name: 'view2'
|
|
425 |
#component:
|
519
|
426 |
#(#SpecCollection
|
672
|
427 |
#collection:
|
519
|
428 |
#(
|
|
429 |
#(#ArbitraryComponentSpec
|
672
|
430 |
#name: 'imageEditView'
|
|
431 |
#layout: #(#LayoutFrame 2 0.0 2 0.0 -2 1.0 -24 1.0)
|
|
432 |
#hasHorizontalScrollBar: true
|
|
433 |
#hasVerticalScrollBar: true
|
|
434 |
#component: #ImageEditView
|
|
435 |
#hasBorder: false
|
519
|
436 |
)
|
|
437 |
#(#LabelSpec
|
672
|
438 |
#name: 'coordLabel'
|
|
439 |
#layout: #(#LayoutFrame 2 0.0 -22 1 -83 1.0 0 1.0)
|
|
440 |
#level: -1
|
|
441 |
#adjust: #left
|
756
|
442 |
#resizeForLabel: false
|
672
|
443 |
)
|
|
444 |
#(#ArrowButtonSpec
|
|
445 |
#name: 'magnifyDownButton'
|
|
446 |
#layout: #(#LayoutFrame -80 1 -22 1 -58 1 0 1)
|
|
447 |
#activeHelpKey: #magnifyImageDown
|
|
448 |
#model: #magnifyDown
|
|
449 |
#enableChannel: #imageIsLoaded
|
|
450 |
#isTriggerOnDown: true
|
|
451 |
#direction: #left
|
|
452 |
)
|
|
453 |
#(#ArrowButtonSpec
|
|
454 |
#name: 'magnifyUpButton'
|
|
455 |
#layout: #(#LayoutFrame -24 1 -22 1 -2 1 0 1)
|
|
456 |
#activeHelpKey: #magnifyImageUp
|
|
457 |
#model: #magnifyUp
|
|
458 |
#enableChannel: #imageIsLoaded
|
|
459 |
#isTriggerOnDown: true
|
|
460 |
#direction: #right
|
|
461 |
)
|
|
462 |
#(#InputFieldSpec
|
|
463 |
#name: 'magnificationInputField'
|
|
464 |
#layout: #(#LayoutFrame -57 1 -22 1 -26 1 0 1)
|
|
465 |
#activeHelpKey: #magnificationNumber
|
|
466 |
#enableChannel: #imageIsLoaded
|
|
467 |
#model: #valueOfMagnification
|
|
468 |
#type: #number
|
|
469 |
#acceptOnReturn: false
|
|
470 |
#acceptOnTab: false
|
|
471 |
#numChars: 2
|
519
|
472 |
)
|
|
473 |
)
|
|
474 |
)
|
672
|
475 |
#level: -1
|
519
|
476 |
)
|
|
477 |
)
|
|
478 |
)
|
676
|
479 |
#handles: #(#Any 0.276 1.0)
|
519
|
480 |
)
|
|
481 |
#(#UISubSpecification
|
672
|
482 |
#name: 'infoBarSubSpec'
|
|
483 |
#layout: #(#LayoutFrame 0 0.0 -24 1 0 1.0 0 1.0)
|
|
484 |
#majorKey: #ToolApplicationModel
|
688
|
485 |
#minorKey: #windowSpecForInfoBar
|
519
|
486 |
)
|
|
487 |
)
|
|
488 |
)
|
|
489 |
)
|
|
490 |
!
|
|
491 |
|
|
492 |
windowSpecForNewImage
|
737
|
493 |
"This resource specification was automatically generated
|
|
494 |
by the UIPainter of ST/X."
|
519
|
495 |
|
737
|
496 |
"Do not manually edit this!! If it is corrupted,
|
|
497 |
the UIPainter may not be able to read the specification."
|
519
|
498 |
|
|
499 |
"
|
|
500 |
UIPainter new openOnClass:ImageEditor andSelector:#windowSpecForNewImage
|
|
501 |
ImageEditor new openInterface:#windowSpecForNewImage
|
|
502 |
"
|
|
503 |
|
|
504 |
<resource: #canvas>
|
|
505 |
|
|
506 |
^
|
|
507 |
|
|
508 |
#(#FullSpec
|
672
|
509 |
#window:
|
519
|
510 |
#(#WindowSpec
|
672
|
511 |
#name: 'New Image'
|
737
|
512 |
#layout: #(#LayoutFrame 240 0 278 0 540 0 382 0)
|
672
|
513 |
#label: 'New Image'
|
|
514 |
#min: #(#Point 10 10)
|
|
515 |
#max: #(#Point 1152 900)
|
737
|
516 |
#bounds: #(#Rectangle 240 278 541 383)
|
672
|
517 |
#usePreferredExtent: false
|
519
|
518 |
)
|
672
|
519 |
#component:
|
519
|
520 |
#(#SpecCollection
|
672
|
521 |
#collection:
|
519
|
522 |
#(
|
|
523 |
#(#ViewSpec
|
672
|
524 |
#name: 'View'
|
737
|
525 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -35 1.0)
|
672
|
526 |
#component:
|
519
|
527 |
#(#SpecCollection
|
672
|
528 |
#collection:
|
519
|
529 |
#(
|
|
530 |
#(#FramedBoxSpec
|
672
|
531 |
#name: 'framedBox1'
|
737
|
532 |
#layout: #(#LayoutFrame 1 0.0 7 0.0 0 0.4 66 0)
|
672
|
533 |
#component:
|
519
|
534 |
#(#SpecCollection
|
672
|
535 |
#collection:
|
519
|
536 |
#(
|
|
537 |
#(#ComboBoxSpec
|
672
|
538 |
#name: 'defaultSizesComboBox'
|
|
539 |
#layout: #(#LayoutFrame 15 0.0 20 0.0 17 1.0 16 1.0)
|
|
540 |
#model: #selectionOfSize
|
|
541 |
#type: #string
|
|
542 |
#comboList: #listOfDefaultSizes
|
519
|
543 |
)
|
|
544 |
)
|
|
545 |
)
|
672
|
546 |
#label: 'Size'
|
|
547 |
#labelPosition: #topLeft
|
|
548 |
#style: #(#FontDescription #helvetica #medium #roman 12)
|
519
|
549 |
)
|
|
550 |
#(#FramedBoxSpec
|
672
|
551 |
#name: 'framedBox2'
|
737
|
552 |
#layout: #(#LayoutFrame 0 0.4 7 0.0 -1 1.0 66 0)
|
672
|
553 |
#component:
|
519
|
554 |
#(#SpecCollection
|
672
|
555 |
#collection:
|
519
|
556 |
#(
|
|
557 |
#(#ComboListSpec
|
672
|
558 |
#name: 'colorMapComboBox'
|
|
559 |
#layout: #(#LayoutFrame 15 0.0 20 0.0 18 1.0 16 1.0)
|
|
560 |
#model: #selectionOfColorMap
|
|
561 |
#comboList: #listOfColorMaps
|
|
562 |
#useIndex: false
|
519
|
563 |
)
|
|
564 |
)
|
|
565 |
)
|
672
|
566 |
#label: 'Color Map'
|
|
567 |
#labelPosition: #topLeft
|
|
568 |
#style: #(#FontDescription #helvetica #medium #roman 12)
|
519
|
569 |
)
|
|
570 |
)
|
|
571 |
)
|
672
|
572 |
#level: 1
|
519
|
573 |
)
|
672
|
574 |
#(#UISubSpecification
|
|
575 |
#name: 'UISubSpecification1'
|
737
|
576 |
#layout: #(#LayoutFrame 2 0.0 -26 1 -2 1.0 -2 1.0)
|
672
|
577 |
#majorKey: #ToolApplicationModel
|
|
578 |
#minorKey: #windowSpecForCommitWithoutChannels
|
519
|
579 |
)
|
|
580 |
)
|
|
581 |
)
|
|
582 |
)
|
|
583 |
! !
|
|
584 |
|
|
585 |
!ImageEditor class methodsFor:'menu specs'!
|
|
586 |
|
400
|
587 |
menu
|
737
|
588 |
"This resource specification was automatically generated
|
|
589 |
by the MenuEditor of ST/X."
|
400
|
590 |
|
737
|
591 |
"Do not manually edit this!! If it is corrupted,
|
|
592 |
the MenuEditor may not be able to read the specification."
|
400
|
593 |
|
|
594 |
"
|
|
595 |
MenuEditor new openOnClass:ImageEditor andSelector:#menu
|
|
596 |
(Menu new fromLiteralArrayEncoding:(ImageEditor menu)) startUp
|
|
597 |
"
|
|
598 |
|
|
599 |
<resource: #menu>
|
|
600 |
|
|
601 |
^
|
|
602 |
|
|
603 |
#(#Menu
|
|
604 |
|
|
605 |
#(
|
|
606 |
#(#MenuItem
|
672
|
607 |
#label: 'About'
|
|
608 |
#activeHelpKey: #about
|
|
609 |
#labelImage: #(#ResourceRetriever nil #menuIcon)
|
|
610 |
#submenuChannel: #menuAbout
|
400
|
611 |
)
|
|
612 |
#(#MenuItem
|
672
|
613 |
#label: 'File'
|
|
614 |
#translateLabel: true
|
|
615 |
#activeHelpKey: #file
|
|
616 |
#submenu:
|
400
|
617 |
#(#Menu
|
|
618 |
|
|
619 |
#(
|
|
620 |
#(#MenuItem
|
672
|
621 |
#label: 'New...'
|
|
622 |
#value: #newImage
|
|
623 |
#activeHelpKey: #fileNewImage
|
400
|
624 |
)
|
|
625 |
#(#MenuItem
|
672
|
626 |
#label: '-'
|
400
|
627 |
)
|
|
628 |
#(#MenuItem
|
672
|
629 |
#label: 'Load...'
|
|
630 |
#value: #loadFromClass
|
|
631 |
#activeHelpKey: #fileLoadFromClass
|
400
|
632 |
)
|
|
633 |
#(#MenuItem
|
672
|
634 |
#label: 'Load From File...'
|
|
635 |
#value: #loadFromFile
|
|
636 |
#activeHelpKey: #fileLoadFromFile
|
400
|
637 |
)
|
|
638 |
#(#MenuItem
|
672
|
639 |
#label: '-'
|
400
|
640 |
)
|
|
641 |
#(#MenuItem
|
672
|
642 |
#label: 'Save'
|
|
643 |
#value: #saveMethod
|
|
644 |
#activeHelpKey: #fileSaveMethod
|
|
645 |
#enabled: #imageIsLoaded
|
400
|
646 |
)
|
|
647 |
#(#MenuItem
|
672
|
648 |
#label: 'Save As...'
|
|
649 |
#value: #saveMethodAs
|
|
650 |
#activeHelpKey: #fileSaveMethodAs
|
|
651 |
#enabled: #imageIsLoaded
|
|
652 |
)
|
|
653 |
#(#MenuItem
|
|
654 |
#label: '-'
|
400
|
655 |
)
|
|
656 |
#(#MenuItem
|
672
|
657 |
#label: 'Save To File...'
|
|
658 |
#value: #saveImageFileAs
|
|
659 |
#activeHelpKey: #fileSaveAs
|
|
660 |
#enabled: #imageIsLoaded
|
400
|
661 |
)
|
|
662 |
#(#MenuItem
|
672
|
663 |
#label: 'Save Mask To File...'
|
|
664 |
#value: #saveImageMaskFileAs
|
|
665 |
#activeHelpKey: #fileSaveMaskAs
|
|
666 |
#enabled: #imageIsLoaded
|
400
|
667 |
)
|
|
668 |
#(#MenuItem
|
672
|
669 |
#label: '-'
|
400
|
670 |
)
|
|
671 |
#(#MenuItem
|
672
|
672 |
#label: 'Print'
|
|
673 |
#value: #print
|
|
674 |
#activeHelpKey: #filePrint
|
|
675 |
#enabled: #imageIsLoaded
|
400
|
676 |
)
|
|
677 |
#(#MenuItem
|
672
|
678 |
#label: '-'
|
400
|
679 |
)
|
|
680 |
#(#MenuItem
|
672
|
681 |
#label: 'Browse Class'
|
|
682 |
#value: #browseClass
|
|
683 |
#activeHelpKey: #fileBrowseClass
|
|
684 |
#enabled: #imageIsLoaded
|
400
|
685 |
)
|
|
686 |
#(#MenuItem
|
672
|
687 |
#label: '-'
|
400
|
688 |
)
|
|
689 |
#(#MenuItem
|
672
|
690 |
#label: 'Exit'
|
|
691 |
#translateLabel: true
|
|
692 |
#value: #closeRequest
|
|
693 |
#activeHelpKey: #fileExit
|
400
|
694 |
)
|
|
695 |
) nil
|
|
696 |
nil
|
|
697 |
)
|
|
698 |
)
|
|
699 |
#(#MenuItem
|
672
|
700 |
#label: 'Edit'
|
|
701 |
#activeHelpKey: #edit
|
|
702 |
#enabled: #imageIsLoaded
|
|
703 |
#submenu:
|
400
|
704 |
#(#Menu
|
|
705 |
|
|
706 |
#(
|
|
707 |
#(#MenuItem
|
672
|
708 |
#label: 'Undo'
|
|
709 |
#value: #undo
|
|
710 |
#activeHelpKey: #editUndo
|
|
711 |
#enabled: #valueOfCanUndo
|
400
|
712 |
)
|
|
713 |
#(#MenuItem
|
672
|
714 |
#label: '-'
|
400
|
715 |
)
|
|
716 |
#(#MenuItem
|
672
|
717 |
#label: 'Flip - Vertical'
|
|
718 |
#value: #flipVertical
|
|
719 |
#activeHelpKey: #editFlipVertical
|
400
|
720 |
)
|
|
721 |
#(#MenuItem
|
672
|
722 |
#label: 'Flip - Horizontal'
|
|
723 |
#value: #flipHorizontal
|
|
724 |
#activeHelpKey: #editFlipHorizontal
|
400
|
725 |
)
|
|
726 |
#(#MenuItem
|
672
|
727 |
#label: '-'
|
400
|
728 |
)
|
|
729 |
#(#MenuItem
|
672
|
730 |
#label: 'Resize...'
|
|
731 |
#value: #resizeImage
|
|
732 |
#activeHelpKey: #editResize
|
400
|
733 |
)
|
|
734 |
#(#MenuItem
|
672
|
735 |
#label: 'Magnify...'
|
|
736 |
#value: #magnifyImage
|
|
737 |
#activeHelpKey: #editMagnifyImage
|
400
|
738 |
)
|
|
739 |
#(#MenuItem
|
672
|
740 |
#label: 'Rotate...'
|
|
741 |
#value: #rotateImage
|
|
742 |
#activeHelpKey: #editRotate
|
400
|
743 |
)
|
|
744 |
#(#MenuItem
|
672
|
745 |
#label: '-'
|
400
|
746 |
)
|
|
747 |
#(#MenuItem
|
672
|
748 |
#label: 'Negative'
|
|
749 |
#value: #negativeImage
|
|
750 |
#activeHelpKey: #editNegate
|
400
|
751 |
)
|
|
752 |
) nil
|
|
753 |
nil
|
|
754 |
)
|
|
755 |
)
|
|
756 |
#(#MenuItem
|
672
|
757 |
#label: 'Color Map'
|
|
758 |
#activeHelpKey: #colorMap
|
|
759 |
#enabled: #imageIsLoaded
|
|
760 |
#submenu:
|
400
|
761 |
#(#Menu
|
|
762 |
|
|
763 |
#(
|
|
764 |
#(#MenuItem
|
672
|
765 |
#label: '8-Plane'
|
|
766 |
#activeHelpKey: #colorMap
|
|
767 |
#argument: '8-plane'
|
|
768 |
#indication: #colorMapMode:value:
|
|
769 |
)
|
|
770 |
#(#MenuItem
|
|
771 |
#label: '4-Plane'
|
|
772 |
#activeHelpKey: #colorMap
|
|
773 |
#argument: '4-plane'
|
|
774 |
#indication: #colorMapMode:value:
|
400
|
775 |
)
|
|
776 |
#(#MenuItem
|
672
|
777 |
#label: '2-Plane'
|
|
778 |
#activeHelpKey: #colorMap
|
|
779 |
#argument: '2-plane'
|
|
780 |
#indication: #colorMapMode:value:
|
400
|
781 |
)
|
|
782 |
#(#MenuItem
|
672
|
783 |
#label: '1-Plane'
|
|
784 |
#activeHelpKey: #colorMap
|
|
785 |
#argument: '1-plane'
|
|
786 |
#indication: #colorMapMode:value:
|
400
|
787 |
)
|
|
788 |
#(#MenuItem
|
672
|
789 |
#label: '-'
|
|
790 |
)
|
|
791 |
#(#MenuItem
|
|
792 |
#label: '8-Plane + Mask'
|
|
793 |
#activeHelpKey: #colorMap
|
|
794 |
#argument: '8-plane + mask'
|
|
795 |
#indication: #colorMapMode:value:
|
400
|
796 |
)
|
|
797 |
#(#MenuItem
|
672
|
798 |
#label: '4-Plane + Mask'
|
|
799 |
#activeHelpKey: #colorMap
|
|
800 |
#argument: '4-plane + mask'
|
|
801 |
#indication: #colorMapMode:value:
|
400
|
802 |
)
|
|
803 |
#(#MenuItem
|
672
|
804 |
#label: '2-Plane + Mask'
|
|
805 |
#activeHelpKey: #colorMap
|
|
806 |
#argument: '2-plane + mask'
|
|
807 |
#indication: #colorMapMode:value:
|
|
808 |
)
|
|
809 |
#(#MenuItem
|
|
810 |
#label: '1-Plane + Mask'
|
|
811 |
#activeHelpKey: #colorMap
|
|
812 |
#argument: '1-plane + mask'
|
|
813 |
#indication: #colorMapMode:value:
|
400
|
814 |
)
|
|
815 |
) nil
|
|
816 |
nil
|
|
817 |
)
|
|
818 |
)
|
|
819 |
#(#MenuItem
|
737
|
820 |
#label: 'Settings'
|
|
821 |
#submenu:
|
|
822 |
#(#Menu
|
|
823 |
|
|
824 |
#(
|
|
825 |
#(#MenuItem
|
|
826 |
#label: 'Fonts'
|
|
827 |
#submenuChannel: #menuFont
|
|
828 |
)
|
|
829 |
) nil
|
|
830 |
nil
|
|
831 |
)
|
|
832 |
)
|
|
833 |
#(#MenuItem
|
756
|
834 |
#label: 'History'
|
|
835 |
#activeHelpKey: #history
|
|
836 |
#submenuChannel: #menuHistory
|
|
837 |
)
|
|
838 |
#(#MenuItem
|
672
|
839 |
#label: 'Help'
|
|
840 |
#startGroup: #right
|
|
841 |
#activeHelpKey: #help
|
|
842 |
#submenuChannel: #menuHelp
|
400
|
843 |
)
|
|
844 |
) nil
|
|
845 |
nil
|
|
846 |
)
|
|
847 |
!
|
|
848 |
|
679
|
849 |
menuMouseButtonColors
|
737
|
850 |
"This resource specification was automatically generated
|
|
851 |
by the MenuEditor of ST/X."
|
679
|
852 |
|
737
|
853 |
"Do not manually edit this!! If it is corrupted,
|
|
854 |
the MenuEditor may not be able to read the specification."
|
679
|
855 |
|
|
856 |
"
|
|
857 |
MenuEditor new openOnClass:ImageEditor andSelector:#menuMouseButtonColors
|
|
858 |
(Menu new fromLiteralArrayEncoding:(ImageEditor menuMouseButtonColors)) startUp
|
|
859 |
"
|
|
860 |
|
|
861 |
<resource: #menu>
|
|
862 |
|
|
863 |
^
|
|
864 |
|
|
865 |
#(#Menu
|
|
866 |
|
|
867 |
#(
|
|
868 |
#(#MenuItem
|
|
869 |
#label: 'Left Mouse Button'
|
|
870 |
#nameKey: #leftMouseKeyButton
|
|
871 |
#activeHelpKey: #mouseKeyColorMode
|
|
872 |
#argument: '1'
|
|
873 |
#labelImage: #(#ResourceRetriever nil #leftMouseKeyIcon)
|
|
874 |
#indication: #mouseKeyColorMode:value:
|
|
875 |
)
|
|
876 |
#(#MenuItem
|
|
877 |
#label: 'Right Mouse Button'
|
|
878 |
#nameKey: #rightMouseKeyButton
|
|
879 |
#activeHelpKey: #mouseKeyColorMode
|
|
880 |
#argument: '2'
|
|
881 |
#labelImage: #(#ResourceRetriever nil #rightMouseKeyIcon)
|
|
882 |
#indication: #mouseKeyColorMode:value:
|
|
883 |
)
|
|
884 |
) nil
|
|
885 |
nil
|
|
886 |
)
|
|
887 |
!
|
|
888 |
|
400
|
889 |
menuToolbar
|
737
|
890 |
"This resource specification was automatically generated
|
|
891 |
by the MenuEditor of ST/X."
|
400
|
892 |
|
737
|
893 |
"Do not manually edit this!! If it is corrupted,
|
|
894 |
the MenuEditor may not be able to read the specification."
|
400
|
895 |
|
|
896 |
"
|
|
897 |
MenuEditor new openOnClass:ImageEditor andSelector:#menuToolbar
|
|
898 |
(Menu new fromLiteralArrayEncoding:(ImageEditor menuToolbar)) startUp
|
|
899 |
"
|
|
900 |
|
|
901 |
<resource: #menu>
|
|
902 |
|
|
903 |
^
|
|
904 |
|
|
905 |
#(#Menu
|
|
906 |
|
|
907 |
#(
|
|
908 |
#(#MenuItem
|
672
|
909 |
#label: 'newImage'
|
|
910 |
#isButton: true
|
|
911 |
#value: #newImage
|
|
912 |
#activeHelpKey: #fileNewImage
|
|
913 |
#labelImage: #(#ResourceRetriever nil #newIcon)
|
400
|
914 |
)
|
|
915 |
#(#MenuItem
|
672
|
916 |
#label: 'loadFromClass'
|
|
917 |
#isButton: true
|
|
918 |
#value: #loadFromClass
|
|
919 |
#activeHelpKey: #fileLoadFromClass
|
|
920 |
#labelImage: #(#ResourceRetriever nil #loadIcon)
|
|
921 |
)
|
|
922 |
#(#MenuItem
|
|
923 |
#label: 'saveMethod'
|
|
924 |
#isButton: true
|
|
925 |
#value: #saveMethod
|
|
926 |
#activeHelpKey: #fileSaveMethod
|
|
927 |
#enabled: #imageIsLoaded
|
|
928 |
#labelImage: #(#ResourceRetriever nil #saveIcon)
|
400
|
929 |
)
|
|
930 |
#(#MenuItem
|
672
|
931 |
#label: ''
|
400
|
932 |
)
|
|
933 |
#(#MenuItem
|
672
|
934 |
#label: ''
|
|
935 |
)
|
|
936 |
#(#MenuItem
|
|
937 |
#label: ''
|
|
938 |
)
|
|
939 |
#(#MenuItem
|
|
940 |
#label: ''
|
400
|
941 |
)
|
|
942 |
#(#MenuItem
|
672
|
943 |
#label: 'Point'
|
|
944 |
#activeHelpKey: #drawModePoint
|
|
945 |
#enabled: #imageIsLoaded
|
|
946 |
#argument: 'point'
|
|
947 |
#indication: #editMode:value:
|
400
|
948 |
)
|
|
949 |
#(#MenuItem
|
672
|
950 |
#label: 'Box'
|
|
951 |
#activeHelpKey: #drawModeBox
|
|
952 |
#enabled: #imageIsLoaded
|
|
953 |
#argument: 'box'
|
|
954 |
#indication: #editMode:value:
|
400
|
955 |
)
|
|
956 |
#(#MenuItem
|
672
|
957 |
#label: 'Filled Box'
|
|
958 |
#activeHelpKey: #drawModeFilledBox
|
|
959 |
#enabled: #imageIsLoaded
|
|
960 |
#argument: 'filledBox'
|
|
961 |
#indication: #editMode:value:
|
400
|
962 |
)
|
|
963 |
#(#MenuItem
|
672
|
964 |
#label: 'Fill'
|
|
965 |
#activeHelpKey: #drawModeFill
|
|
966 |
#enabled: #imageIsLoaded
|
|
967 |
#argument: 'fill'
|
|
968 |
#indication: #editMode:value:
|
400
|
969 |
)
|
|
970 |
#(#MenuItem
|
672
|
971 |
#label: 'Copy'
|
|
972 |
#activeHelpKey: #drawModeCopy
|
|
973 |
#enabled: #imageIsLoaded
|
|
974 |
#argument: 'copy'
|
|
975 |
#indication: #editMode:value:
|
400
|
976 |
)
|
|
977 |
#(#MenuItem
|
672
|
978 |
#label: 'Paste'
|
|
979 |
#activeHelpKey: #drawModePaste
|
|
980 |
#enabled: #imageIsLoaded
|
|
981 |
#argument: 'paste'
|
|
982 |
#indication: #editMode:value:
|
400
|
983 |
)
|
|
984 |
) nil
|
|
985 |
nil
|
|
986 |
)
|
|
987 |
! !
|
|
988 |
|
|
989 |
!ImageEditor methodsFor:'accessing'!
|
|
990 |
|
|
991 |
image
|
|
992 |
|
|
993 |
^self imageEditView image
|
|
994 |
!
|
|
995 |
|
|
996 |
postOpenAction: anAction
|
|
997 |
|
|
998 |
postOpenAction := anAction
|
|
999 |
! !
|
|
1000 |
|
|
1001 |
!ImageEditor methodsFor:'accessing - views'!
|
|
1002 |
|
487
|
1003 |
coordLabel
|
|
1004 |
|
|
1005 |
^builder componentAt: #coordLabel
|
|
1006 |
!
|
|
1007 |
|
400
|
1008 |
imageEditView
|
|
1009 |
|
|
1010 |
^(builder componentAt: #imageEditView) subViews first
|
|
1011 |
!
|
|
1012 |
|
|
1013 |
imagePreView
|
|
1014 |
|
|
1015 |
^(builder componentAt: #imagePreView) subViews first
|
475
|
1016 |
! !
|
|
1017 |
|
400
|
1018 |
!ImageEditor methodsFor:'aspects'!
|
|
1019 |
|
|
1020 |
imageIsLoaded
|
|
1021 |
|
|
1022 |
|holder|
|
|
1023 |
(holder := builder bindingAt:#imageIsLoaded) isNil ifTrue:[
|
|
1024 |
builder aspectAt:#imageIsLoaded put:(holder := false asValue).
|
|
1025 |
].
|
|
1026 |
^ holder
|
|
1027 |
!
|
|
1028 |
|
|
1029 |
listOfColors
|
|
1030 |
|
|
1031 |
|holder|
|
|
1032 |
(holder := builder bindingAt:#listOfColors) isNil ifTrue:[
|
|
1033 |
builder aspectAt:#listOfColors put:(holder := List new).
|
|
1034 |
].
|
|
1035 |
^ holder
|
|
1036 |
!
|
|
1037 |
|
|
1038 |
selectionOfColor
|
|
1039 |
|
|
1040 |
|holder|
|
|
1041 |
(holder := builder bindingAt:#selectionOfColor) isNil ifTrue:[
|
|
1042 |
builder aspectAt:#selectionOfColor put:(
|
|
1043 |
holder := AspectAdaptor new subject:self; forAspect:#selectedColorIndex).
|
|
1044 |
].
|
|
1045 |
^ holder
|
|
1046 |
!
|
|
1047 |
|
|
1048 |
valueOfMagnification
|
|
1049 |
|
|
1050 |
|holder|
|
|
1051 |
(holder := builder bindingAt:#valueOfMagnification) isNil ifTrue:[
|
|
1052 |
builder aspectAt:#valueOfMagnification put:(
|
|
1053 |
holder := AspectAdaptor new subject:self; forAspect:#magnification)
|
|
1054 |
].
|
|
1055 |
^ holder
|
|
1056 |
! !
|
|
1057 |
|
672
|
1058 |
!ImageEditor methodsFor:'help'!
|
|
1059 |
|
|
1060 |
defaultInfoLabel
|
|
1061 |
|
|
1062 |
(self imageEditView resourceClass isSymbol and: [(Smalltalk at: self imageEditView resourceClass) isClass])
|
|
1063 |
ifTrue:
|
|
1064 |
[
|
|
1065 |
^self imageEditView resourceClass, ' >> ', self imageEditView resourceSelector
|
|
1066 |
].
|
|
1067 |
^'No class defined'
|
674
|
1068 |
!
|
|
1069 |
|
702
|
1070 |
openDocumentation
|
674
|
1071 |
|
763
|
1072 |
self openHTMLDocument: 'tools/uipainter/ImageEditor.html'
|
|
1073 |
|
672
|
1074 |
! !
|
|
1075 |
|
400
|
1076 |
!ImageEditor methodsFor:'menu modes'!
|
|
1077 |
|
|
1078 |
colorMapMode: aMode
|
|
1079 |
|
|
1080 |
^colorMapMode = aMode
|
|
1081 |
!
|
|
1082 |
|
|
1083 |
colorMapMode: aMode value: aValue
|
|
1084 |
|
405
|
1085 |
|depth newColorMap newImage image newColors realColorMap oldFileName|
|
400
|
1086 |
|
|
1087 |
newColorMap := self class listOfColorMaps at: aMode.
|
|
1088 |
depth := (newColorMap size log: 2) asInteger.
|
|
1089 |
newImage := (Image implementorForDepth: depth) new.
|
|
1090 |
oldFileName := self image fileName.
|
|
1091 |
Object errorSignal handle:
|
|
1092 |
[:ex|
|
|
1093 |
Object errorSignal handle:
|
|
1094 |
[:ex|
|
|
1095 |
^self warn: 'Convertation failed!!'
|
|
1096 |
]
|
|
1097 |
do:
|
|
1098 |
[
|
|
1099 |
self image colorsFromX:0 y:0 toX:(self image width-1) y:(self image height-1) do:
|
|
1100 |
[:x :y :clr |
|
|
1101 |
(newColorMap includes: clr)
|
|
1102 |
ifTrue: [self image colorAtX:x y:y put:clr]
|
|
1103 |
ifFalse: [self image colorAtX:x y:y put: self image colorMap first]
|
|
1104 |
].
|
|
1105 |
image := newImage fromImage: self image.
|
|
1106 |
].
|
|
1107 |
]
|
|
1108 |
do:
|
|
1109 |
[
|
|
1110 |
image := newImage fromImage: self image
|
|
1111 |
].
|
|
1112 |
(String fromString: aMode) reverse readStream nextWord reverse = 'mask'
|
|
1113 |
ifTrue:
|
|
1114 |
[
|
|
1115 |
image mask isNil
|
|
1116 |
ifTrue:
|
|
1117 |
[
|
|
1118 |
image mask: (Depth1Image fromImage: (image asThresholdMonochromeImage: 0.1)).
|
|
1119 |
].
|
|
1120 |
]
|
|
1121 |
ifFalse:
|
|
1122 |
[
|
|
1123 |
image mask: nil.
|
405
|
1124 |
].
|
|
1125 |
realColorMap := OrderedCollection new.
|
|
1126 |
image realColorMap do:
|
|
1127 |
[:clr|
|
|
1128 |
(realColorMap includes: clr) ifFalse: [realColorMap add: clr]
|
400
|
1129 |
].
|
405
|
1130 |
newColors := realColorMap copyFrom: 1 to: (newColorMap size min: realColorMap size).
|
400
|
1131 |
newColorMap do:
|
|
1132 |
[:clr|
|
|
1133 |
((newColors size < newColorMap size) and: [(newColors includes: clr) not])
|
|
1134 |
ifTrue:
|
|
1135 |
[
|
|
1136 |
newColors add: clr
|
|
1137 |
]
|
405
|
1138 |
].
|
400
|
1139 |
image colorMap: newColors.
|
|
1140 |
colorMapMode := aMode.
|
|
1141 |
(self imageEditView image: image) notNil
|
|
1142 |
ifTrue:
|
|
1143 |
[
|
|
1144 |
self image fileName: oldFileName.
|
|
1145 |
self listOfColors contents: image colorMap.
|
|
1146 |
self findColorMapMode.
|
694
|
1147 |
self updateLabelsAndHistory.
|
400
|
1148 |
]
|
|
1149 |
!
|
|
1150 |
|
|
1151 |
editMode: aMode
|
|
1152 |
|
|
1153 |
^self imageEditView editMode = aMode
|
|
1154 |
!
|
|
1155 |
|
|
1156 |
editMode: aMode value: aValue
|
|
1157 |
|
|
1158 |
self imageEditView editMode: aMode
|
|
1159 |
!
|
|
1160 |
|
|
1161 |
mouseKeyColorMode: aMode
|
|
1162 |
|
|
1163 |
^self imageEditView mouseKeyColorMode = aMode
|
|
1164 |
!
|
|
1165 |
|
|
1166 |
mouseKeyColorMode: aMode value: aValue
|
|
1167 |
|
|
1168 |
self imageEditView mouseKeyColorMode: aMode.
|
|
1169 |
|
|
1170 |
self selectionOfColor value: (self listOfColors indexOf: self imageEditView selectedColor).
|
|
1171 |
! !
|
|
1172 |
|
|
1173 |
!ImageEditor methodsFor:'private'!
|
|
1174 |
|
|
1175 |
findColorMapMode
|
|
1176 |
|
|
1177 |
self image depth > 8 ifTrue: [colorMapMode := ''. self listOfColors removeAll. ^nil].
|
|
1178 |
colorMapMode := self image depth printString, '-plane'.
|
|
1179 |
self listOfColors isEmpty
|
|
1180 |
ifTrue:
|
|
1181 |
[
|
|
1182 |
self colorMapMode: colorMapMode value: nil
|
|
1183 |
].
|
756
|
1184 |
self imageEditView selectColor: (Array with: (self listOfColors at: 1) with: (self listOfColors at: 2 ifAbsent: [self listOfColors at: 1])).
|
400
|
1185 |
self image mask notNil
|
|
1186 |
ifTrue:
|
|
1187 |
[
|
|
1188 |
colorMapMode := colorMapMode, ' + mask'.
|
|
1189 |
self listOfColors addFirst: (Color basicNew setColorId:0).
|
756
|
1190 |
self imageEditView selectColor: (Array with: (self listOfColors at: 1 ifAbsent: [self listOfColors at: 2]) with: (self listOfColors at: 1)).
|
400
|
1191 |
].
|
|
1192 |
self selectionOfColor value: 0.
|
|
1193 |
self selectionOfColor value: (self listOfColors indexOf: self imageEditView selectedColor).
|
|
1194 |
!
|
|
1195 |
|
449
|
1196 |
updateForNoneImage
|
|
1197 |
|
|
1198 |
self imageIsLoaded value: false.
|
|
1199 |
self listOfColors removeAll.
|
|
1200 |
self imagePreView image: nil
|
|
1201 |
|
|
1202 |
|
|
1203 |
|
|
1204 |
|
|
1205 |
!
|
|
1206 |
|
694
|
1207 |
updateLabelsAndHistory
|
400
|
1208 |
|
|
1209 |
self imageIsLoaded value: self image notNil.
|
|
1210 |
|
|
1211 |
self image isNil ifTrue: [^nil].
|
|
1212 |
|
|
1213 |
self updateInfoLabel.
|
|
1214 |
|
|
1215 |
self imageEditView resourceMessage asCollectionOfWords size = 2
|
|
1216 |
ifTrue: [self addToHistory: self imageEditView resourceMessage -> #loadFromMessage:].
|
|
1217 |
|
|
1218 |
self image fileName notNil
|
|
1219 |
ifTrue: [self addToHistory: self image fileName -> #loadFromFile:].
|
|
1220 |
|
|
1221 |
|
|
1222 |
|
|
1223 |
! !
|
|
1224 |
|
535
|
1225 |
!ImageEditor methodsFor:'queries'!
|
|
1226 |
|
|
1227 |
preferredExtent
|
|
1228 |
|
|
1229 |
^super preferredExtent max: (Screen current width//3)@(Screen current height//3.5)
|
|
1230 |
|
|
1231 |
|
|
1232 |
! !
|
|
1233 |
|
400
|
1234 |
!ImageEditor methodsFor:'selection'!
|
|
1235 |
|
|
1236 |
magnification
|
|
1237 |
|
|
1238 |
(builder componentAt: #imageEditView) isNil ifTrue: [^1].
|
|
1239 |
^self imageEditView magnification x
|
|
1240 |
!
|
|
1241 |
|
|
1242 |
magnification: aValue
|
|
1243 |
|
|
1244 |
|magnification|
|
|
1245 |
magnification := aValue asInteger asPoint.
|
|
1246 |
(magnification = self imageEditView magnification) | (magnification = (0@0)) ifTrue: [^nil].
|
|
1247 |
self imageEditView magnification: magnification
|
|
1248 |
!
|
|
1249 |
|
|
1250 |
selectedColorIndex
|
|
1251 |
|
|
1252 |
^selectedColorIndex
|
|
1253 |
!
|
|
1254 |
|
|
1255 |
selectedColorIndex: anIndex
|
|
1256 |
|
|
1257 |
selectedColorIndex := anIndex.
|
|
1258 |
self imageEditView selectedColor: (self listOfColors at: anIndex ifAbsent: [^nil])
|
|
1259 |
|
|
1260 |
! !
|
|
1261 |
|
|
1262 |
!ImageEditor methodsFor:'startup / release'!
|
|
1263 |
|
|
1264 |
closeRequest
|
|
1265 |
|
|
1266 |
self imageEditView checkModified ifTrue:[super closeRequest]
|
|
1267 |
|
|
1268 |
!
|
|
1269 |
|
|
1270 |
open
|
|
1271 |
|
|
1272 |
super open.
|
444
|
1273 |
|
672
|
1274 |
self imageEditView masterApplication: self
|
400
|
1275 |
!
|
|
1276 |
|
|
1277 |
postOpenWith:aBuilder
|
|
1278 |
|
415
|
1279 |
self imageEditView masterApplication: self.
|
400
|
1280 |
postOpenAction notNil ifTrue: [postOpenAction value].
|
|
1281 |
super postOpenWith:aBuilder.
|
|
1282 |
!
|
|
1283 |
|
|
1284 |
reOpen
|
|
1285 |
|
|
1286 |
self imageEditView checkModified ifTrue:[super reOpen]
|
|
1287 |
|
|
1288 |
! !
|
|
1289 |
|
|
1290 |
!ImageEditor methodsFor:'user actions - editing'!
|
|
1291 |
|
|
1292 |
browseClass
|
|
1293 |
|
|
1294 |
SystemBrowser openInClass: (Smalltalk at: self imageEditView resourceClass ifAbsent: [^nil]) class selector: self imageEditView resourceSelector
|
|
1295 |
!
|
|
1296 |
|
|
1297 |
flipHorizontal
|
|
1298 |
|
|
1299 |
self imageEditView flipHorizontal
|
|
1300 |
!
|
|
1301 |
|
|
1302 |
flipVertical
|
|
1303 |
|
|
1304 |
self imageEditView flipVertical
|
|
1305 |
!
|
|
1306 |
|
|
1307 |
magnifyDown
|
|
1308 |
|
|
1309 |
self valueOfMagnification value > 1
|
|
1310 |
ifTrue:
|
|
1311 |
[
|
|
1312 |
self valueOfMagnification value: self valueOfMagnification value - 1
|
|
1313 |
]
|
|
1314 |
!
|
|
1315 |
|
|
1316 |
magnifyImage
|
|
1317 |
|
|
1318 |
self imageEditView magnifyImage.
|
|
1319 |
self updateInfoLabel
|
|
1320 |
!
|
|
1321 |
|
|
1322 |
magnifyUp
|
|
1323 |
|
|
1324 |
self valueOfMagnification value < 99
|
|
1325 |
ifTrue:
|
|
1326 |
[
|
|
1327 |
self valueOfMagnification value: self valueOfMagnification value + 1
|
|
1328 |
]
|
|
1329 |
!
|
|
1330 |
|
|
1331 |
negativeImage
|
|
1332 |
|
|
1333 |
self imageEditView negativeImage.
|
|
1334 |
self listOfColors removeAll.
|
|
1335 |
self findColorMapMode.
|
|
1336 |
!
|
|
1337 |
|
|
1338 |
resizeImage
|
|
1339 |
|
|
1340 |
self imageEditView resizeImage.
|
|
1341 |
self updateInfoLabel
|
|
1342 |
!
|
|
1343 |
|
|
1344 |
rotateImage
|
|
1345 |
|
|
1346 |
self imageEditView rotateImage.
|
|
1347 |
self updateInfoLabel
|
|
1348 |
!
|
|
1349 |
|
|
1350 |
undo
|
|
1351 |
|
|
1352 |
self imageEditView undo
|
|
1353 |
! !
|
|
1354 |
|
|
1355 |
!ImageEditor methodsFor:'user actions - loading'!
|
|
1356 |
|
|
1357 |
loadFromClass
|
|
1358 |
|
574
|
1359 |
(self imageEditView loadFromClass) notNil
|
|
1360 |
ifTrue:
|
|
1361 |
[
|
|
1362 |
self image notNil
|
|
1363 |
ifTrue:
|
|
1364 |
[
|
|
1365 |
self listOfColors contents: self image usedColors asSet asOrderedCollection.
|
|
1366 |
self findColorMapMode.
|
694
|
1367 |
self updateLabelsAndHistory.
|
574
|
1368 |
]
|
|
1369 |
ifFalse:
|
|
1370 |
[
|
|
1371 |
self updateForNoneImage
|
|
1372 |
]
|
|
1373 |
]
|
400
|
1374 |
!
|
|
1375 |
|
|
1376 |
loadFromFile
|
|
1377 |
|
|
1378 |
self loadFromFile:
|
|
1379 |
(FileSelectionBrowser
|
756
|
1380 |
request: 'Load Image From'
|
|
1381 |
fileName: (self image notNil ifTrue: [self image fileName] ifFalse: [nil])
|
|
1382 |
withFileFilters: FileSelectionBrowser loadImageFileNameFilters)
|
400
|
1383 |
!
|
|
1384 |
|
|
1385 |
loadFromFile: aFileName
|
|
1386 |
|
461
|
1387 |
(self imageEditView loadFromFile: aFileName) notNil
|
450
|
1388 |
ifTrue:
|
|
1389 |
[
|
461
|
1390 |
self image notNil
|
400
|
1391 |
ifTrue:
|
461
|
1392 |
[
|
|
1393 |
self image colorMap notNil
|
|
1394 |
ifTrue:
|
|
1395 |
[
|
|
1396 |
self listOfColors contents: self image usedColors asSet.
|
|
1397 |
]
|
|
1398 |
ifFalse:
|
|
1399 |
[
|
|
1400 |
self listOfColors removeAll.
|
|
1401 |
].
|
|
1402 |
self findColorMapMode.
|
694
|
1403 |
self updateLabelsAndHistory.
|
400
|
1404 |
]
|
|
1405 |
ifFalse:
|
|
1406 |
[
|
461
|
1407 |
self updateForNoneImage
|
|
1408 |
]
|
449
|
1409 |
]
|
400
|
1410 |
!
|
|
1411 |
|
|
1412 |
loadFromImage: image
|
|
1413 |
|
450
|
1414 |
self imageEditView image: image.
|
|
1415 |
self image notNil
|
400
|
1416 |
ifTrue:
|
|
1417 |
[
|
|
1418 |
self image colorMap notNil
|
|
1419 |
ifTrue:
|
|
1420 |
[
|
|
1421 |
self listOfColors contents: self image usedColors asSet asOrderedCollection.
|
|
1422 |
]
|
|
1423 |
ifFalse:
|
|
1424 |
[
|
|
1425 |
self listOfColors removeAll.
|
|
1426 |
].
|
|
1427 |
self findColorMapMode.
|
694
|
1428 |
self updateLabelsAndHistory.
|
400
|
1429 |
]
|
449
|
1430 |
ifFalse:
|
|
1431 |
[
|
|
1432 |
self updateForNoneImage
|
|
1433 |
]
|
400
|
1434 |
!
|
|
1435 |
|
|
1436 |
loadFromMessage: aMessage
|
|
1437 |
|
461
|
1438 |
(self imageEditView loadFromMessage: aMessage) notNil
|
400
|
1439 |
ifTrue:
|
|
1440 |
[
|
461
|
1441 |
self image notNil
|
|
1442 |
ifTrue:
|
|
1443 |
[
|
|
1444 |
self listOfColors contents: self image usedColors asSet asOrderedCollection.
|
|
1445 |
self findColorMapMode.
|
694
|
1446 |
self updateLabelsAndHistory.
|
461
|
1447 |
]
|
|
1448 |
ifFalse:
|
|
1449 |
[
|
|
1450 |
self updateForNoneImage
|
|
1451 |
]
|
400
|
1452 |
]
|
|
1453 |
!
|
|
1454 |
|
415
|
1455 |
loadFromOrPrepareForMessage: aMessage
|
|
1456 |
|
|
1457 |
(self imageEditView loadFromMessage: aMessage) notNil
|
|
1458 |
ifTrue:
|
|
1459 |
[
|
|
1460 |
self listOfColors contents: self image usedColors asSet asOrderedCollection.
|
|
1461 |
self findColorMapMode.
|
|
1462 |
]
|
|
1463 |
ifFalse:
|
|
1464 |
[
|
|
1465 |
self imageEditView resourceMessage: aMessage.
|
694
|
1466 |
].
|
|
1467 |
self updateLabelsAndHistory.
|
415
|
1468 |
!
|
|
1469 |
|
400
|
1470 |
newImage
|
|
1471 |
|
|
1472 |
|aspects|
|
|
1473 |
aspects := IdentityDictionary new
|
|
1474 |
at:#listOfSizes put: self class listOfDefaultSizes asValue;
|
|
1475 |
at:#listOfColorMaps put: self class listOfColorMaps keys asSortedCollection asValue;
|
|
1476 |
at:#selectionOfSize put: self class listOfDefaultSizes first copy asValue;
|
|
1477 |
at:#selectionOfColorMap put: self class listOfColorMaps keys asSortedCollection first asValue;
|
|
1478 |
yourself.
|
|
1479 |
|
|
1480 |
(self openDialogInterface:#windowSpecForNewImage withBindings:aspects)
|
|
1481 |
ifTrue:
|
|
1482 |
[
|
|
1483 |
|width height cMap imageClass image|
|
|
1484 |
width := 128 min: (Integer readFromString: ((aspects at:#selectionOfSize) value upTo: $x) onError:[24]).
|
|
1485 |
height := 128 min: (Integer readFromString: ((aspects at:#selectionOfSize) value copy reverse upTo: $x) reverse onError:[24]).
|
|
1486 |
|
|
1487 |
cMap := (self class listOfColorMaps at: (colorMapMode := (aspects at:#selectionOfColorMap) value)).
|
|
1488 |
imageClass := Image implementorForDepth: ((cMap size log: 2) asInteger).
|
|
1489 |
image := imageClass width: width height: height fromArray: (ByteArray new: width*height).
|
|
1490 |
|
|
1491 |
(colorMapMode copy reverse readStream nextWord reverse = 'mask')
|
|
1492 |
ifTrue:
|
|
1493 |
[
|
|
1494 |
image mask: (Depth1Image width: width height: height depth: 1 fromArray: (ByteArray new: width*height)) clearMaskedPixels.
|
|
1495 |
].
|
|
1496 |
image colorMap: cMap.
|
|
1497 |
image fillRectangleX:0 y:0 width:width height:height with:Color white.
|
|
1498 |
(self imageEditView image: image) notNil
|
|
1499 |
ifTrue:
|
|
1500 |
[
|
|
1501 |
self listOfColors contents: cMap.
|
|
1502 |
self findColorMapMode.
|
694
|
1503 |
self updateLabelsAndHistory
|
400
|
1504 |
]
|
|
1505 |
].
|
|
1506 |
! !
|
|
1507 |
|
|
1508 |
!ImageEditor methodsFor:'user actions - saving'!
|
|
1509 |
|
|
1510 |
print
|
|
1511 |
|
|
1512 |
self imageEditView print
|
|
1513 |
!
|
|
1514 |
|
|
1515 |
saveImageFile
|
|
1516 |
|
672
|
1517 |
self imageEditView save
|
400
|
1518 |
!
|
|
1519 |
|
|
1520 |
saveImageFileAs
|
|
1521 |
|
|
1522 |
self imageEditView saveImageFileAs.
|
694
|
1523 |
self updateLabelsAndHistory
|
400
|
1524 |
!
|
|
1525 |
|
|
1526 |
saveImageMaskFileAs
|
|
1527 |
|
|
1528 |
self imageEditView saveImageMaskFileAs
|
|
1529 |
!
|
|
1530 |
|
|
1531 |
saveMethod
|
|
1532 |
|
672
|
1533 |
self imageEditView saveMethod notNil
|
400
|
1534 |
ifTrue:
|
|
1535 |
[
|
694
|
1536 |
self updateLabelsAndHistory
|
400
|
1537 |
]
|
|
1538 |
!
|
|
1539 |
|
|
1540 |
saveMethodAs
|
|
1541 |
|
|
1542 |
self imageEditView saveMethodAs notNil
|
|
1543 |
ifTrue:
|
|
1544 |
[
|
694
|
1545 |
self updateLabelsAndHistory
|
400
|
1546 |
]
|
|
1547 |
! !
|
|
1548 |
|
|
1549 |
!ImageEditor class methodsFor:'documentation'!
|
|
1550 |
|
|
1551 |
version
|
|
1552 |
^ '$Header$'
|
|
1553 |
! !
|