173 1 to: 25 do: |
173 1 to: 25 do: |
174 [:g| |
174 [:g| |
175 colorMap add: (Color redByte: (g*255//26) ceiling greenByte: (g*255//26) ceiling blueByte: (g*255//26) ceiling) |
175 colorMap add: (Color redByte: (g*255//26) ceiling greenByte: (g*255//26) ceiling blueByte: (g*255//26) ceiling) |
176 ]. |
176 ]. |
177 |
177 |
178 ^Dictionary new |
178 ^ Dictionary new |
179 at: '8-plane' put: colorMap; |
179 at: #depth24 put:(FixedPalette redShift:16 redMask:16rFF greenShift:8 greenMask:16rFF blueShift:0 blueMask:16rFF); |
180 at: '8-plane + mask' put: colorMap; |
180 at: #masked24 put:(FixedPalette redShift:16 redMask:16rFF greenShift:8 greenMask:16rFF blueShift:0 blueMask:16rFF); |
181 at: '4-plane' put: (colorMap copyFrom: 1 to: 16); |
181 at: #depth16 put:(FixedPalette redShift:11 redMask:16r1F greenShift:5 greenMask:16r3F blueShift:0 blueMask:16r1F); |
182 at: '4-plane + mask' put: (colorMap copyFrom: 1 to: 16); |
182 at: #masked16 put:(FixedPalette redShift:11 redMask:16r1F greenShift:5 greenMask:16r3F blueShift:0 blueMask:16r1F); |
183 at: '2-plane' put: (colorMap copyFrom: 1 to: 4); |
183 at: #depth8 put: colorMap; |
184 at: '2-plane + mask' put: (colorMap copyFrom: 1 to: 4); |
184 at: #masked8 put: colorMap; |
185 at: '1-plane' put: (colorMap copyFrom: 1 to: 2); |
185 at: #depth4 put: (colorMap copyFrom: 1 to: 16); |
186 at: '1-plane + mask' put: (colorMap copyFrom: 1 to: 2); |
186 at: #masked4 put: (colorMap copyFrom: 1 to: 16); |
|
187 at: #depth2 put: (colorMap copyFrom: 1 to: 4); |
|
188 at: #masked2 put: (colorMap copyFrom: 1 to: 4); |
|
189 at: #depth1 put: (colorMap copyFrom: 1 to: 2); |
|
190 at: #masked1 put: (colorMap copyFrom: 1 to: 2); |
187 yourself |
191 yourself |
188 ! |
192 ! |
189 |
193 |
190 listOfDefaultSizes |
194 listOfDefaultSizes |
191 "returns the list of default sizes for a new image" |
195 "returns the list of default sizes for a new image" |
192 |
196 |
193 ^#('8x8' '16x16' '22x22' '32x32' '48x48' '64x64') |
197 ^#('8x8' '16x16' '22x22' '32x32' '48x48' '64x64') |
194 |
198 |
195 "Modified: / 31.7.1998 / 01:57:34 / cg" |
199 "Modified: / 31.7.1998 / 01:57:34 / cg" |
|
200 ! |
|
201 |
|
202 namesOfColorMaps |
|
203 ^ Dictionary new |
|
204 at: #depth24 put: '24-plane'; |
|
205 at: #masked24 put: '24-plane + mask'; |
|
206 at: #depth16 put: '16-plane'; |
|
207 at: #masked16 put: '16-plane + mask'; |
|
208 at: #depth8 put: ' 8-plane'; |
|
209 at: #masked8 put: ' 8-plane + mask'; |
|
210 at: #depth4 put: ' 4-plane'; |
|
211 at: #masked4 put: ' 4-plane + mask'; |
|
212 at: #depth2 put: ' 2-plane'; |
|
213 at: #masked2 put: ' 2-plane + mask'; |
|
214 at: #depth1 put: ' 1-plane'; |
|
215 at: #masked1 put: ' 1-plane + mask' ; |
|
216 yourself |
196 ! ! |
217 ! ! |
197 |
218 |
198 !ImageEditor class methodsFor:'help specs'! |
219 !ImageEditor class methodsFor:'help specs'! |
199 |
220 |
200 flyByHelpSpec |
221 flyByHelpSpec |
1559 |
1581 |
1560 "Do not manually edit this!! If it is corrupted, |
1582 "Do not manually edit this!! If it is corrupted, |
1561 the MenuEditor may not be able to read the specification." |
1583 the MenuEditor may not be able to read the specification." |
1562 |
1584 |
1563 " |
1585 " |
1564 MenuEditor new openOnClass:ImageEditor andSelector:#menuSpec |
1586 MenuEditor new openOnClass:ImageEditor andSelector:#colorMapMenu |
1565 (Menu new fromLiteralArrayEncoding:(ImageEditor menuSpec)) startUp |
1587 (Menu new fromLiteralArrayEncoding:(ImageEditor colorMapMenu)) startUp |
1566 " |
1588 " |
1567 |
1589 |
1568 <resource: #menu> |
1590 <resource: #menu> |
1569 |
1591 |
1570 ^ |
1592 ^ |
1571 |
1593 #(Menu |
1572 #(#Menu |
1594 ( |
1573 |
1595 (MenuItem |
1574 #( |
1596 enabled: hasColormap |
1575 #(#MenuItem |
1597 label: 'Add Color' |
1576 #label: 'Add Color' |
1598 itemValue: addColorToColormap |
1577 #translateLabel: true |
1599 translateLabel: true |
1578 #value: #addColorToColormap |
1600 ) |
1579 #enabled: #hasColormap |
1601 (MenuItem |
1580 ) |
1602 enabled: hasColormap |
1581 #(#MenuItem |
1603 label: 'Pick and Add Color' |
1582 #label: 'Pick and Add Color' |
1604 itemValue: pickAndAddColorToColormap |
1583 #translateLabel: true |
1605 translateLabel: true |
1584 #value: #pickAndAddColorToColormap |
1606 ) |
1585 #enabled: #hasColormap |
1607 (MenuItem |
1586 ) |
1608 label: '-' |
1587 #(#MenuItem |
1609 ) |
1588 #label: '-' |
1610 (MenuItem |
1589 ) |
1611 enabled: hasColormap |
1590 #(#MenuItem |
1612 label: 'Brighter' |
1591 #label: 'Brighter' |
1613 itemValue: makeSelectedColorBrighter |
1592 #translateLabel: true |
1614 translateLabel: true |
1593 #value: #makeSelectedColorBrighter |
1615 ) |
1594 #enabled: #hasColormap |
1616 (MenuItem |
1595 ) |
1617 enabled: hasColormap |
1596 #(#MenuItem |
1618 label: 'Darker' |
1597 #label: 'Darker' |
1619 itemValue: makeSelectedColorDarker |
1598 #translateLabel: true |
1620 translateLabel: true |
1599 #value: #makeSelectedColorDarker |
1621 ) |
1600 #enabled: #hasColormap |
1622 (MenuItem |
1601 ) |
1623 enabled: hasColormap |
1602 #(#MenuItem |
1624 label: 'Edit Color' |
1603 #label: '-' |
1625 itemValue: editSelectedColor |
1604 ) |
1626 translateLabel: true |
1605 #(#MenuItem |
1627 ) |
1606 #label: 'Inspect Color' |
1628 (MenuItem |
1607 #translateLabel: true |
1629 label: '-' |
1608 #value: #inspectColor |
1630 ) |
1609 #enabled: #hasColormap |
1631 (MenuItem |
1610 ) |
1632 enabled: hasColormap |
1611 ) nil |
1633 label: 'Inspect Color' |
1612 nil |
1634 itemValue: inspectColor |
|
1635 translateLabel: true |
|
1636 ) |
|
1637 ) |
|
1638 nil |
|
1639 nil |
1613 ) |
1640 ) |
1614 |
|
1615 "Created: / 12.3.1999 / 00:19:00 / cg" |
|
1616 ! |
1641 ! |
1617 |
1642 |
1618 menu |
1643 menu |
1619 "This resource specification was automatically generated |
1644 "This resource specification was automatically generated |
1620 by the MenuEditor of ST/X." |
1645 by the MenuEditor of ST/X." |
1931 #(#MenuItem |
1956 #(#MenuItem |
1932 #activeHelpKey: #colorMap8 |
1957 #activeHelpKey: #colorMap8 |
1933 #label: '8-Plane' |
1958 #label: '8-Plane' |
1934 #itemValue: #colorMapMode: |
1959 #itemValue: #colorMapMode: |
1935 #translateLabel: true |
1960 #translateLabel: true |
1936 #argument: '8-plane' |
1961 #argument: #depth8 |
1937 #choice: #colorMapMode |
1962 #choice: #colorMapMode |
1938 #choiceValue: '8-plane' |
1963 #choiceValue: #depth8 |
1939 ) |
1964 ) |
1940 #(#MenuItem |
1965 #(#MenuItem |
1941 #activeHelpKey: #colorMap4 |
1966 #activeHelpKey: #colorMap4 |
1942 #label: '4-Plane' |
1967 #label: '4-Plane' |
1943 #itemValue: #colorMapMode: |
1968 #itemValue: #colorMapMode: |
1944 #translateLabel: true |
1969 #translateLabel: true |
1945 #argument: '4-plane' |
1970 #argument: #depth4 |
1946 #choice: #colorMapMode |
1971 #choice: #colorMapMode |
1947 #choiceValue: '4-plane' |
1972 #choiceValue: #depth4 |
1948 ) |
1973 ) |
1949 #(#MenuItem |
1974 #(#MenuItem |
1950 #activeHelpKey: #colorMap2 |
1975 #activeHelpKey: #colorMap2 |
1951 #label: '2-Plane' |
1976 #label: '2-Plane' |
1952 #itemValue: #colorMapMode: |
1977 #itemValue: #colorMapMode: |
1953 #translateLabel: true |
1978 #translateLabel: true |
1954 #argument: '2-plane' |
1979 #argument: #depth2 |
1955 #choice: #colorMapMode |
1980 #choice: #colorMapMode |
1956 #choiceValue: '2-plane' |
1981 #choiceValue: #depth2 |
1957 ) |
1982 ) |
1958 #(#MenuItem |
1983 #(#MenuItem |
1959 #activeHelpKey: #colorMap1 |
1984 #activeHelpKey: #colorMap1 |
1960 #label: '1-Plane' |
1985 #label: '1-Plane' |
1961 #itemValue: #colorMapMode: |
1986 #itemValue: #colorMapMode: |
1962 #translateLabel: true |
1987 #translateLabel: true |
1963 #argument: '1-plane' |
1988 #argument: #depth1 |
1964 #choice: #colorMapMode |
1989 #choice: #colorMapMode |
1965 #choiceValue: '1-plane' |
1990 #choiceValue: #depth1 |
1966 ) |
1991 ) |
1967 #(#MenuItem |
1992 #(#MenuItem |
1968 #label: '-' |
1993 #label: '-' |
1969 ) |
1994 ) |
1970 #(#MenuItem |
1995 #(#MenuItem |
1971 #activeHelpKey: #colorMap8M |
1996 #activeHelpKey: #colorMap8M |
1972 #label: '8-Plane + Mask' |
1997 #label: '8-Plane + Mask' |
1973 #itemValue: #colorMapMode: |
1998 #itemValue: #colorMapMode: |
1974 #translateLabel: true |
1999 #translateLabel: true |
1975 #argument: '8-plane + mask' |
2000 #argument: #masked8 |
1976 #choice: #colorMapMode |
2001 #choice: #colorMapMode |
1977 #choiceValue: '8-plane + mask' |
2002 #choiceValue: #masked8 |
1978 ) |
2003 ) |
1979 #(#MenuItem |
2004 #(#MenuItem |
1980 #activeHelpKey: #colorMap4M |
2005 #activeHelpKey: #colorMap4M |
1981 #label: '4-Plane + Mask' |
2006 #label: '4-Plane + Mask' |
1982 #itemValue: #colorMapMode: |
2007 #itemValue: #colorMapMode: |
1983 #translateLabel: true |
2008 #translateLabel: true |
1984 #argument: '4-plane + mask' |
2009 #argument: #masked4 |
1985 #choice: #colorMapMode |
2010 #choice: #colorMapMode |
1986 #choiceValue: '4-plane + mask' |
2011 #choiceValue: #masked4 |
1987 ) |
2012 ) |
1988 #(#MenuItem |
2013 #(#MenuItem |
1989 #activeHelpKey: #colorMap2M |
2014 #activeHelpKey: #colorMap2M |
1990 #label: '2-Plane + Mask' |
2015 #label: '2-Plane + Mask' |
1991 #itemValue: #colorMapMode: |
2016 #itemValue: #colorMapMode: |
1992 #translateLabel: true |
2017 #translateLabel: true |
1993 #argument: '2-plane + mask' |
2018 #argument: #masked2 |
1994 #choice: #colorMapMode |
2019 #choice: #colorMapMode |
1995 #choiceValue: '2-plane + mask' |
2020 #choiceValue: #masked2 |
1996 ) |
2021 ) |
1997 #(#MenuItem |
2022 #(#MenuItem |
1998 #activeHelpKey: #colorMap1M |
2023 #activeHelpKey: #colorMap1M |
1999 #label: '1-Plane + Mask' |
2024 #label: '1-Plane + Mask' |
2000 #itemValue: #colorMapMode: |
2025 #itemValue: #colorMapMode: |
2001 #translateLabel: true |
2026 #translateLabel: true |
2002 #argument: '1-plane + mask' |
2027 #argument: #masked1 |
2003 #choice: #colorMapMode |
2028 #choice: #colorMapMode |
2004 #choiceValue: '1-plane + mask' |
2029 #choiceValue: #masked1 |
2005 ) |
2030 ) |
2006 ) |
2031 ) |
2007 nil |
2032 nil |
2008 nil |
2033 nil |
2009 ) |
2034 ) |
2810 !ImageEditor methodsFor:'change & update'! |
2835 !ImageEditor methodsFor:'change & update'! |
2811 |
2836 |
2812 findColorMapMode |
2837 findColorMapMode |
2813 "finds the colorMapMode for a new image" |
2838 "finds the colorMapMode for a new image" |
2814 |
2839 |
2815 |image listOfColors| |
2840 |image listOfColors colorMapModeKey| |
2816 |
2841 |
2817 image := self image. |
2842 image := self image. |
2818 image depth > 8 ifTrue: [ |
2843 |
2819 colorMapMode value: ''. |
2844 image mask notNil ifTrue: [ |
2820 self listOfColors removeAll. |
2845 colorMapModeKey := 'masked' , image depth printString. |
2821 ^ nil |
2846 ] ifFalse:[ |
2822 ]. |
2847 colorMapModeKey := 'depth' , image depth printString. |
2823 |
2848 ]. |
2824 colorMapMode value:(image depth printString, '-plane'). |
2849 |
2825 |
2850 colorMapMode value:colorMapModeKey. |
2826 (listOfColors := self listOfColors) isEmpty ifTrue:[ |
2851 |
2827 self colorMapMode: colorMapMode value. |
2852 image depth > 12 ifTrue:[ |
2828 listOfColors := self listOfColors. |
2853 self listOfColors removeAll. |
2829 image := self image. |
2854 listOfColors := image colorMap. |
|
2855 listOfColors isEmptyOrNil ifTrue:[ |
|
2856 listOfColors := Array with:Color black with:Color white. |
|
2857 ]. |
|
2858 ] ifFalse:[ |
|
2859 (listOfColors := self listOfColors) isEmpty ifTrue:[ |
|
2860 self colorMapMode: colorMapMode value. |
|
2861 listOfColors := self listOfColors. |
|
2862 image := self image. |
|
2863 ]. |
2830 ]. |
2864 ]. |
2831 imageEditView drawingColors:(Array |
2865 imageEditView drawingColors:(Array |
2832 with: (listOfColors at:1) |
2866 with: (listOfColors at:1) |
2833 with: (listOfColors at:2 ifAbsent:[listOfColors at:1])). |
2867 with: (listOfColors at:2 ifAbsent:[listOfColors at:1])). |
2834 |
2868 |
2835 image mask notNil ifTrue: [ |
2869 image mask notNil ifTrue: [ |
2836 colorMapMode value:(colorMapMode value, ' + mask'). |
|
2837 |
|
2838 (listOfColors detect: [:clr| clr = (Color colorId:0)] ifNone: nil) isNil |
2870 (listOfColors detect: [:clr| clr = (Color colorId:0)] ifNone: nil) isNil |
2839 ifTrue:[ |
2871 ifTrue:[ |
2840 listOfColors addFirst:(Color colorId:0). |
2872 listOfColors addFirst:(Color colorId:0). |
2841 imageEditView drawingColors: (Array |
2873 imageEditView drawingColors: (Array |
2842 with:(listOfColors at:2 ifAbsent:[listOfColors at:1]) |
2874 with:(listOfColors at:2 ifAbsent:[listOfColors at:1]) |
2891 ^ self. |
2923 ^ self. |
2892 ]. |
2924 ]. |
2893 |
2925 |
2894 changedObject == imageEditView ifTrue:[ |
2926 changedObject == imageEditView ifTrue:[ |
2895 something == #imageColors ifTrue:[ |
2927 something == #imageColors ifTrue:[ |
2896 self listOfColors contents:img colorMap. |
2928 self updateListOfColorsAndColormapMode. |
2897 self findColorMapMode. |
|
2898 ^ self. |
2929 ^ self. |
2899 ]. |
2930 ]. |
2900 something == #image ifTrue:[ |
2931 something == #image ifTrue:[ |
2901 self imagePreView image:img. |
2932 self imagePreView image:img. |
2902 self listOfColors contents:img colorMap. |
2933 self updateListOfColorsAndColormapMode. |
2903 self findColorMapMode. |
|
2904 self tileModeHolder value ifTrue:[ |
2934 self tileModeHolder value ifTrue:[ |
2905 self imagePreView tileMode:true tileOffset:(img extent). |
2935 self imagePreView tileMode:true tileOffset:(img extent). |
2906 ]. |
2936 ]. |
2907 ^ self. |
2937 ^ self. |
2908 ]. |
2938 ]. |
2968 self image fileName notNil |
2998 self image fileName notNil |
2969 ifTrue: [self addToHistory: self image fileName -> #loadFromFile:]. |
2999 ifTrue: [self addToHistory: self image fileName -> #loadFromFile:]. |
2970 |
3000 |
2971 |
3001 |
2972 |
3002 |
|
3003 ! |
|
3004 |
|
3005 updateListOfColorsAndColormapMode |
|
3006 |colorMap image| |
|
3007 |
|
3008 image := self image. |
|
3009 colorMap := image colorMap. |
|
3010 colorMap size <= 4096 ifTrue:[ |
|
3011 self listOfColors contents:colorMap. |
|
3012 ] ifFalse:[ |
|
3013 self listOfColors removeAll. |
|
3014 colorMap isFixedPalette ifTrue:[ |
|
3015 image colorMap:nil. |
|
3016 image photometric:#rgb. |
|
3017 image samplesPerPixel:3. |
|
3018 |
|
3019 image bitsPerSample:(Array |
|
3020 with:(colorMap bitsRed) |
|
3021 with:(colorMap bitsGreen) |
|
3022 with:(colorMap bitsBlue)). |
|
3023 ]. |
|
3024 ]. |
|
3025 self findColorMapMode. |
2973 ! ! |
3026 ! ! |
2974 |
3027 |
2975 !ImageEditor methodsFor:'data access'! |
3028 !ImageEditor methodsFor:'data access'! |
2976 |
3029 |
2977 atColor:aOldColor put:aNewColor |
3030 atColor:aOldColor put:aNewColor |
3407 or:[cMap size == (1 bitShift:depth)]) ifTrue:[ |
3460 or:[cMap size == (1 bitShift:depth)]) ifTrue:[ |
3408 depth >= 8 ifTrue:[ |
3461 depth >= 8 ifTrue:[ |
3409 self warn:'No space for more colors in colormap.'. |
3462 self warn:'No space for more colors in colormap.'. |
3410 ^ self |
3463 ^ self |
3411 ]. |
3464 ]. |
3412 (self confirm:'No space for more colors in colormap.\Change depth first.' withCRs) |
3465 (self confirm:'No space for more colors in colormap.\Change depth ?' withCRs) |
3413 ifFalse:[ |
3466 ifFalse:[ |
3414 ^ self |
3467 ^ self |
3415 ]. |
3468 ]. |
3416 |
3469 |
3417 imageEditView makeUndo. |
3470 imageEditView makeUndo. |
3418 newMode := (depth*2) printString , (colorMapMode value copyFrom:2). |
3471 img mask notNil ifTrue:[ |
|
3472 newMode := 'masked' , (depth*2) printString. |
|
3473 ] ifFalse:[ |
|
3474 newMode := 'depth' , (depth*2) printString. |
|
3475 ]. |
3419 self colorMapMode:newMode. |
3476 self colorMapMode:newMode. |
3420 ] ifFalse:[ |
3477 ] ifFalse:[ |
3421 imageEditView makeUndo. |
3478 imageEditView makeUndo. |
3422 ]. |
3479 ]. |
3423 |
3480 |
3424 cMap := cMap asArray. |
3481 cMap := cMap asArray. |
3425 listOfColors := self listOfColors. |
3482 listOfColors := self listOfColors. |
3426 oldCListSize := listOfColors size. |
3483 oldCListSize := listOfColors size. |
3427 |
|
3428 "/ (colorMapMode value asString endsWith:'mask') ifTrue:[ |
|
3429 "/ cMap last = Color noColor ifTrue:[ |
|
3430 "/ cMap := cMap copyWithoutLast:1 |
|
3431 "/ ] ifFalse:[ |
|
3432 "/ cMap first = Color noColor ifTrue:[ |
|
3433 "/ cMap := cMap copyFrom:2 |
|
3434 "/ ] |
|
3435 "/ ]. |
|
3436 "/ ]. |
|
3437 "/ |
|
3438 |
3484 |
3439 newColorMap := cMap copyWith:newColor. |
3485 newColorMap := cMap copyWith:newColor. |
3440 |
3486 |
3441 newImage := img species new |
3487 newImage := img species new |
3442 width:img width |
3488 width:img width |
4013 self warn:'Image has no colormap\change colorMap mode first.' withCRs. |
4070 self warn:'Image has no colormap\change colorMap mode first.' withCRs. |
4014 ^ self |
4071 ^ self |
4015 ]. |
4072 ]. |
4016 imageEditView makeUndo. |
4073 imageEditView makeUndo. |
4017 |
4074 |
4018 cMap := cMap asArray. |
4075 modifiedColormap := cMap asArray copy. |
4019 clr := cMap at:selectedColorIndex. |
4076 clr := modifiedColormap at:selectedColorIndex. |
4020 cMap at:selectedColorIndex put:(aBlock value:clr). |
4077 modifiedColormap at:selectedColorIndex put:(aBlock value:clr). |
4021 |
4078 |
4022 newImage := img species new |
4079 newImage := img species new |
4023 width:img width |
4080 width:img width |
4024 height:img height |
4081 height:img height |
4025 depth:img depth |
4082 depth:img depth |
4026 fromArray:img bits. |
4083 fromArray:img bits. |
4027 |
4084 |
4028 newImage colorMap:cMap. |
4085 newImage colorMap:modifiedColormap. |
4029 newImage fileName:img fileName. |
4086 newImage fileName:img fileName. |
4030 newImage mask:(img mask copy). |
4087 newImage mask:(img mask copy). |
4031 |
4088 |
4032 oldSelection := self selectionOfColor value. |
4089 oldSelection := self selectionOfColor value. |
4033 |
4090 |
4591 ! |
4651 ! |
4592 |
4652 |
4593 doNewImage |
4653 doNewImage |
4594 "opens a dialog with choices of size and color map for creating a new image" |
4654 "opens a dialog with choices of size and color map for creating a new image" |
4595 |
4655 |
4596 |aspects width height cMapString cMap imageClass image szString| |
4656 |aspects width height cMapString cMapMode cMap imageClass image szString defaultSize| |
|
4657 |
|
4658 defaultSize := (self class listOfDefaultSizes includes:'32x32') |
|
4659 ifTrue:['32x32'] |
|
4660 ifFalse:[self class listOfDefaultSizes first]. |
4597 |
4661 |
4598 aspects := IdentityDictionary new |
4662 aspects := IdentityDictionary new |
4599 at:#listOfSizes put: self class listOfDefaultSizes asValue; |
4663 at:#listOfSizes put: self class listOfDefaultSizes asValue; |
4600 at:#listOfColorMaps put: self class listOfColorMaps keys asSortedCollection asValue; |
4664 at:#listOfColorMaps put: self class namesOfColorMaps values asSortedCollection asValue; |
4601 at:#selectionOfSize put: (LastSizeString ? self class listOfDefaultSizes first copy) asValue; |
4665 at:#selectionOfSize put: (LastSizeString ? defaultSize) asValue; |
4602 at:#selectionOfColorMap put: (LastColormapMode ? self class listOfColorMaps keys asSortedCollection first) asValue; |
4666 at:#selectionOfColorMap put: (LastColormapMode ? self class namesOfColorMaps values asSortedCollection first) asValue; |
4603 yourself. |
4667 yourself. |
4604 |
4668 |
4605 (self openDialogInterface:#dialogSpecForNewImage withBindings:aspects) |
4669 (self openDialogInterface:#dialogSpecForNewImage withBindings:aspects) |
4606 ifTrue:[ |
4670 ifTrue:[ |
4607 szString := (aspects at:#selectionOfSize) value. |
4671 szString := (aspects at:#selectionOfSize) value. |
4608 width := 128 min: (Integer readFromString: (szString upTo: $x) onError:[24]). |
4672 width := 128 min: (Integer readFromString: (szString upTo: $x) onError:[24]). |
4609 height := 128 min: (Integer readFromString: (szString copy reverse upTo: $x) reverse onError:[24]). |
4673 height := 128 min: (Integer readFromString: (szString copy reverse upTo: $x) reverse onError:[24]). |
4610 |
4674 |
4611 cMapString := (aspects at:#selectionOfColorMap) value. |
4675 cMapString := (aspects at:#selectionOfColorMap) value. |
4612 cMap := (self class listOfColorMaps at: (colorMapMode value: (aspects at:#selectionOfColorMap) value) value). |
4676 cMapMode := self class namesOfColorMaps keyAtEqualValue:cMapString. |
4613 imageClass := Image implementorForDepth: ((cMap size log: 2) asInteger). |
4677 cMap := self class listOfColorMaps at:cMapMode. |
4614 image := imageClass width: width height: height fromArray: (ByteArray new: width*height). |
4678 imageClass := Image implementorForDepth:(cMap size highBit-1). |
|
4679 image := imageClass width: width height: height. |
|
4680 image bits:(ByteArray new:(image bytesPerRow*height)). |
4615 |
4681 |
4616 LastSizeString := szString. |
4682 LastSizeString := szString. |
4617 LastColormapMode := cMapString. |
4683 LastColormapMode := cMapString. |
4618 |
4684 |
4619 (colorMapMode value endsWith: 'mask') |
4685 (cMapMode startsWith: 'mask') ifTrue:[ |
4620 ifTrue: |
|
4621 [ |
|
4622 image mask: (Depth1Image width: width height: height depth: 1 fromArray: (ByteArray new: width*height)) clearMaskedPixels |
4686 image mask: (Depth1Image width: width height: height depth: 1 fromArray: (ByteArray new: width*height)) clearMaskedPixels |
4623 ]. |
4687 ]. |
4624 image colorMap: cMap. |
4688 image colorMap: cMap. |
|
4689 (imageEditView image: image) notNil ifTrue:[ |
|
4690 self updateListOfColorsAndColormapMode. |
|
4691 self updateLabelsAndHistory. |
|
4692 ]. |
4625 image fillRectangleX:0 y:0 width:width height:height with:Color white. |
4693 image fillRectangleX:0 y:0 width:width height:height with:Color white. |
4626 (imageEditView image: image) notNil |
|
4627 ifTrue: |
|
4628 [ |
|
4629 self listOfColors contents: cMap. |
|
4630 self findColorMapMode. |
|
4631 self updateLabelsAndHistory. |
|
4632 ] |
|
4633 ] |
4694 ] |
4634 ! |
4695 ! |
4635 |
4696 |
4636 doNewImageFromClipboard |
4697 doNewImageFromClipboard |
4637 |image| |
4698 |image| |