1561 #label: 'Add Color' |
1561 #label: 'Add Color' |
1562 #translateLabel: true |
1562 #translateLabel: true |
1563 #value: #addColorToColormap |
1563 #value: #addColorToColormap |
1564 ) |
1564 ) |
1565 #(#MenuItem |
1565 #(#MenuItem |
|
1566 #label: 'Pick and Add Color' |
|
1567 #translateLabel: true |
|
1568 #value: #pickAndAddColorToColormap |
|
1569 ) |
|
1570 #(#MenuItem |
|
1571 #label: '-' |
|
1572 ) |
|
1573 #(#MenuItem |
|
1574 #label: 'Darker' |
|
1575 #translateLabel: true |
|
1576 #value: #makeSelectedColorDarker |
|
1577 ) |
|
1578 #(#MenuItem |
|
1579 #label: 'Brighter' |
|
1580 #translateLabel: true |
|
1581 #value: #makeSelectedColorBrighter |
|
1582 ) |
|
1583 #(#MenuItem |
1566 #label: '-' |
1584 #label: '-' |
1567 ) |
1585 ) |
1568 #(#MenuItem |
1586 #(#MenuItem |
1569 #label: 'Inspect Color' |
1587 #label: 'Inspect Color' |
1570 #translateLabel: true |
1588 #translateLabel: true |
2594 ]. |
2618 ]. |
2595 ^ holder |
2619 ^ holder |
2596 ! |
2620 ! |
2597 |
2621 |
2598 selectionOfColor |
2622 selectionOfColor |
2599 "returns current selection of the edit color as an AspectAdaptor" |
2623 "returns a valueHolder for the current selection of the edit color. |
|
2624 Here, an AspectAdaptor which accesses selectedColorIndex is returned." |
2600 |
2625 |
2601 |holder| |
2626 |holder| |
|
2627 |
2602 (holder := builder bindingAt:#selectionOfColor) isNil ifTrue:[ |
2628 (holder := builder bindingAt:#selectionOfColor) isNil ifTrue:[ |
2603 builder aspectAt:#selectionOfColor put:( |
2629 builder aspectAt:#selectionOfColor put:( |
2604 holder := AspectAdaptor new subject:self; forAspect:#selectedColorIndex). |
2630 holder := AspectAdaptor new subject:self; forAspect:#selectedColorIndex ). |
2605 ]. |
2631 ]. |
2606 ^ holder |
2632 ^ holder |
2607 ! |
2633 ! |
2608 |
2634 |
2609 tileModeHolder |
2635 tileModeHolder |
3192 cMap isNil ifTrue:[ |
3222 cMap isNil ifTrue:[ |
3193 drawingColormap isNil ifTrue:[ |
3223 drawingColormap isNil ifTrue:[ |
3194 self information:'Image has no colormap.\The shown colorMap is for drawing only.' withCRs. |
3224 self information:'Image has no colormap.\The shown colorMap is for drawing only.' withCRs. |
3195 drawingColormap := OrderedCollection new. |
3225 drawingColormap := OrderedCollection new. |
3196 ]. |
3226 ]. |
3197 drawingColormap add:(Color black). |
3227 drawingColormap add:newColor. |
3198 self listOfColors contents:drawingColormap. |
3228 self listOfColors contents:drawingColormap. |
3199 self selectionOfColor value:(drawingColormap size). |
3229 self selectionOfColor value:(drawingColormap size). |
3200 |
3230 |
3201 "/ self warn:'Image has no colormap.\Change colorMap mode first.' withCRs. |
3231 "/ self warn:'Image has no colormap.\Change colorMap mode first.' withCRs. |
3202 ^ self |
3232 ^ self |
3768 ] |
3795 ] |
3769 ]. |
3796 ]. |
3770 ! |
3797 ! |
3771 |
3798 |
3772 makeSelectedColorBrighter |
3799 makeSelectedColorBrighter |
3773 |img cMap newImage clr| |
3800 self processSelectedColorWith:[:clr | clr lightened] |
3774 |
|
3775 img := self image. |
|
3776 cMap := img colorMap. |
|
3777 cMap isNil ifTrue:[ |
|
3778 self warn:'Image has no colormap\change colorMap mode first.' withCRs. |
|
3779 ^ self |
|
3780 ]. |
|
3781 |
|
3782 imageEditView makeUndo. |
|
3783 |
|
3784 cMap := cMap asArray. |
|
3785 clr := cMap at:imageEditView selectedColorIndex. |
|
3786 cMap at:imageEditView selectedColorIndex put:clr lightened. |
|
3787 |
|
3788 newImage := img species new |
|
3789 width:img width |
|
3790 height:img height |
|
3791 depth:nil |
|
3792 fromArray:img bits. |
|
3793 |
|
3794 newImage colorMap:cMap. |
|
3795 newImage fileName:img fileName. |
|
3796 newImage mask:(img mask copy). |
|
3797 |
|
3798 (imageEditView image:newImage) notNil ifTrue:[ |
|
3799 self fetchImageData. |
|
3800 "/ self listOfColors contents: newImage colorMap. |
|
3801 "/ self findColorMapMode. |
|
3802 "/ self updateLabelsAndHistory. |
|
3803 ] |
|
3804 |
|
3805 "Created: / 12.3.1999 / 00:20:28 / cg" |
|
3806 "Modified: / 16.3.1999 / 21:57:26 / cg" |
|
3807 ! |
3801 ! |
3808 |
3802 |
3809 makeSelectedColorDarker |
3803 makeSelectedColorDarker |
3810 |img cMap clr newImage| |
3804 self processSelectedColorWith:[:clr | clr darkened] |
3811 |
|
3812 img := self image. |
|
3813 cMap := img colorMap. |
|
3814 cMap isNil ifTrue:[ |
|
3815 self warn:'Image has no colormap\change colorMap mode first.' withCRs. |
|
3816 ^ self |
|
3817 ]. |
|
3818 imageEditView makeUndo. |
|
3819 |
|
3820 cMap := cMap asArray. |
|
3821 clr := cMap at:imageEditView selectedColorIndex. |
|
3822 cMap at:imageEditView selectedColorIndex put:clr darkened. |
|
3823 |
|
3824 newImage := img species new |
|
3825 width:img width |
|
3826 height:img height |
|
3827 depth:nil |
|
3828 fromArray:img bits. |
|
3829 |
|
3830 newImage colorMap:cMap. |
|
3831 newImage fileName:img fileName. |
|
3832 newImage mask:(img mask copy). |
|
3833 |
|
3834 (imageEditView image:newImage) notNil ifTrue:[ |
|
3835 self fetchImageData. |
|
3836 "/ self listOfColors contents: newImage colorMap. |
|
3837 "/ self findColorMapMode. |
|
3838 "/ self updateLabelsAndHistory. |
|
3839 ] |
|
3840 |
|
3841 "Created: / 12.3.1999 / 00:20:28 / cg" |
|
3842 "Modified: / 16.3.1999 / 21:57:26 / cg" |
|
3843 ! |
3805 ! |
3844 |
3806 |
3845 pasteMask |
3807 pasteMask |
3846 |img mask| |
3808 |img mask| |
3847 |
3809 |
3860 (imageEditView image:img copy) notNil ifTrue:[ |
3822 (imageEditView image:img copy) notNil ifTrue:[ |
3861 self fetchImageData. |
3823 self fetchImageData. |
3862 ] |
3824 ] |
3863 ! |
3825 ! |
3864 |
3826 |
|
3827 pickAndAddColorToColormap |
|
3828 self addColorToColormap:(Color fromUser) |
|
3829 ! |
|
3830 |
|
3831 processSelectedColorWith:aBlock |
|
3832 |img cMap clr newImage selectedColorIndex oldSelection| |
|
3833 |
|
3834 selectedColorIndex := self selectedColorIndexOrNil. |
|
3835 selectedColorIndex isNil ifTrue:[^ self]. |
|
3836 |
|
3837 img := self image. |
|
3838 cMap := img colorMap. |
|
3839 cMap isNil ifTrue:[ |
|
3840 self warn:'Image has no colormap\change colorMap mode first.' withCRs. |
|
3841 ^ self |
|
3842 ]. |
|
3843 imageEditView makeUndo. |
|
3844 |
|
3845 cMap := cMap asArray. |
|
3846 clr := cMap at:selectedColorIndex. |
|
3847 cMap at:selectedColorIndex put:(aBlock value:clr). |
|
3848 |
|
3849 newImage := img species new |
|
3850 width:img width |
|
3851 height:img height |
|
3852 depth:nil |
|
3853 fromArray:img bits. |
|
3854 |
|
3855 newImage colorMap:cMap. |
|
3856 newImage fileName:img fileName. |
|
3857 newImage mask:(img mask copy). |
|
3858 |
|
3859 oldSelection := self selectionOfColor value. |
|
3860 |
|
3861 (imageEditView image:newImage) notNil ifTrue:[ |
|
3862 self fetchImageData. |
|
3863 "/ self listOfColors contents: newImage colorMap. |
|
3864 "/ self findColorMapMode. |
|
3865 "/ self updateLabelsAndHistory. |
|
3866 ]. |
|
3867 self selectionOfColor value:oldSelection. |
|
3868 |
|
3869 "Created: / 12.3.1999 / 00:20:28 / cg" |
|
3870 "Modified: / 16.3.1999 / 21:57:26 / cg" |
|
3871 ! |
|
3872 |
3865 reduceNumberOfColors |
3873 reduceNumberOfColors |
3866 |s n anyChange img| |
3874 |s n anyChange img| |
3867 |
3875 |
3868 s := Dialog request:'Number of color bits to strip (1-7) ?'. |
3876 s := Dialog request:'Number of color bits to strip (1-7) ?'. |
3869 s size == 0 ifTrue:[^ self]. |
3877 s size == 0 ifTrue:[^ self]. |
3886 "/ self findColorMapMode. |
3894 "/ self findColorMapMode. |
3887 "/ self updateLabelsAndHistory. |
3895 "/ self updateLabelsAndHistory. |
3888 Dialog information:(img usedColors size printString , ' colors used.') |
3896 Dialog information:(img usedColors size printString , ' colors used.') |
3889 ] |
3897 ] |
3890 ]. |
3898 ]. |
|
3899 ! |
|
3900 |
|
3901 selectedColorIndexOrNil |
|
3902 | img clrIndex| |
|
3903 |
|
3904 img := self image. |
|
3905 img isNil ifTrue:[ |
|
3906 self warn:'No Image.'. |
|
3907 ^ nil |
|
3908 ]. |
|
3909 clrIndex := self selectionOfColor value. |
|
3910 img mask notNil ifTrue: [ clrIndex := clrIndex - 1 ]. |
|
3911 ^ clrIndex |
3891 ! |
3912 ! |
3892 |
3913 |
3893 sortColorMap |
3914 sortColorMap |
3894 "calculates a new color map for the image, sorting colors" |
3915 "calculates a new color map for the image, sorting colors" |
3895 |
3916 |