45 ImageEditView Image |
45 ImageEditView Image |
46 |
46 |
47 [author:] |
47 [author:] |
48 Thomas Zwick, eXept Software AG |
48 Thomas Zwick, eXept Software AG |
49 " |
49 " |
50 ! |
|
51 |
|
52 listOfColors |
|
53 |
|
54 ^List new |
|
55 |
|
56 ! ! |
50 ! ! |
57 |
51 |
58 !ImageEditor class methodsFor:'instance creation'! |
52 !ImageEditor class methodsFor:'instance creation'! |
59 |
53 |
60 openModalOnClass: aClass andSelector: aSelector |
54 openModalOnClass: aClass andSelector: aSelector |
61 |
55 "opens modal the Image Editor on aClass and aSelector" |
62 "self openModalOnClass: self andSelector: #leftMouseKeyIcon" |
56 " |
63 |
57 self openModalOnClass: self andSelector: #leftMouseKeyIcon |
64 |imageEditor imageEditView className resourceClassName resourceSelector| |
58 " |
|
59 |
|
60 |imageEditor imageEditView className resourceClassName resourceSelector| |
|
61 |
65 imageEditor := self new. |
62 imageEditor := self new. |
|
63 |
66 aClass isClass ifTrue: [className := aClass name]. |
64 aClass isClass ifTrue: [className := aClass name]. |
67 aClass isString ifTrue: [className := aClass]. |
65 aClass isString ifTrue:[className := aClass]. |
68 |
66 |
69 imageEditor postOpenAction: [imageEditView := imageEditor imageEditView. imageEditor loadFromOrPrepareForMessage: className, ' ', aSelector]. |
67 imageEditor postOpenAction: [imageEditView := imageEditor imageEditView. imageEditor loadFromOrPrepareForMessage: className, ' ', aSelector]. |
70 imageEditor openModal. |
68 imageEditor openModal. |
71 |
69 |
72 resourceClassName := imageEditView resourceClass. |
70 resourceClassName := imageEditView resourceClass. |
73 resourceSelector := imageEditView resourceSelector. |
71 resourceSelector := imageEditView resourceSelector. |
74 |
72 |
75 (className asString ~= resourceClassName) | (aSelector asString ~= resourceSelector) |
73 (className asString ~= resourceClassName) | (aSelector asString ~= resourceSelector) |
76 ifTrue: [^resourceClassName, ' ', resourceSelector] |
74 ifTrue: [^resourceClassName, ' ', resourceSelector] |
77 ifFalse:[^nil] |
75 ifFalse:[^nil] |
78 ! |
76 ! |
79 |
77 |
80 openOnClass: aClass andSelector: aSelector |
78 openOnClass: aClass andSelector: aSelector |
81 |
79 "opens the Image Editor on aClass and aSelector" |
82 "self openOnClass: self andSelector: #leftMouseKeyIcon" |
80 " |
|
81 self openOnClass: self andSelector: #leftMouseKeyIcon |
|
82 " |
83 |
83 |
84 ^self open loadFromMessage: aClass name, ' ', aSelector |
84 ^self open loadFromMessage: aClass name, ' ', aSelector |
85 ! |
85 ! |
86 |
86 |
87 openOnFile: image |
87 openOnFile: aFileName |
88 |
88 "opens the Image Editor on aFileName" |
89 "self openOnFile: 'bitmaps/SmalltalkX.xbm'" |
89 " |
90 |
90 self openOnFile: 'bitmaps/SmalltalkX.xbm' |
91 ^self open loadFromFile: image |
91 " |
92 ! |
92 |
93 |
93 ^self open loadFromFile: aFileName |
94 openOnImage: image |
94 ! |
95 |
95 |
96 "self openOnImage: self stxIcon" |
96 openOnImage: anImage |
97 |
97 "opens the Image Editor on anImage" |
98 ^self open loadFromImage: image |
98 " |
|
99 self openOnImage: self stxIcon |
|
100 " |
|
101 |
|
102 ^self open loadFromImage: anImage |
99 ! ! |
103 ! ! |
100 |
104 |
101 !ImageEditor class methodsFor:'accessing'! |
105 !ImageEditor class methodsFor:'accessing'! |
102 |
106 |
103 listOfColorMaps |
107 listOfColorMaps |
|
108 "returns the list of default color maps for a new image" |
104 |
109 |
105 |colorMap| |
110 |colorMap| |
106 (colorMap := OrderedCollection new) |
111 (colorMap := OrderedCollection new) |
107 add: Color black; |
112 add: Color black; |
108 add: Color white; |
113 add: Color white; |
290 constantNamed:#'ImageEditor rightMouseKeyIcon' |
296 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]! ! |
297 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 |
298 |
293 !ImageEditor class methodsFor:'interface specs'! |
299 !ImageEditor class methodsFor:'interface specs'! |
294 |
300 |
295 windowSpec |
301 dialogSpecForNewImage |
296 "This resource specification was automatically generated |
302 "This resource specification was automatically generated |
297 by the UIPainter of ST/X." |
303 by the UIPainter of ST/X." |
298 |
304 |
299 "Do not manually edit this!! If it is corrupted, |
305 "Do not manually edit this!! If it is corrupted, |
300 the UIPainter may not be able to read the specification." |
306 the UIPainter may not be able to read the specification." |
301 |
307 |
302 " |
308 " |
303 UIPainter new openOnClass:ImageEditor andSelector:#windowSpec |
309 UIPainter new openOnClass:ImageEditor andSelector:#dialogSpecForNewImage |
304 ImageEditor new openInterface:#windowSpec |
310 ImageEditor new openInterface:#dialogSpecForNewImage |
305 ImageEditor open |
|
306 " |
|
307 |
|
308 <resource: #canvas> |
|
309 |
|
310 ^ |
|
311 |
|
312 #(#FullSpec |
|
313 #window: |
|
314 #(#WindowSpec |
|
315 #name: 'Image Editor' |
|
316 #layout: #(#LayoutFrame 188 0 318 0 687 0 663 0) |
|
317 #label: 'Image Editor' |
|
318 #min: #(#Point 400 320) |
|
319 #max: #(#Point 1152 900) |
|
320 #bounds: #(#Rectangle 188 318 688 664) |
|
321 #menu: #menu |
|
322 #usePreferredExtent: false |
|
323 ) |
|
324 #component: |
|
325 #(#SpecCollection |
|
326 #collection: |
|
327 #( |
|
328 #(#MenuPanelSpec |
|
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 |
|
334 ) |
|
335 #(#VariableHorizontalPanelSpec |
|
336 #name: 'variableHorizontalPanel1' |
|
337 #layout: #(#LayoutFrame 0 0.0 34 0.0 0 1.0 -26 1.0) |
|
338 #component: |
|
339 #(#SpecCollection |
|
340 #collection: |
|
341 #( |
|
342 #(#ViewSpec |
|
343 #name: 'view1' |
|
344 #component: |
|
345 #(#SpecCollection |
|
346 #collection: |
|
347 #( |
|
348 #(#VariableVerticalPanelSpec |
|
349 #name: 'VariableVerticalPanel1' |
|
350 #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
351 #component: |
|
352 #(#SpecCollection |
|
353 #collection: |
|
354 #( |
|
355 #(#ViewSpec |
|
356 #name: 'View1' |
|
357 #component: |
|
358 #(#SpecCollection |
|
359 #collection: |
|
360 #( |
|
361 #(#MenuPanelSpec |
|
362 #name: 'MouseButtonColorToolBar' |
|
363 #layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 24 0) |
|
364 #menu: #menuMouseButtonColors |
|
365 ) |
|
366 #(#DataSetSpec |
|
367 #name: 'colorDataSetView' |
|
368 #layout: #(#LayoutFrame 0 0.0 26 0.0 0 1.0 0 1.0) |
|
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 |
|
376 #level: -1 |
|
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 ) |
|
404 ) |
|
405 ) |
|
406 #(#ArbitraryComponentSpec |
|
407 #name: 'imagePreView' |
|
408 #activeHelpKey: #previewView |
|
409 #hasHorizontalScrollBar: true |
|
410 #hasVerticalScrollBar: true |
|
411 #miniScrollerHorizontal: true |
|
412 #miniScrollerVertical: true |
|
413 #component: #ImageView |
|
414 #hasBorder: false |
|
415 ) |
|
416 ) |
|
417 ) |
|
418 #handles: #(#Any 0.723776 1.0) |
|
419 ) |
|
420 ) |
|
421 ) |
|
422 ) |
|
423 #(#ViewSpec |
|
424 #name: 'view2' |
|
425 #component: |
|
426 #(#SpecCollection |
|
427 #collection: |
|
428 #( |
|
429 #(#ArbitraryComponentSpec |
|
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 |
|
436 ) |
|
437 #(#LabelSpec |
|
438 #name: 'coordLabel' |
|
439 #layout: #(#LayoutFrame 2 0.0 -22 1 -83 1.0 0 1.0) |
|
440 #level: -1 |
|
441 #adjust: #left |
|
442 #resizeForLabel: false |
|
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 |
|
472 ) |
|
473 ) |
|
474 ) |
|
475 #level: -1 |
|
476 ) |
|
477 ) |
|
478 ) |
|
479 #handles: #(#Any 0.276 1.0) |
|
480 ) |
|
481 #(#UISubSpecification |
|
482 #name: 'infoBarSubSpec' |
|
483 #layout: #(#LayoutFrame 0 0.0 -24 1 0 1.0 0 1.0) |
|
484 #majorKey: #ToolApplicationModel |
|
485 #minorKey: #windowSpecForInfoBar |
|
486 ) |
|
487 ) |
|
488 ) |
|
489 ) |
|
490 ! |
|
491 |
|
492 windowSpecForNewImage |
|
493 "This resource specification was automatically generated |
|
494 by the UIPainter of ST/X." |
|
495 |
|
496 "Do not manually edit this!! If it is corrupted, |
|
497 the UIPainter may not be able to read the specification." |
|
498 |
|
499 " |
|
500 UIPainter new openOnClass:ImageEditor andSelector:#windowSpecForNewImage |
|
501 ImageEditor new openInterface:#windowSpecForNewImage |
|
502 " |
311 " |
503 |
312 |
504 <resource: #canvas> |
313 <resource: #canvas> |
505 |
314 |
506 ^ |
315 ^ |
578 #minorKey: #windowSpecForCommitWithoutChannels |
387 #minorKey: #windowSpecForCommitWithoutChannels |
579 ) |
388 ) |
580 ) |
389 ) |
581 ) |
390 ) |
582 ) |
391 ) |
|
392 ! |
|
393 |
|
394 windowSpec |
|
395 "This resource specification was automatically generated |
|
396 by the UIPainter of ST/X." |
|
397 |
|
398 "Do not manually edit this!! If it is corrupted, |
|
399 the UIPainter may not be able to read the specification." |
|
400 |
|
401 " |
|
402 UIPainter new openOnClass:ImageEditor andSelector:#windowSpec |
|
403 ImageEditor new openInterface:#windowSpec |
|
404 ImageEditor open |
|
405 " |
|
406 |
|
407 <resource: #canvas> |
|
408 |
|
409 ^ |
|
410 |
|
411 #(#FullSpec |
|
412 #window: |
|
413 #(#WindowSpec |
|
414 #name: 'Image Editor' |
|
415 #layout: #(#LayoutFrame 167 0 330 0 666 0 675 0) |
|
416 #label: 'Image Editor' |
|
417 #min: #(#Point 400 320) |
|
418 #max: #(#Point 1152 900) |
|
419 #bounds: #(#Rectangle 167 330 667 676) |
|
420 #menu: #menu |
|
421 #usePreferredExtent: false |
|
422 ) |
|
423 #component: |
|
424 #(#SpecCollection |
|
425 #collection: |
|
426 #( |
|
427 #(#MenuPanelSpec |
|
428 #name: 'menuToolbarView' |
|
429 #layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 32 0) |
|
430 #menu: #menuToolbar |
|
431 #style: #(#FontDescription #helvetica #medium #roman 10) |
|
432 #showSeparatingLines: true |
|
433 ) |
|
434 #(#VariableHorizontalPanelSpec |
|
435 #name: 'variableHorizontalPanel1' |
|
436 #layout: #(#LayoutFrame 0 0.0 34 0.0 0 1.0 -26 1.0) |
|
437 #component: |
|
438 #(#SpecCollection |
|
439 #collection: |
|
440 #( |
|
441 #(#ViewSpec |
|
442 #name: 'view1' |
|
443 #component: |
|
444 #(#SpecCollection |
|
445 #collection: |
|
446 #( |
|
447 #(#VariableVerticalPanelSpec |
|
448 #name: 'VariableVerticalPanel1' |
|
449 #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
450 #component: |
|
451 #(#SpecCollection |
|
452 #collection: |
|
453 #( |
|
454 #(#ViewSpec |
|
455 #name: 'View1' |
|
456 #component: |
|
457 #(#SpecCollection |
|
458 #collection: |
|
459 #( |
|
460 #(#MenuPanelSpec |
|
461 #name: 'MouseButtonColorToolBar' |
|
462 #layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 24 0) |
|
463 #menu: #menuMouseButtonColors |
|
464 ) |
|
465 #(#DataSetSpec |
|
466 #name: 'colorDataSetView' |
|
467 #layout: #(#LayoutFrame 0 0.0 26 0.0 0 1.0 0 1.0) |
|
468 #activeHelpKey: #colorMapTable |
|
469 #model: #selectionOfColor |
|
470 #style: #(#FontDescription #helvetica #medium #roman 10) |
|
471 #hasHorizontalScrollBar: true |
|
472 #hasVerticalScrollBar: true |
|
473 #miniScrollerHorizontal: true |
|
474 #miniScrollerVertical: true |
|
475 #level: -1 |
|
476 #dataList: #listOfColors |
|
477 #has3Dsepartors: true |
|
478 #verticalSpacing: 1 |
|
479 #columns: |
|
480 #( |
|
481 #(#DataSetColumnSpec |
|
482 #rendererType: #rowSelector |
|
483 #backgroundSelector: #yourself |
|
484 ) |
|
485 #(#DataSetColumnSpec |
|
486 #label: 'R' |
|
487 #labelAlignment: #left |
|
488 #model: #rowRedByte |
|
489 #canSelect: false |
|
490 ) |
|
491 #(#DataSetColumnSpec |
|
492 #label: 'G' |
|
493 #labelAlignment: #left |
|
494 #model: #rowGreenByte |
|
495 #canSelect: false |
|
496 ) |
|
497 #(#DataSetColumnSpec |
|
498 #label: 'B' |
|
499 #labelAlignment: #left |
|
500 #model: #rowBlueByte |
|
501 #canSelect: false |
|
502 ) |
|
503 ) |
|
504 ) |
|
505 ) |
|
506 ) |
|
507 ) |
|
508 #(#ArbitraryComponentSpec |
|
509 #name: 'imagePreView' |
|
510 #activeHelpKey: #previewView |
|
511 #hasHorizontalScrollBar: true |
|
512 #hasVerticalScrollBar: true |
|
513 #miniScrollerHorizontal: true |
|
514 #miniScrollerVertical: true |
|
515 #component: #ImageView |
|
516 #hasBorder: false |
|
517 ) |
|
518 ) |
|
519 ) |
|
520 #handles: #(#Any 0.723776 1.0) |
|
521 ) |
|
522 ) |
|
523 ) |
|
524 ) |
|
525 #(#ViewSpec |
|
526 #name: 'view2' |
|
527 #component: |
|
528 #(#SpecCollection |
|
529 #collection: |
|
530 #( |
|
531 #(#ArbitraryComponentSpec |
|
532 #name: 'imageEditView' |
|
533 #layout: #(#LayoutFrame 2 0.0 2 0.0 -2 1.0 -24 1.0) |
|
534 #hasHorizontalScrollBar: true |
|
535 #hasVerticalScrollBar: true |
|
536 #component: #ImageEditView |
|
537 #hasBorder: false |
|
538 ) |
|
539 #(#LabelSpec |
|
540 #name: 'coordLabel' |
|
541 #layout: #(#LayoutFrame 2 0.0 -22 1 -83 1.0 0 1.0) |
|
542 #level: -1 |
|
543 #adjust: #left |
|
544 #resizeForLabel: false |
|
545 ) |
|
546 #(#ArrowButtonSpec |
|
547 #name: 'magnifyDownButton' |
|
548 #layout: #(#LayoutFrame -80 1 -22 1 -58 1 0 1) |
|
549 #activeHelpKey: #magnifyImageDown |
|
550 #model: #doMagnifyDown |
|
551 #enableChannel: #imageIsLoaded |
|
552 #isTriggerOnDown: true |
|
553 #direction: #left |
|
554 ) |
|
555 #(#ArrowButtonSpec |
|
556 #name: 'magnifyUpButton' |
|
557 #layout: #(#LayoutFrame -24 1 -22 1 -2 1 0 1) |
|
558 #activeHelpKey: #magnifyImageUp |
|
559 #model: #doMagnifyUp |
|
560 #enableChannel: #imageIsLoaded |
|
561 #isTriggerOnDown: true |
|
562 #direction: #right |
|
563 ) |
|
564 #(#InputFieldSpec |
|
565 #name: 'magnificationInputField' |
|
566 #layout: #(#LayoutFrame -57 1 -22 1 -26 1 0 1) |
|
567 #activeHelpKey: #magnificationNumber |
|
568 #enableChannel: #imageIsLoaded |
|
569 #model: #valueOfMagnification |
|
570 #type: #number |
|
571 #acceptOnReturn: false |
|
572 #acceptOnTab: false |
|
573 #numChars: 2 |
|
574 ) |
|
575 ) |
|
576 ) |
|
577 #level: -1 |
|
578 ) |
|
579 ) |
|
580 ) |
|
581 #handles: #(#Any 0.276 1.0) |
|
582 ) |
|
583 #(#UISubSpecification |
|
584 #name: 'infoBarSubSpec' |
|
585 #layout: #(#LayoutFrame 0 0.0 -24 1 0 1.0 0 1.0) |
|
586 #majorKey: #ToolApplicationModel |
|
587 #minorKey: #windowSpecForInfoBar |
|
588 ) |
|
589 ) |
|
590 ) |
|
591 ) |
583 ! ! |
592 ! ! |
584 |
593 |
585 !ImageEditor class methodsFor:'menu specs'! |
594 !ImageEditor class methodsFor:'menu specs'! |
586 |
595 |
587 menu |
596 menu |
987 ! ! |
996 ! ! |
988 |
997 |
989 !ImageEditor methodsFor:'accessing'! |
998 !ImageEditor methodsFor:'accessing'! |
990 |
999 |
991 image |
1000 image |
|
1001 "returns the current editing image" |
992 |
1002 |
993 ^self imageEditView image |
1003 ^self imageEditView image |
994 ! |
1004 ! |
995 |
1005 |
996 postOpenAction: anAction |
1006 postOpenAction: anAction |
|
1007 "sets an action which is evaluated after opening" |
997 |
1008 |
998 postOpenAction := anAction |
1009 postOpenAction := anAction |
999 ! ! |
1010 ! ! |
1000 |
1011 |
1001 !ImageEditor methodsFor:'accessing - views'! |
1012 !ImageEditor methodsFor:'accessing - views'! |
1002 |
1013 |
1003 coordLabel |
1014 coordLabel |
|
1015 "returns the view the coord label" |
1004 |
1016 |
1005 ^builder componentAt: #coordLabel |
1017 ^builder componentAt: #coordLabel |
1006 ! |
1018 ! |
1007 |
1019 |
1008 imageEditView |
1020 imageEditView |
|
1021 "returns the image editing view" |
1009 |
1022 |
1010 ^(builder componentAt: #imageEditView) subViews first |
1023 ^(builder componentAt: #imageEditView) subViews first |
1011 ! |
1024 ! |
1012 |
1025 |
1013 imagePreView |
1026 imagePreView |
|
1027 "returns the preview of the image" |
1014 |
1028 |
1015 ^(builder componentAt: #imagePreView) subViews first |
1029 ^(builder componentAt: #imagePreView) subViews first |
1016 ! ! |
1030 ! ! |
1017 |
1031 |
1018 !ImageEditor methodsFor:'aspects'! |
1032 !ImageEditor methodsFor:'aspects'! |
1019 |
1033 |
1020 imageIsLoaded |
1034 imageIsLoaded |
|
1035 "returns whether an image is loaded as value holder" |
1021 |
1036 |
1022 |holder| |
1037 |holder| |
1023 (holder := builder bindingAt:#imageIsLoaded) isNil ifTrue:[ |
1038 (holder := builder bindingAt:#imageIsLoaded) isNil ifTrue:[ |
1024 builder aspectAt:#imageIsLoaded put:(holder := false asValue). |
1039 builder aspectAt:#imageIsLoaded put:(holder := false asValue). |
1025 ]. |
1040 ]. |
1026 ^ holder |
1041 ^ holder |
1027 ! |
1042 ! |
1028 |
1043 |
1029 listOfColors |
1044 listOfColors |
|
1045 "returns the list of colors in a List" |
1030 |
1046 |
1031 |holder| |
1047 |holder| |
1032 (holder := builder bindingAt:#listOfColors) isNil ifTrue:[ |
1048 (holder := builder bindingAt:#listOfColors) isNil ifTrue:[ |
1033 builder aspectAt:#listOfColors put:(holder := List new). |
1049 builder aspectAt:#listOfColors put:(holder := List new). |
1034 ]. |
1050 ]. |
1035 ^ holder |
1051 ^ holder |
1036 ! |
1052 ! |
1037 |
1053 |
1038 selectionOfColor |
1054 selectionOfColor |
|
1055 "returns current selection of the edit color as an AspectAdaptor" |
1039 |
1056 |
1040 |holder| |
1057 |holder| |
1041 (holder := builder bindingAt:#selectionOfColor) isNil ifTrue:[ |
1058 (holder := builder bindingAt:#selectionOfColor) isNil ifTrue:[ |
1042 builder aspectAt:#selectionOfColor put:( |
1059 builder aspectAt:#selectionOfColor put:( |
1043 holder := AspectAdaptor new subject:self; forAspect:#selectedColorIndex). |
1060 holder := AspectAdaptor new subject:self; forAspect:#selectedColorIndex). |
1044 ]. |
1061 ]. |
1045 ^ holder |
1062 ^ holder |
1046 ! |
1063 ! |
1047 |
1064 |
1048 valueOfMagnification |
1065 valueOfMagnification |
|
1066 "returns current magnification of the image as an AspectAdaptor" |
1049 |
1067 |
1050 |holder| |
1068 |holder| |
1051 (holder := builder bindingAt:#valueOfMagnification) isNil ifTrue:[ |
1069 (holder := builder bindingAt:#valueOfMagnification) isNil ifTrue:[ |
1052 builder aspectAt:#valueOfMagnification put:( |
1070 builder aspectAt:#valueOfMagnification put:( |
1053 holder := AspectAdaptor new subject:self; forAspect:#magnification) |
1071 holder := AspectAdaptor new subject:self; forAspect:#magnification) |
1054 ]. |
1072 ]. |
1055 ^ holder |
1073 ^ holder |
1056 ! ! |
1074 ! ! |
1057 |
1075 |
|
1076 !ImageEditor methodsFor:'change & update'! |
|
1077 |
|
1078 findColorMapMode |
|
1079 "finds the colorMapMode for an new image" |
|
1080 |
|
1081 self image depth > 8 ifTrue: [colorMapMode := ''. self listOfColors removeAll. ^nil]. |
|
1082 colorMapMode := self image depth printString, '-plane'. |
|
1083 self listOfColors isEmpty |
|
1084 ifTrue: |
|
1085 [ |
|
1086 self colorMapMode: colorMapMode value: nil |
|
1087 ]. |
|
1088 self imageEditView selectColors: (Array with: (self listOfColors at: 1) with: (self listOfColors at: 2 ifAbsent: [self listOfColors at: 1])). |
|
1089 (self image mask notNil and: [(self listOfColors includes: (Color basicNew setColorId:0)) not]) |
|
1090 ifTrue: |
|
1091 [ |
|
1092 colorMapMode := colorMapMode, ' + mask'. |
|
1093 self listOfColors addFirst: (Color basicNew setColorId:0). |
|
1094 self imageEditView selectColors: (Array with: (self listOfColors at: 2 ifAbsent: [self listOfColors at: 1]) with: (self listOfColors at: 1)). |
|
1095 ]. |
|
1096 self selectionOfColor value: 0. |
|
1097 self selectionOfColor value: (self listOfColors indexOf: self imageEditView selectedColor). |
|
1098 ! |
|
1099 |
|
1100 updateForNoneImage |
|
1101 "updates channels and view, if image is loaded" |
|
1102 |
|
1103 self imageIsLoaded value: false. |
|
1104 self listOfColors removeAll. |
|
1105 self imagePreView image: nil |
|
1106 |
|
1107 |
|
1108 |
|
1109 |
|
1110 ! |
|
1111 |
|
1112 updateLabelsAndHistory |
|
1113 "updates labels and history, if something has changed" |
|
1114 |
|
1115 self imageIsLoaded value: self image notNil. |
|
1116 |
|
1117 self image isNil ifTrue: [^nil]. |
|
1118 |
|
1119 self updateInfoLabel. |
|
1120 |
|
1121 self imageEditView resourceMessage asCollectionOfWords size = 2 |
|
1122 ifTrue: [self addToHistory: self imageEditView resourceMessage -> #loadFromMessage:]. |
|
1123 |
|
1124 self image fileName notNil |
|
1125 ifTrue: [self addToHistory: self image fileName -> #loadFromFile:]. |
|
1126 |
|
1127 |
|
1128 |
|
1129 ! ! |
|
1130 |
1058 !ImageEditor methodsFor:'help'! |
1131 !ImageEditor methodsFor:'help'! |
1059 |
1132 |
1060 defaultInfoLabel |
1133 defaultInfoLabel |
|
1134 "returns the default info label" |
1061 |
1135 |
1062 (self imageEditView resourceClass isSymbol and: [(Smalltalk at: self imageEditView resourceClass) isClass]) |
1136 (self imageEditView resourceClass isSymbol and: [(Smalltalk at: self imageEditView resourceClass) isClass]) |
1063 ifTrue: |
1137 ifTrue: |
1064 [ |
1138 [ |
1065 ^self imageEditView resourceClass, ' >> ', self imageEditView resourceSelector |
1139 ^self imageEditView resourceClass, ' >> ', self imageEditView resourceSelector |
1066 ]. |
1140 ]. |
1067 ^'No class defined' |
1141 ^'No class and selector defined.' |
1068 ! |
1142 ! |
1069 |
1143 |
1070 openDocumentation |
1144 openDocumentation |
|
1145 "opens the documentation file of the Image Editor" |
1071 |
1146 |
1072 self openHTMLDocument: 'tools/uipainter/ImageEditor.html' |
1147 self openHTMLDocument: 'tools/uipainter/ImageEditor.html' |
1073 |
1148 |
1074 ! ! |
1149 ! ! |
1075 |
1150 |
|
1151 !ImageEditor methodsFor:'loading'! |
|
1152 |
|
1153 loadFromFile: aFileName |
|
1154 "loads an image from aFileName and sets up color map list and other info labels" |
|
1155 |
|
1156 (self imageEditView loadFromFile: aFileName) notNil |
|
1157 ifTrue: |
|
1158 [ |
|
1159 self image notNil |
|
1160 ifTrue: |
|
1161 [ |
|
1162 self image colorMap notNil |
|
1163 ifTrue: |
|
1164 [ |
|
1165 self listOfColors contents: self image usedColors asSet. |
|
1166 ] |
|
1167 ifFalse: |
|
1168 [ |
|
1169 self listOfColors removeAll. |
|
1170 ]. |
|
1171 self findColorMapMode. |
|
1172 self updateLabelsAndHistory. |
|
1173 ] |
|
1174 ifFalse: |
|
1175 [ |
|
1176 self updateForNoneImage |
|
1177 ] |
|
1178 ] |
|
1179 ! |
|
1180 |
|
1181 loadFromImage: anImage |
|
1182 "loads an image from anImage and sets up color map list and other info labels" |
|
1183 |
|
1184 self imageEditView image: anImage. |
|
1185 self image notNil |
|
1186 ifTrue: |
|
1187 [ |
|
1188 self image colorMap notNil |
|
1189 ifTrue: |
|
1190 [ |
|
1191 self listOfColors contents: self image usedColors asSet asOrderedCollection. |
|
1192 ] |
|
1193 ifFalse: |
|
1194 [ |
|
1195 self listOfColors removeAll. |
|
1196 ]. |
|
1197 self findColorMapMode. |
|
1198 self updateLabelsAndHistory. |
|
1199 ] |
|
1200 ifFalse: |
|
1201 [ |
|
1202 self updateForNoneImage |
|
1203 ] |
|
1204 ! |
|
1205 |
|
1206 loadFromMessage: aMessage |
|
1207 "loads an image by evaluating aMessage and sets up color map list and other info labels" |
|
1208 |
|
1209 (self imageEditView loadFromMessage: aMessage) notNil |
|
1210 ifTrue: |
|
1211 [ |
|
1212 self image notNil |
|
1213 ifTrue: |
|
1214 [ |
|
1215 self listOfColors contents: self image usedColors asSet asOrderedCollection. |
|
1216 self findColorMapMode. |
|
1217 self updateLabelsAndHistory. |
|
1218 ] |
|
1219 ifFalse: |
|
1220 [ |
|
1221 self updateForNoneImage |
|
1222 ] |
|
1223 ] |
|
1224 ! |
|
1225 |
|
1226 loadFromOrPrepareForMessage: aMessage |
|
1227 "loads an image by evaluating aMessage; |
|
1228 if no image could extract from aMessage; do set the class and the selector from |
|
1229 the aMessage for a saving at the end of editing" |
|
1230 |
|
1231 (self imageEditView loadFromMessage: aMessage) notNil |
|
1232 ifTrue: |
|
1233 [ |
|
1234 self listOfColors contents: self image usedColors asSet asOrderedCollection. |
|
1235 self findColorMapMode. |
|
1236 ] |
|
1237 ifFalse: |
|
1238 [ |
|
1239 self imageEditView resourceMessage: aMessage. |
|
1240 ]. |
|
1241 self updateLabelsAndHistory. |
|
1242 ! ! |
|
1243 |
1076 !ImageEditor methodsFor:'menu modes'! |
1244 !ImageEditor methodsFor:'menu modes'! |
1077 |
1245 |
1078 colorMapMode: aMode |
1246 colorMapMode: aMode |
|
1247 "returns whether colorMapMode is equal to aMode" |
1079 |
1248 |
1080 ^colorMapMode = aMode |
1249 ^colorMapMode = aMode |
1081 ! |
1250 ! |
1082 |
1251 |
1083 colorMapMode: aMode value: aValue |
1252 colorMapMode: aMode value: aValue |
|
1253 "calculates a new color map for the image from aMode" |
1084 |
1254 |
1085 |depth newColorMap newImage image newColors realColorMap oldFileName| |
1255 |depth newColorMap newImage image newColors realColorMap oldFileName| |
1086 |
1256 |
1087 newColorMap := self class listOfColorMaps at: aMode. |
1257 newColorMap := self class listOfColorMaps at: aMode. |
1088 depth := (newColorMap size log: 2) asInteger. |
1258 depth := (newColorMap size log: 2) asInteger. |
1147 self updateLabelsAndHistory. |
1317 self updateLabelsAndHistory. |
1148 ] |
1318 ] |
1149 ! |
1319 ! |
1150 |
1320 |
1151 editMode: aMode |
1321 editMode: aMode |
|
1322 "returns whether editMode is equal to aMode" |
1152 |
1323 |
1153 ^self imageEditView editMode = aMode |
1324 ^self imageEditView editMode = aMode |
1154 ! |
1325 ! |
1155 |
1326 |
1156 editMode: aMode value: aValue |
1327 editMode: aMode value: aValue |
|
1328 "sets the editMode to aMode" |
1157 |
1329 |
1158 self imageEditView editMode: aMode |
1330 self imageEditView editMode: aMode |
1159 ! |
1331 ! |
1160 |
1332 |
1161 mouseKeyColorMode: aMode |
1333 mouseKeyColorMode: aMode |
|
1334 "sets the mouseKeyColorMode to aMode" |
1162 |
1335 |
1163 ^self imageEditView mouseKeyColorMode = aMode |
1336 ^self imageEditView mouseKeyColorMode = aMode |
1164 ! |
1337 ! |
1165 |
1338 |
1166 mouseKeyColorMode: aMode value: aValue |
1339 mouseKeyColorMode: aMode value: aValue |
|
1340 "sets the mouseKeyColorMode to aMode" |
1167 |
1341 |
1168 self imageEditView mouseKeyColorMode: aMode. |
1342 self imageEditView mouseKeyColorMode: aMode. |
1169 |
1343 |
1170 self selectionOfColor value: (self listOfColors indexOf: self imageEditView selectedColor). |
1344 self selectionOfColor value: (self listOfColors indexOf: self imageEditView selectedColor). |
1171 ! ! |
1345 ! ! |
1172 |
1346 |
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 ]. |
|
1184 self imageEditView selectColor: (Array with: (self listOfColors at: 1) with: (self listOfColors at: 2 ifAbsent: [self listOfColors at: 1])). |
|
1185 self image mask notNil |
|
1186 ifTrue: |
|
1187 [ |
|
1188 colorMapMode := colorMapMode, ' + mask'. |
|
1189 self listOfColors addFirst: (Color basicNew setColorId:0). |
|
1190 self imageEditView selectColor: (Array with: (self listOfColors at: 1 ifAbsent: [self listOfColors at: 2]) with: (self listOfColors at: 1)). |
|
1191 ]. |
|
1192 self selectionOfColor value: 0. |
|
1193 self selectionOfColor value: (self listOfColors indexOf: self imageEditView selectedColor). |
|
1194 ! |
|
1195 |
|
1196 updateForNoneImage |
|
1197 |
|
1198 self imageIsLoaded value: false. |
|
1199 self listOfColors removeAll. |
|
1200 self imagePreView image: nil |
|
1201 |
|
1202 |
|
1203 |
|
1204 |
|
1205 ! |
|
1206 |
|
1207 updateLabelsAndHistory |
|
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 |
|
1225 !ImageEditor methodsFor:'queries'! |
1347 !ImageEditor methodsFor:'queries'! |
1226 |
1348 |
1227 preferredExtent |
1349 preferredExtent |
|
1350 "returns the preferred extent" |
1228 |
1351 |
1229 ^super preferredExtent max: (Screen current width//3)@(Screen current height//3.5) |
1352 ^super preferredExtent max: (Screen current width//3)@(Screen current height//3.5) |
1230 |
1353 |
1231 |
1354 |
1232 ! ! |
1355 ! ! |
1233 |
1356 |
1234 !ImageEditor methodsFor:'selection'! |
1357 !ImageEditor methodsFor:'selection'! |
1235 |
1358 |
1236 magnification |
1359 magnification |
|
1360 "returns the magnification of the image" |
1237 |
1361 |
1238 (builder componentAt: #imageEditView) isNil ifTrue: [^1]. |
1362 (builder componentAt: #imageEditView) isNil ifTrue: [^1]. |
1239 ^self imageEditView magnification x |
1363 ^self imageEditView magnification x |
1240 ! |
1364 ! |
1241 |
1365 |
1242 magnification: aValue |
1366 magnification: aValue |
|
1367 "sets the magnification of the image" |
1243 |
1368 |
1244 |magnification| |
1369 |magnification| |
1245 magnification := aValue asInteger asPoint. |
1370 magnification := aValue asInteger asPoint. |
1246 (magnification = self imageEditView magnification) | (magnification = (0@0)) ifTrue: [^nil]. |
1371 (magnification = self imageEditView magnification or: [magnification = (0@0)]) ifTrue: [^nil]. |
1247 self imageEditView magnification: magnification |
1372 self imageEditView magnification: magnification |
1248 ! |
1373 ! |
1249 |
1374 |
1250 selectedColorIndex |
1375 selectedColorIndex |
|
1376 "returns the index of the selected color" |
1251 |
1377 |
1252 ^selectedColorIndex |
1378 ^selectedColorIndex |
1253 ! |
1379 ! |
1254 |
1380 |
1255 selectedColorIndex: anIndex |
1381 selectedColorIndex: anIndex |
|
1382 "sets the index of the selected color" |
1256 |
1383 |
1257 selectedColorIndex := anIndex. |
1384 selectedColorIndex := anIndex. |
1258 self imageEditView selectedColor: (self listOfColors at: anIndex ifAbsent: [^nil]) |
1385 self imageEditView selectedColor: (self listOfColors at: anIndex ifAbsent: [^nil]) |
1259 |
1386 |
1260 ! ! |
1387 ! ! |
1261 |
1388 |
1262 !ImageEditor methodsFor:'startup / release'! |
1389 !ImageEditor methodsFor:'startup / release'! |
1263 |
1390 |
1264 closeRequest |
1391 closeRequest |
|
1392 "close request" |
1265 |
1393 |
1266 self imageEditView checkModified ifTrue:[super closeRequest] |
1394 self imageEditView checkModified ifTrue:[super closeRequest] |
1267 |
1395 |
1268 ! |
1396 ! |
1269 |
1397 |
1270 open |
1398 open |
|
1399 "after opening, sets the masterApplication of the imageEditView to self" |
1271 |
1400 |
1272 super open. |
1401 super open. |
1273 |
1402 |
1274 self imageEditView masterApplication: self |
1403 self imageEditView masterApplication: self |
1275 ! |
1404 ! |
1276 |
1405 |
1277 postOpenWith:aBuilder |
1406 postOpenWith:aBuilder |
|
1407 "after opening, sets the masterApplication of the imageEditView to self; |
|
1408 evaluate the postOpenAction" |
1278 |
1409 |
1279 self imageEditView masterApplication: self. |
1410 self imageEditView masterApplication: self. |
1280 postOpenAction notNil ifTrue: [postOpenAction value]. |
1411 postOpenAction notNil ifTrue: [postOpenAction value]. |
1281 super postOpenWith:aBuilder. |
1412 |
1282 ! |
1413 super postOpenWith:aBuilder |
1283 |
|
1284 reOpen |
|
1285 |
|
1286 self imageEditView checkModified ifTrue:[super reOpen] |
|
1287 |
|
1288 ! ! |
1414 ! ! |
1289 |
1415 |
1290 !ImageEditor methodsFor:'user actions - editing'! |
1416 !ImageEditor methodsFor:'user actions - editing'! |
1291 |
1417 |
1292 browseClass |
1418 doBrowseClass |
|
1419 "opens a System Browser on the resourceClass and the resourceSelector" |
1293 |
1420 |
1294 SystemBrowser openInClass: (Smalltalk at: self imageEditView resourceClass ifAbsent: [^nil]) class selector: self imageEditView resourceSelector |
1421 SystemBrowser openInClass: (Smalltalk at: self imageEditView resourceClass ifAbsent: [^nil]) class selector: self imageEditView resourceSelector |
1295 ! |
1422 ! |
1296 |
1423 |
1297 flipHorizontal |
1424 doFlipHorizontal |
|
1425 "flips horizontally current image" |
1298 |
1426 |
1299 self imageEditView flipHorizontal |
1427 self imageEditView flipHorizontal |
1300 ! |
1428 ! |
1301 |
1429 |
1302 flipVertical |
1430 doFlipVertical |
|
1431 "flips vertically current image" |
1303 |
1432 |
1304 self imageEditView flipVertical |
1433 self imageEditView flipVertical |
1305 ! |
1434 ! |
1306 |
1435 |
1307 magnifyDown |
1436 doMagnifyDown |
|
1437 "magnifies current image one step down" |
1308 |
1438 |
1309 self valueOfMagnification value > 1 |
1439 self valueOfMagnification value > 1 |
1310 ifTrue: |
1440 ifTrue: |
1311 [ |
1441 [ |
1312 self valueOfMagnification value: self valueOfMagnification value - 1 |
1442 self valueOfMagnification value: self valueOfMagnification value - 1 |
1313 ] |
1443 ] |
1314 ! |
1444 ! |
1315 |
1445 |
1316 magnifyImage |
1446 doMagnifyImage |
|
1447 "magnifies current image" |
1317 |
1448 |
1318 self imageEditView magnifyImage. |
1449 self imageEditView magnifyImage. |
1319 self updateInfoLabel |
1450 self updateInfoLabel |
1320 ! |
1451 ! |
1321 |
1452 |
1322 magnifyUp |
1453 doMagnifyUp |
|
1454 "magnifies current image one step up" |
1323 |
1455 |
1324 self valueOfMagnification value < 99 |
1456 self valueOfMagnification value < 99 |
1325 ifTrue: |
1457 ifTrue: |
1326 [ |
1458 [ |
1327 self valueOfMagnification value: self valueOfMagnification value + 1 |
1459 self valueOfMagnification value: self valueOfMagnification value + 1 |
1328 ] |
1460 ] |
1329 ! |
1461 ! |
1330 |
1462 |
1331 negativeImage |
1463 doNegativeImage |
|
1464 "negates current image by negating the color map" |
1332 |
1465 |
1333 self imageEditView negativeImage. |
1466 self imageEditView negativeImage. |
1334 self listOfColors removeAll. |
1467 self listOfColors removeAll. |
1335 self findColorMapMode. |
1468 self findColorMapMode |
1336 ! |
1469 ! |
1337 |
1470 |
1338 resizeImage |
1471 doResizeImage |
|
1472 "resizes current image" |
1339 |
1473 |
1340 self imageEditView resizeImage. |
1474 self imageEditView resizeImage. |
1341 self updateInfoLabel |
1475 self updateInfoLabel |
1342 ! |
1476 ! |
1343 |
1477 |
1344 rotateImage |
1478 doRotateImage |
|
1479 "rotates current image" |
1345 |
1480 |
1346 self imageEditView rotateImage. |
1481 self imageEditView rotateImage. |
1347 self updateInfoLabel |
1482 self updateInfoLabel |
1348 ! |
1483 ! |
1349 |
1484 |
1350 undo |
1485 doUndo |
|
1486 "reverses last edit action" |
1351 |
1487 |
1352 self imageEditView undo |
1488 self imageEditView undo |
1353 ! ! |
1489 ! ! |
1354 |
1490 |
1355 !ImageEditor methodsFor:'user actions - loading'! |
1491 !ImageEditor methodsFor:'user actions - loading'! |
1356 |
1492 |
1357 loadFromClass |
1493 doLoadFromClass |
|
1494 "opens a dialog for loading an image from class and a (resource-) selector" |
1358 |
1495 |
1359 (self imageEditView loadFromClass) notNil |
1496 (self imageEditView loadFromClass) notNil |
1360 ifTrue: |
1497 ifTrue: |
1361 [ |
1498 [ |
1362 self image notNil |
1499 self image notNil |
1363 ifTrue: |
1500 ifTrue: |
1364 [ |
1501 [ |
1365 self listOfColors contents: self image usedColors asSet asOrderedCollection. |
1502 self listOfColors contents: self image usedColors asSet asOrderedCollection. |
1366 self findColorMapMode. |
1503 self findColorMapMode. |
1367 self updateLabelsAndHistory. |
1504 self updateLabelsAndHistory |
1368 ] |
1505 ] |
1369 ifFalse: |
1506 ifFalse: |
1370 [ |
1507 [ |
1371 self updateForNoneImage |
1508 self updateForNoneImage |
1372 ] |
1509 ] |
1373 ] |
1510 ] |
1374 ! |
1511 ! |
1375 |
1512 |
1376 loadFromFile |
1513 doLoadFromFile |
|
1514 "opens a dialog for loading an image from a file" |
1377 |
1515 |
1378 self loadFromFile: |
1516 self loadFromFile: |
1379 (FileSelectionBrowser |
1517 (FileSelectionBrowser |
1380 request: 'Load Image From' |
1518 request: 'Load Image From' |
1381 fileName: (self image notNil ifTrue: [self image fileName] ifFalse: [nil]) |
1519 fileName: (self image notNil ifTrue: [self image fileName] ifFalse: [nil]) |
1382 withFileFilters: FileSelectionBrowser loadImageFileNameFilters) |
1520 withFileFilters: FileSelectionBrowser loadImageFileNameFilters) |
1383 ! |
1521 ! |
1384 |
1522 |
1385 loadFromFile: aFileName |
1523 doNewImage |
1386 |
1524 "opens a dialog with choices of size and color map for creating a new image" |
1387 (self imageEditView loadFromFile: aFileName) notNil |
|
1388 ifTrue: |
|
1389 [ |
|
1390 self image notNil |
|
1391 ifTrue: |
|
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. |
|
1403 self updateLabelsAndHistory. |
|
1404 ] |
|
1405 ifFalse: |
|
1406 [ |
|
1407 self updateForNoneImage |
|
1408 ] |
|
1409 ] |
|
1410 ! |
|
1411 |
|
1412 loadFromImage: image |
|
1413 |
|
1414 self imageEditView image: image. |
|
1415 self image notNil |
|
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. |
|
1428 self updateLabelsAndHistory. |
|
1429 ] |
|
1430 ifFalse: |
|
1431 [ |
|
1432 self updateForNoneImage |
|
1433 ] |
|
1434 ! |
|
1435 |
|
1436 loadFromMessage: aMessage |
|
1437 |
|
1438 (self imageEditView loadFromMessage: aMessage) notNil |
|
1439 ifTrue: |
|
1440 [ |
|
1441 self image notNil |
|
1442 ifTrue: |
|
1443 [ |
|
1444 self listOfColors contents: self image usedColors asSet asOrderedCollection. |
|
1445 self findColorMapMode. |
|
1446 self updateLabelsAndHistory. |
|
1447 ] |
|
1448 ifFalse: |
|
1449 [ |
|
1450 self updateForNoneImage |
|
1451 ] |
|
1452 ] |
|
1453 ! |
|
1454 |
|
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. |
|
1466 ]. |
|
1467 self updateLabelsAndHistory. |
|
1468 ! |
|
1469 |
|
1470 newImage |
|
1471 |
1525 |
1472 |aspects| |
1526 |aspects| |
|
1527 |
1473 aspects := IdentityDictionary new |
1528 aspects := IdentityDictionary new |
1474 at:#listOfSizes put: self class listOfDefaultSizes asValue; |
1529 at:#listOfSizes put: self class listOfDefaultSizes asValue; |
1475 at:#listOfColorMaps put: self class listOfColorMaps keys asSortedCollection asValue; |
1530 at:#listOfColorMaps put: self class listOfColorMaps keys asSortedCollection asValue; |
1476 at:#selectionOfSize put: self class listOfDefaultSizes first copy asValue; |
1531 at:#selectionOfSize put: self class listOfDefaultSizes first copy asValue; |
1477 at:#selectionOfColorMap put: self class listOfColorMaps keys asSortedCollection first asValue; |
1532 at:#selectionOfColorMap put: self class listOfColorMaps keys asSortedCollection first asValue; |
1478 yourself. |
1533 yourself. |
1479 |
1534 |
1480 (self openDialogInterface:#windowSpecForNewImage withBindings:aspects) |
1535 (self openDialogInterface:#dialogSpecForNewImage withBindings:aspects) |
1481 ifTrue: |
1536 ifTrue: |
1482 [ |
1537 [ |
1483 |width height cMap imageClass image| |
1538 |width height cMap imageClass image| |
1484 width := 128 min: (Integer readFromString: ((aspects at:#selectionOfSize) value upTo: $x) onError:[24]). |
1539 |
|
1540 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]). |
1541 height := 128 min: (Integer readFromString: ((aspects at:#selectionOfSize) value copy reverse upTo: $x) reverse onError:[24]). |
1486 |
1542 |
1487 cMap := (self class listOfColorMaps at: (colorMapMode := (aspects at:#selectionOfColorMap) value)). |
1543 cMap := (self class listOfColorMaps at: (colorMapMode := (aspects at:#selectionOfColorMap) value)). |
1488 imageClass := Image implementorForDepth: ((cMap size log: 2) asInteger). |
1544 imageClass := Image implementorForDepth: ((cMap size log: 2) asInteger). |
1489 image := imageClass width: width height: height fromArray: (ByteArray new: width*height). |
1545 image := imageClass width: width height: height fromArray: (ByteArray new: width*height). |
1490 |
1546 |
1491 (colorMapMode copy reverse readStream nextWord reverse = 'mask') |
1547 (colorMapMode copy reverse readStream nextWord reverse = 'mask') |
1492 ifTrue: |
1548 ifTrue: |
1493 [ |
1549 [ |
1494 image mask: (Depth1Image width: width height: height depth: 1 fromArray: (ByteArray new: width*height)) clearMaskedPixels. |
1550 image mask: (Depth1Image width: width height: height depth: 1 fromArray: (ByteArray new: width*height)) clearMaskedPixels |
1495 ]. |
1551 ]. |
1496 image colorMap: cMap. |
1552 image colorMap: cMap. |
1497 image fillRectangleX:0 y:0 width:width height:height with:Color white. |
1553 image fillRectangleX:0 y:0 width:width height:height with:Color white. |
1498 (self imageEditView image: image) notNil |
1554 (self imageEditView image: image) notNil |
1499 ifTrue: |
1555 ifTrue: |
1500 [ |
1556 [ |
1501 self listOfColors contents: cMap. |
1557 self listOfColors contents: cMap. |
1502 self findColorMapMode. |
1558 self findColorMapMode. |
1503 self updateLabelsAndHistory |
1559 self updateLabelsAndHistory |
1504 ] |
1560 ] |
1505 ]. |
1561 ] |
1506 ! ! |
1562 ! ! |
1507 |
1563 |
1508 !ImageEditor methodsFor:'user actions - saving'! |
1564 !ImageEditor methodsFor:'user actions - saving'! |
1509 |
1565 |
1510 print |
1566 doPrint |
|
1567 "prints current image on the current printer" |
1511 |
1568 |
1512 self imageEditView print |
1569 self imageEditView print |
1513 ! |
1570 ! |
1514 |
1571 |
1515 saveImageFile |
1572 doSaveImageFile |
|
1573 "saves current image to current file" |
1516 |
1574 |
1517 self imageEditView save |
1575 self imageEditView save |
1518 ! |
1576 ! |
1519 |
1577 |
1520 saveImageFileAs |
1578 doSaveImageFileAs |
|
1579 "opens a dialog for saving current image to a file" |
1521 |
1580 |
1522 self imageEditView saveImageFileAs. |
1581 self imageEditView saveImageFileAs. |
1523 self updateLabelsAndHistory |
1582 self updateLabelsAndHistory |
1524 ! |
1583 ! |
1525 |
1584 |
1526 saveImageMaskFileAs |
1585 doSaveImageMaskFileAs |
|
1586 "opens a dialog for saving mask of current image to a file" |
1527 |
1587 |
1528 self imageEditView saveImageMaskFileAs |
1588 self imageEditView saveImageMaskFileAs |
1529 ! |
1589 ! |
1530 |
1590 |
1531 saveMethod |
1591 doSaveMethod |
|
1592 "saves current image on current class and selector" |
1532 |
1593 |
1533 self imageEditView saveMethod notNil |
1594 self imageEditView saveMethod notNil |
1534 ifTrue: |
1595 ifTrue: |
1535 [ |
1596 [ |
1536 self updateLabelsAndHistory |
1597 self updateLabelsAndHistory |
1537 ] |
1598 ] |
1538 ! |
1599 ! |
1539 |
1600 |
1540 saveMethodAs |
1601 doSaveMethodAs |
|
1602 "opens a dialog for saving current image on a class and a selector" |
1541 |
1603 |
1542 self imageEditView saveMethodAs notNil |
1604 self imageEditView saveMethodAs notNil |
1543 ifTrue: |
1605 ifTrue: |
1544 [ |
1606 [ |
1545 self updateLabelsAndHistory |
1607 self updateLabelsAndHistory |