23 classVariableNames:'Clipboard ClipboardMagnified LastMagnification |
23 classVariableNames:'Clipboard ClipboardMagnified LastMagnification |
24 GridMagnificationLimit MaxUndos LastSaveDirectory LastSaveClass |
24 GridMagnificationLimit MaxUndos LastSaveDirectory LastSaveClass |
25 EditModePoint EditModeBox EditModeFilledBox EditModeFill |
25 EditModePoint EditModeBox EditModeFilledBox EditModeFill |
26 EditModeCopy EditModePasteUnder EditModePaste |
26 EditModeCopy EditModePasteUnder EditModePaste |
27 EditModePasteWithMask EditModeSpecialOperation EditModeSpray |
27 EditModePasteWithMask EditModeSpecialOperation EditModeSpray |
28 EditModeCircle' |
28 EditModeCircle EditModeSmooth' |
29 poolDictionaries:'' |
29 poolDictionaries:'' |
30 category:'Views-Misc' |
30 category:'Views-Misc' |
31 ! |
31 ! |
32 |
32 |
33 !ImageEditView class methodsFor:'documentation'! |
33 !ImageEditView class methodsFor:'documentation'! |
74 EditModeFilledBox := #filledBox. |
74 EditModeFilledBox := #filledBox. |
75 EditModeFill := #fill. |
75 EditModeFill := #fill. |
76 EditModeCopy := #copy. |
76 EditModeCopy := #copy. |
77 EditModeSpecialOperation := #specialOperation. |
77 EditModeSpecialOperation := #specialOperation. |
78 EditModeSpray := #spray. |
78 EditModeSpray := #spray. |
|
79 EditModeSmooth := #smooth. |
79 |
80 |
80 " |
81 " |
81 self initialize |
82 self initialize |
82 " |
83 " |
83 ! ! |
84 ! ! |
1688 |
1698 |
1689 "Modified: / 15-02-2012 / 22:47:30 / cg" |
1699 "Modified: / 15-02-2012 / 22:47:30 / cg" |
1690 ! |
1700 ! |
1691 |
1701 |
1692 pointAt:aPoint width:pw |
1702 pointAt:aPoint width:pw |
1693 "draw a single pixel with the currently selected color" |
1703 "draw a single pixel (or dot of width pw) with the currently selected color" |
1694 |
1704 |
1695 |draw imagePoint clr pix| |
1705 |draw imagePoint clr pix| |
1696 |
1706 |
1697 imagePoint := aPoint // magnification. |
1707 imagePoint := aPoint // magnification. |
1698 (imagePoint x between:0 and:image width-1) ifFalse:[^ self]. |
1708 (imagePoint x between:0 and:image width-1) ifFalse:[^ self]. |
1707 pix := self selectedColorIndex. |
1717 pix := self selectedColorIndex. |
1708 image atImageAndMask:point putValue:pix. |
1718 image atImageAndMask:point putValue:pix. |
1709 ]. |
1719 ]. |
1710 self invalidate:((point * magnification extent: magnification) expandedBy:1). |
1720 self invalidate:((point * magnification extent: magnification) expandedBy:1). |
1711 ]. |
1721 ]. |
|
1722 |
1712 draw value:imagePoint. |
1723 draw value:imagePoint. |
1713 |
1724 |
1714 pw == 1 ifTrue:[ |
1725 pw > 1 ifTrue:[ |
1715 draw value:imagePoint. |
|
1716 ] ifFalse:[ |
|
1717 "/ draw with a wide pen |
1726 "/ draw with a wide pen |
1718 (pw//2) negated to:(pw-(pw//2)-1) do:[:xOffs | |
1727 (pw//2) negated to:(pw-(pw//2)-1) do:[:xOffs | |
1719 (pw//2) negated to:(pw-(pw//2)-1) do:[:yOffs | |
1728 (pw//2) negated to:(pw-(pw//2)-1) do:[:yOffs | |
1720 imagePoint x + xOffs >= 0 ifTrue:[ |
1729 imagePoint x + xOffs >= 0 ifTrue:[ |
1721 imagePoint y + yOffs >= 0 ifTrue:[ |
1730 imagePoint y + yOffs >= 0 ifTrue:[ |
1824 |
1833 |
1825 ^ newImage. |
1834 ^ newImage. |
1826 |
1835 |
1827 "Created: / 7.9.1998 / 13:00:16 / cg" |
1836 "Created: / 7.9.1998 / 13:00:16 / cg" |
1828 "Modified: / 7.9.1998 / 14:15:32 / cg" |
1837 "Modified: / 7.9.1998 / 14:15:32 / cg" |
|
1838 ! |
|
1839 |
|
1840 smoothAt:aPoint |
|
1841 "smoth (average) a single pixel with pixels around" |
|
1842 |
|
1843 |draw imagePoint x y w h| |
|
1844 |
|
1845 imagePoint := aPoint // magnification. |
|
1846 w := image width. |
|
1847 h := image height. |
|
1848 ((x := imagePoint x) between:0 and:w-1) ifFalse:[^ self]. |
|
1849 ((y := imagePoint y) between:0 and:h-1) ifFalse:[^ self]. |
|
1850 |
|
1851 draw := |
|
1852 [:point | |
|
1853 |sumRed sumGreen sumBlue newClr| |
|
1854 |
|
1855 sumRed := sumGreen := sumBlue := 0. |
|
1856 -1 to:1 do:[:dx | |
|
1857 -1 to:1 do:[:dy | |
|
1858 |clr| |
|
1859 |
|
1860 ((x + dx) between:0 and:w-1) ifTrue:[ |
|
1861 ((y + dy) between:0 and:h-1) ifTrue:[ |
|
1862 clr := image colorAtX:(x + dx) y:(y + dy). |
|
1863 sumRed := sumRed + clr redByte. |
|
1864 sumGreen := sumGreen + clr greenByte. |
|
1865 sumBlue := sumBlue + clr blueByte. |
|
1866 ] |
|
1867 ]. |
|
1868 ] |
|
1869 ]. |
|
1870 newClr := Color |
|
1871 redByte:(sumRed / 9) rounded |
|
1872 greenByte:(sumGreen / 9) rounded |
|
1873 blueByte:(sumBlue / 9) rounded. |
|
1874 image colorMap isNil ifTrue:[ |
|
1875 Transcript |
|
1876 show:(image colorAt:point); |
|
1877 show:' -> '; |
|
1878 showCR:newClr. |
|
1879 image atImageAndMask:point put:newClr. |
|
1880 ] ifFalse:[ |
|
1881 image atImageAndMask:point put:(image colorMap colorNearestTo:newClr). |
|
1882 ]. |
|
1883 self invalidate:((point * magnification extent: magnification) expandedBy:1). |
|
1884 ]. |
|
1885 |
|
1886 draw value:imagePoint. |
|
1887 self setModified. |
1829 ! |
1888 ! |
1830 |
1889 |
1831 specialOperationAt: aPoint |
1890 specialOperationAt: aPoint |
1832 "special operation on a rectangular area" |
1891 "special operation on a rectangular area" |
1833 |
1892 |
2796 ! ! |
2855 ! ! |
2797 |
2856 |
2798 !ImageEditView class methodsFor:'documentation'! |
2857 !ImageEditView class methodsFor:'documentation'! |
2799 |
2858 |
2800 version |
2859 version |
2801 ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.263 2015-02-22 10:25:33 cg Exp $' |
2860 ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.264 2015-02-22 12:29:21 cg Exp $' |
2802 ! |
2861 ! |
2803 |
2862 |
2804 version_CVS |
2863 version_CVS |
2805 ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.263 2015-02-22 10:25:33 cg Exp $' |
2864 ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.264 2015-02-22 12:29:21 cg Exp $' |
2806 ! ! |
2865 ! ! |
2807 |
2866 |
2808 |
2867 |
2809 ImageEditView initialize! |
2868 ImageEditView initialize! |