ImageEditor.st
changeset 1649 80586cf27eb8
parent 1644 df1f5a97b8e9
child 1650 cb63d6bf76c1
equal deleted inserted replaced
1648:d88ec5777284 1649:80586cf27eb8
   906          
   906          
   907         )
   907         )
   908       )
   908       )
   909 !
   909 !
   910 
   910 
       
   911 hueShiftDialogSpec
       
   912     "This resource specification was automatically generated
       
   913      by the UIPainter of ST/X."
       
   914 
       
   915     "Do not manually edit this!! If it is corrupted,
       
   916      the UIPainter may not be able to read the specification."
       
   917 
       
   918     "
       
   919      UIPainter new openOnClass:ImageEditor andSelector:#hueShiftDialogSpec
       
   920      ImageEditor new openInterface:#hueShiftDialogSpec
       
   921     "
       
   922 
       
   923     <resource: #canvas>
       
   924 
       
   925     ^ 
       
   926      #(#FullSpec
       
   927         #name: #hueShiftDialogSpec
       
   928         #window: 
       
   929        #(#WindowSpec
       
   930           #label: 'Shift Hue'
       
   931           #name: 'Shift Hue'
       
   932           #min: #(#Point 10 10)
       
   933           #max: #(#Point 800 478)
       
   934           #bounds: #(#Rectangle 16 46 261 229)
       
   935         )
       
   936         #component: 
       
   937        #(#SpecCollection
       
   938           #collection: #(
       
   939            #(#LabelSpec
       
   940               #label: 'Hue-Shift:'
       
   941               #name: 'HueLabel'
       
   942               #layout: #(#LayoutFrame 14 0 21 0 90 0 43 0)
       
   943               #translateLabel: true
       
   944               #adjust: #right
       
   945             )
       
   946            #(#InputFieldSpec
       
   947               #name: 'HueShiftEntryField'
       
   948               #layout: #(#LayoutFrame 95 0 21 0 138 0 43 0)
       
   949               #tabable: true
       
   950               #model: #hueShiftAmount
       
   951               #type: #number
       
   952               #acceptChannel: #acceptChannel
       
   953               #acceptOnPointerLeave: false
       
   954             )
       
   955            #(#HorizontalPanelViewSpec
       
   956               #name: 'HorizontalPanel1'
       
   957               #layout: #(#LayoutFrame 0 0.0 -30 1 0 1.0 0 1)
       
   958               #horizontalLayout: #fitSpace
       
   959               #verticalLayout: #center
       
   960               #horizontalSpace: 3
       
   961               #verticalSpace: 3
       
   962               #reverseOrderIfOKAtLeft: true
       
   963               #component: 
       
   964              #(#SpecCollection
       
   965                 #collection: #(
       
   966                  #(#ActionButtonSpec
       
   967                     #label: 'Cancel'
       
   968                     #name: 'Button1'
       
   969                     #translateLabel: true
       
   970                     #tabable: true
       
   971                     #model: #cancel
       
   972                     #extent: #(#Point 118 22)
       
   973                   )
       
   974                  #(#ActionButtonSpec
       
   975                     #label: 'OK'
       
   976                     #name: 'Button2'
       
   977                     #translateLabel: true
       
   978                     #tabable: true
       
   979                     #model: #accept
       
   980                     #extent: #(#Point 118 22)
       
   981                   )
       
   982                  )
       
   983                
       
   984               )
       
   985             )
       
   986            #(#ThumbWheelSpec
       
   987               #name: 'ThumbWheel1'
       
   988               #layout: #(#LayoutFrame 60 0 83 0 177 0 103 0)
       
   989               #model: #hueShiftAmount
       
   990               #orientation: #horizontal
       
   991               #step: 1
       
   992               #endlessRotation: true
       
   993             )
       
   994            #(#LabelSpec
       
   995               #name: 'HueColorLabel'
       
   996               #layout: #(#LayoutFrame 5 0 109 0 241 0 148 0)
       
   997               #translateLabel: true
       
   998               #backgroundChannel: #hueColor
       
   999             )
       
  1000            )
       
  1001          
       
  1002         )
       
  1003       )
       
  1004 !
       
  1005 
   911 shiftDialogSpec
  1006 shiftDialogSpec
   912     "This resource specification was automatically generated
  1007     "This resource specification was automatically generated
   913      by the UIPainter of ST/X."
  1008      by the UIPainter of ST/X."
   914 
  1009 
   915     "Do not manually edit this!! If it is corrupted,
  1010     "Do not manually edit this!! If it is corrupted,
   983                
  1078                
   984               )
  1079               )
   985             )
  1080             )
   986            #(#ArrowButtonSpec
  1081            #(#ArrowButtonSpec
   987               #name: 'ArrowButton1'
  1082               #name: 'ArrowButton1'
   988               #layout: #(#LayoutFrame 105 0 67 0 127 0 89 0)
  1083               #layout: #(#LayoutFrame 105 0 63 0 127 0 85 0)
   989               #model: #shiftUpNow
  1084               #model: #shiftUpNow
   990               #isTriggerOnDown: true
  1085               #isTriggerOnDown: true
   991               #actionValue: ''
  1086               #actionValue: ''
   992               #direction: #up
  1087               #direction: #up
   993             )
  1088             )
   994            #(#ArrowButtonSpec
  1089            #(#ArrowButtonSpec
   995               #name: 'ArrowButton2'
  1090               #name: 'ArrowButton2'
   996               #layout: #(#LayoutFrame 88 0 86 0 110 0 108 0)
  1091               #layout: #(#LayoutFrame 84 0 86 0 106 0 108 0)
   997               #model: #shiftLeftNow
  1092               #model: #shiftLeftNow
   998               #isTriggerOnDown: true
  1093               #isTriggerOnDown: true
   999               #actionValue: ''
  1094               #actionValue: ''
  1000               #direction: #left
  1095               #direction: #left
  1001             )
  1096             )
  1002            #(#ArrowButtonSpec
  1097            #(#ArrowButtonSpec
  1003               #name: 'ArrowButton3'
  1098               #name: 'ArrowButton3'
  1004               #layout: #(#LayoutFrame 122 0 86 0 144 0 108 0)
  1099               #layout: #(#LayoutFrame 126 0 86 0 148 0 108 0)
  1005               #model: #shiftRightNow
  1100               #model: #shiftRightNow
  1006               #isTriggerOnDown: true
  1101               #isTriggerOnDown: true
  1007               #actionValue: ''
  1102               #actionValue: ''
  1008               #direction: #right
  1103               #direction: #right
  1009             )
  1104             )
  1010            #(#ArrowButtonSpec
  1105            #(#ArrowButtonSpec
  1011               #name: 'ArrowButton4'
  1106               #name: 'ArrowButton4'
  1012               #layout: #(#LayoutFrame 105 0 103 0 127 0 125 0)
  1107               #layout: #(#LayoutFrame 105 0 107 0 127 0 129 0)
  1013               #model: #shiftDownNow
  1108               #model: #shiftDownNow
  1014               #isTriggerOnDown: true
  1109               #isTriggerOnDown: true
  1015               #actionValue: ''
  1110               #actionValue: ''
  1016               #direction: #down
  1111               #direction: #down
  1017             )
  1112             )
  1738             #translateLabel: true
  1833             #translateLabel: true
  1739             #submenu: 
  1834             #submenu: 
  1740            #(#Menu
  1835            #(#Menu
  1741               #(
  1836               #(
  1742                #(#MenuItem
  1837                #(#MenuItem
  1743                   #activeHelpKey: #colorMap8
  1838                   #label: 'Depth'
  1744                   #label: '8-Plane'
       
  1745                   #itemValue: #colorMapMode:
       
  1746                   #translateLabel: true
  1839                   #translateLabel: true
  1747                   #argument: '8-plane'
  1840                   #submenu: 
  1748                   #choice: #colorMapMode
  1841                  #(#Menu
  1749                   #choiceValue: '8-plane'
  1842                     #(
       
  1843                      #(#MenuItem
       
  1844                         #activeHelpKey: #colorMap8
       
  1845                         #label: '8-Plane'
       
  1846                         #itemValue: #colorMapMode:
       
  1847                         #translateLabel: true
       
  1848                         #argument: '8-plane'
       
  1849                         #choice: #colorMapMode
       
  1850                         #choiceValue: '8-plane'
       
  1851                       )
       
  1852                      #(#MenuItem
       
  1853                         #activeHelpKey: #colorMap4
       
  1854                         #label: '4-Plane'
       
  1855                         #itemValue: #colorMapMode:
       
  1856                         #translateLabel: true
       
  1857                         #argument: '4-plane'
       
  1858                         #choice: #colorMapMode
       
  1859                         #choiceValue: '4-plane'
       
  1860                       )
       
  1861                      #(#MenuItem
       
  1862                         #activeHelpKey: #colorMap2
       
  1863                         #label: '2-Plane'
       
  1864                         #itemValue: #colorMapMode:
       
  1865                         #translateLabel: true
       
  1866                         #argument: '2-plane'
       
  1867                         #choice: #colorMapMode
       
  1868                         #choiceValue: '2-plane'
       
  1869                       )
       
  1870                      #(#MenuItem
       
  1871                         #activeHelpKey: #colorMap1
       
  1872                         #label: '1-Plane'
       
  1873                         #itemValue: #colorMapMode:
       
  1874                         #translateLabel: true
       
  1875                         #argument: '1-plane'
       
  1876                         #choice: #colorMapMode
       
  1877                         #choiceValue: '1-plane'
       
  1878                       )
       
  1879                      #(#MenuItem
       
  1880                         #label: '-'
       
  1881                       )
       
  1882                      #(#MenuItem
       
  1883                         #activeHelpKey: #colorMap8M
       
  1884                         #label: '8-Plane + Mask'
       
  1885                         #itemValue: #colorMapMode:
       
  1886                         #translateLabel: true
       
  1887                         #argument: '8-plane + mask'
       
  1888                         #choice: #colorMapMode
       
  1889                         #choiceValue: '8-plane + mask'
       
  1890                       )
       
  1891                      #(#MenuItem
       
  1892                         #activeHelpKey: #colorMap4M
       
  1893                         #label: '4-Plane + Mask'
       
  1894                         #itemValue: #colorMapMode:
       
  1895                         #translateLabel: true
       
  1896                         #argument: '4-plane + mask'
       
  1897                         #choice: #colorMapMode
       
  1898                         #choiceValue: '4-plane + mask'
       
  1899                       )
       
  1900                      #(#MenuItem
       
  1901                         #activeHelpKey: #colorMap2M
       
  1902                         #label: '2-Plane + Mask'
       
  1903                         #itemValue: #colorMapMode:
       
  1904                         #translateLabel: true
       
  1905                         #argument: '2-plane + mask'
       
  1906                         #choice: #colorMapMode
       
  1907                         #choiceValue: '2-plane + mask'
       
  1908                       )
       
  1909                      #(#MenuItem
       
  1910                         #activeHelpKey: #colorMap1M
       
  1911                         #label: '1-Plane + Mask'
       
  1912                         #itemValue: #colorMapMode:
       
  1913                         #translateLabel: true
       
  1914                         #argument: '1-plane + mask'
       
  1915                         #choice: #colorMapMode
       
  1916                         #choiceValue: '1-plane + mask'
       
  1917                       )
       
  1918                      )
       
  1919                     nil
       
  1920                     nil
       
  1921                   )
  1750                 )
  1922                 )
  1751                #(#MenuItem
  1923                #(#MenuItem
  1752                   #activeHelpKey: #colorMap4
  1924                   #label: 'Colors'
  1753                   #label: '4-Plane'
       
  1754                   #itemValue: #colorMapMode:
       
  1755                   #translateLabel: true
  1925                   #translateLabel: true
  1756                   #argument: '4-plane'
  1926                   #submenu: 
  1757                   #choice: #colorMapMode
  1927                  #(#Menu
  1758                   #choiceValue: '4-plane'
  1928                     #(
       
  1929                      #(#MenuItem
       
  1930                         #activeHelpKey: #compressColormap
       
  1931                         #enabled: #hasColormap
       
  1932                         #label: 'Compress Colormap'
       
  1933                         #itemValue: #compressColorMap
       
  1934                         #translateLabel: true
       
  1935                       )
       
  1936                      #(#MenuItem
       
  1937                         #enabled: #hasColormap
       
  1938                         #label: 'Sort Colormap'
       
  1939                         #itemValue: #sortColorMap
       
  1940                         #translateLabel: true
       
  1941                       )
       
  1942                      #(#MenuItem
       
  1943                         #label: 'Reduce Number of Colors...'
       
  1944                         #itemValue: #reduceNumberOfColors
       
  1945                         #translateLabel: true
       
  1946                       )
       
  1947                      )
       
  1948                     nil
       
  1949                     nil
       
  1950                   )
  1759                 )
  1951                 )
  1760                #(#MenuItem
  1952                #(#MenuItem
  1761                   #activeHelpKey: #colorMap2
  1953                   #label: 'Process'
  1762                   #label: '2-Plane'
       
  1763                   #itemValue: #colorMapMode:
       
  1764                   #translateLabel: true
  1954                   #translateLabel: true
  1765                   #argument: '2-plane'
  1955                   #submenu: 
  1766                   #choice: #colorMapMode
  1956                  #(#Menu
  1767                   #choiceValue: '2-plane'
  1957                     #(
       
  1958                      #(#MenuItem
       
  1959                         #label: 'Make GrayScale'
       
  1960                         #itemValue: #makeGrayScale
       
  1961                         #translateLabel: true
       
  1962                       )
       
  1963                      #(#MenuItem
       
  1964                         #label: 'Make Brighter'
       
  1965                         #itemValue: #makeBrighter
       
  1966                         #translateLabel: true
       
  1967                       )
       
  1968                      #(#MenuItem
       
  1969                         #label: 'Make Darker'
       
  1970                         #itemValue: #makeDarker
       
  1971                         #translateLabel: true
       
  1972                       )
       
  1973                      #(#MenuItem
       
  1974                         #label: 'Make Inverse'
       
  1975                         #itemValue: #makeInverse
       
  1976                         #translateLabel: true
       
  1977                       )
       
  1978                      #(#MenuItem
       
  1979                         #label: '-'
       
  1980                       )
       
  1981                      #(#MenuItem
       
  1982                         #label: 'Change Hue...'
       
  1983                         #itemValue: #changeHue
       
  1984                         #translateLabel: true
       
  1985                       )
       
  1986                      )
       
  1987                     nil
       
  1988                     nil
       
  1989                   )
  1768                 )
  1990                 )
  1769                #(#MenuItem
  1991                #(#MenuItem
  1770                   #activeHelpKey: #colorMap1
  1992                   #label: 'Mask'
  1771                   #label: '1-Plane'
       
  1772                   #itemValue: #colorMapMode:
       
  1773                   #translateLabel: true
  1993                   #translateLabel: true
  1774                   #argument: '1-plane'
  1994                   #submenu: 
  1775                   #choice: #colorMapMode
  1995                  #(#Menu
  1776                   #choiceValue: '1-plane'
  1996                     #(
  1777                 )
  1997                      #(#MenuItem
  1778                #(#MenuItem
  1998                         #activeHelpKey: #copyMask
  1779                   #label: '-'
  1999                         #enabled: #hasMask
  1780                 )
  2000                         #label: 'Copy Mask'
  1781                #(#MenuItem
  2001                         #itemValue: #copyMask
  1782                   #activeHelpKey: #colorMap8M
  2002                         #translateLabel: true
  1783                   #label: '8-Plane + Mask'
  2003                       )
  1784                   #itemValue: #colorMapMode:
  2004                      #(#MenuItem
  1785                   #translateLabel: true
  2005                         #activeHelpKey: #pasteMask
  1786                   #argument: '8-plane + mask'
  2006                         #enabled: #hasMask
  1787                   #choice: #colorMapMode
  2007                         #label: 'Paste Mask'
  1788                   #choiceValue: '8-plane + mask'
  2008                         #itemValue: #pasteMask
  1789                 )
  2009                         #translateLabel: true
  1790                #(#MenuItem
  2010                       )
  1791                   #activeHelpKey: #colorMap4M
  2011                      #(#MenuItem
  1792                   #label: '4-Plane + Mask'
  2012                         #label: 'Clear Masked Pixels'
  1793                   #itemValue: #colorMapMode:
  2013                         #itemValue: #clearMaskedPixels
  1794                   #translateLabel: true
  2014                         #translateLabel: true
  1795                   #argument: '4-plane + mask'
  2015                       )
  1796                   #choice: #colorMapMode
  2016                      )
  1797                   #choiceValue: '4-plane + mask'
  2017                     nil
  1798                 )
  2018                     nil
  1799                #(#MenuItem
  2019                   )
  1800                   #activeHelpKey: #colorMap2M
       
  1801                   #label: '2-Plane + Mask'
       
  1802                   #itemValue: #colorMapMode:
       
  1803                   #translateLabel: true
       
  1804                   #argument: '2-plane + mask'
       
  1805                   #choice: #colorMapMode
       
  1806                   #choiceValue: '2-plane + mask'
       
  1807                 )
       
  1808                #(#MenuItem
       
  1809                   #activeHelpKey: #colorMap1M
       
  1810                   #label: '1-Plane + Mask'
       
  1811                   #itemValue: #colorMapMode:
       
  1812                   #translateLabel: true
       
  1813                   #argument: '1-plane + mask'
       
  1814                   #choice: #colorMapMode
       
  1815                   #choiceValue: '1-plane + mask'
       
  1816                 )
       
  1817                #(#MenuItem
       
  1818                   #label: '-'
       
  1819                 )
       
  1820                #(#MenuItem
       
  1821                   #activeHelpKey: #compressColormap
       
  1822                   #enabled: #hasColormap
       
  1823                   #label: 'Compress Colormap'
       
  1824                   #itemValue: #compressColorMap
       
  1825                   #translateLabel: true
       
  1826                 )
       
  1827                #(#MenuItem
       
  1828                   #enabled: #hasColormap
       
  1829                   #label: 'Sort Colormap'
       
  1830                   #itemValue: #sortColorMap
       
  1831                   #translateLabel: true
       
  1832                 )
       
  1833                #(#MenuItem
       
  1834                   #label: 'Reduce Number of Colors...'
       
  1835                   #itemValue: #reduceNumberOfColors
       
  1836                   #translateLabel: true
       
  1837                 )
       
  1838                #(#MenuItem
       
  1839                   #label: '-'
       
  1840                 )
       
  1841                #(#MenuItem
       
  1842                   #label: 'Make GrayScale'
       
  1843                   #itemValue: #makeGrayScale
       
  1844                   #translateLabel: true
       
  1845                 )
       
  1846                #(#MenuItem
       
  1847                   #label: 'Make Brighter'
       
  1848                   #itemValue: #makeBrighter
       
  1849                   #translateLabel: true
       
  1850                 )
       
  1851                #(#MenuItem
       
  1852                   #label: 'Make Darker'
       
  1853                   #itemValue: #makeDarker
       
  1854                   #translateLabel: true
       
  1855                 )
       
  1856                #(#MenuItem
       
  1857                   #label: 'Make Inverse'
       
  1858                   #itemValue: #makeInverse
       
  1859                   #translateLabel: true
       
  1860                 )
       
  1861                #(#MenuItem
       
  1862                   #label: '-'
       
  1863                 )
       
  1864                #(#MenuItem
       
  1865                   #activeHelpKey: #copyMask
       
  1866                   #enabled: #hasMask
       
  1867                   #label: 'Copy Mask'
       
  1868                   #itemValue: #copyMask
       
  1869                   #translateLabel: true
       
  1870                 )
       
  1871                #(#MenuItem
       
  1872                   #activeHelpKey: #pasteMask
       
  1873                   #enabled: #hasMask
       
  1874                   #label: 'Paste Mask'
       
  1875                   #itemValue: #pasteMask
       
  1876                   #translateLabel: true
       
  1877                 )
       
  1878                #(#MenuItem
       
  1879                   #label: 'Clear Masked Pixels'
       
  1880                   #itemValue: #clearMaskedPixels
       
  1881                   #translateLabel: true
       
  1882                 )
  2020                 )
  1883                )
  2021                )
  1884               nil
  2022               nil
  1885               nil
  2023               nil
  1886             )
  2024             )
  3071 
  3209 
  3072     "Created: / 12.3.1999 / 00:20:28 / cg"
  3210     "Created: / 12.3.1999 / 00:20:28 / cg"
  3073     "Modified: / 16.3.1999 / 21:57:26 / cg"
  3211     "Modified: / 16.3.1999 / 21:57:26 / cg"
  3074 !
  3212 !
  3075 
  3213 
       
  3214 changeHue
       
  3215     "let user specify amount and shift"
       
  3216 
       
  3217     |bindings shiftAmount originalColormap img firstChange shiftAction acceptChannel hueColorHolder|
       
  3218 
       
  3219     originalColormap := imageEditView image colorMap copy.
       
  3220 
       
  3221     acceptChannel := TriggerValue new.
       
  3222 
       
  3223     firstChange := true.
       
  3224 
       
  3225     shiftAction := 
       
  3226         [
       
  3227             acceptChannel value:true.
       
  3228 
       
  3229             firstChange ifTrue:[
       
  3230                 imageEditView makeUndo.
       
  3231                 firstChange := false.
       
  3232             ].
       
  3233             hueColorHolder value:(Color hue:shiftAmount value light:50 saturation:100).
       
  3234             imageEditView image colorMap:originalColormap copy.
       
  3235             imageEditView image colorMapProcessing:[:clr | Color hue:((clr hue) ? 0+shiftAmount value) light:clr light saturation:clr saturation].
       
  3236             self updateImage.
       
  3237             self updateInfoLabel.
       
  3238         ].
       
  3239 
       
  3240     bindings := IdentityDictionary new.
       
  3241     bindings at:#hueShiftAmount put:(shiftAmount := 0 asValue).
       
  3242     (bindings at:#hueShiftAmount) onChangeEvaluate:shiftAction.
       
  3243     bindings at:#acceptChannel put:acceptChannel.
       
  3244     bindings at:#hueColor put:(hueColorHolder := Color white asValue).
       
  3245 
       
  3246     (self openDialogInterface:#hueShiftDialogSpec withBindings:bindings) 
       
  3247     ifFalse:[ 
       
  3248         firstChange ~~ true ifTrue:[
       
  3249             imageEditView undo
       
  3250         ]
       
  3251     ].
       
  3252 !
       
  3253 
  3076 clearMaskedPixels
  3254 clearMaskedPixels
  3077     "clear all masked pixels (to pixelValue 0)"
  3255     "clear all masked pixels (to pixelValue 0)"
  3078 
  3256 
  3079     |newImage oldImage| 
  3257     |newImage oldImage| 
  3080 
  3258