--- a/ImageEditor.st Fri Aug 05 12:44:04 2005 +0200
+++ b/ImageEditor.st Fri Aug 05 15:29:41 2005 +0200
@@ -2003,6 +2003,24 @@
(Menu
(
(MenuItem
+ activeHelpKey: colorMap24
+ label: '24-Plane'
+ itemValue: colorMapMode:
+ translateLabel: true
+ argument: depth24
+ choice: colorMapMode
+ choiceValue: depth24
+ )
+ (MenuItem
+ activeHelpKey: colorMap16
+ label: '16-Plane'
+ itemValue: colorMapMode:
+ translateLabel: true
+ argument: depth16
+ choice: colorMapMode
+ choiceValue: depth16
+ )
+ (MenuItem
activeHelpKey: colorMap8
label: '8-Plane'
itemValue: colorMapMode:
@@ -2042,6 +2060,24 @@
label: '-'
)
(MenuItem
+ activeHelpKey: colorMap24M
+ label: '24-Plane + Mask'
+ itemValue: colorMapMode:
+ translateLabel: true
+ argument: masked24
+ choice: colorMapMode
+ choiceValue: masked24
+ )
+ (MenuItem
+ activeHelpKey: colorMap16M
+ label: '16-Plane + Mask'
+ itemValue: colorMapMode:
+ translateLabel: true
+ argument: masked16
+ choice: colorMapMode
+ choiceValue: masked16
+ )
+ (MenuItem
activeHelpKey: colorMap8M
label: '8-Plane + Mask'
itemValue: colorMapMode:
@@ -2102,7 +2138,12 @@
translateLabel: true
)
(MenuItem
- label: 'Reduce Number of Colors...'
+ label: 'Reduce Number of Colors by Rounding...'
+ itemValue: reduceNumberOfColors2
+ translateLabel: true
+ )
+ (MenuItem
+ label: 'Reduce Number of Colors by Masking Bits...'
itemValue: reduceNumberOfColors
translateLabel: true
)
@@ -4271,6 +4312,7 @@
s := Dialog request:'Number of color bits to strip (1-7) ?'.
s size == 0 ifTrue:[^ self].
+
n := Integer readFrom:s onError:0.
(n between:1 and:7) ifFalse:[
Dialog warn:'Image unchanged'.
@@ -4297,35 +4339,51 @@
!
reduceNumberOfColors2
- |s n anyChange img usedColors|
-
- s := Dialog request:'Similarity Delta (1..) ?' initialAnswer:2.
- s size == 0 ifTrue:[
- self reduceNumberOfColors2.
- ^ self
- ].
- n := Integer readFrom:s onError:0.
- (n >= 1) ifFalse:[
+ |s rnd usedColors image newImage|
+
+ s := Dialog request:'Rounding Interval (2..) ?' initialAnswer:2.
+ s size == 0 ifTrue:[^ self].
+
+ rnd := Integer readFrom:s onError:0.
+ (rnd > 1) ifFalse:[
Dialog warn:'Image unchanged'.
^ self
].
self withExecuteCursorDo:[
-"/ anyChange := imageEditView reduceColorResolutionBy:n.
-"/ anyChange ifFalse:[
-"/ Dialog warn:'Image unchanged'.
-"/ ] ifTrue:[
-"/ img := imageEditView image.
-"/ imageEditView image:img.
-"/
-"/ self fetchImageData.
-"/ usedColors := img usedColorsMax:10000.
-"/ usedColors size == 10000 ifTrue:[
-"/ Dialog information:('>= ' , usedColors size printString , ' colors used.')
-"/ ] ifFalse:[
-"/ Dialog information:(usedColors size printString , ' colors used.')
-"/ ]
-"/ ]
+ image := self image.
+ usedColors := image usedColors.
+ imageEditView makeUndo.
+
+ newImage := image copy.
+ image
+ colorsFromX:0 y:0 toX:(image width-1) y:(image height-1)
+ do:[:x :y :clr |
+ |r g b nr ng nb newClr|
+
+ r := clr redByte.
+ g := clr greenByte.
+ b := clr blueByte.
+ nr := (r roundTo:rnd) min:255.
+ ng := (g roundTo:rnd) min:255.
+ nb := (b roundTo:rnd) min:255.
+
+ newClr := Color redByte:nr greenByte:ng blueByte:nb.
+ newImage colorAtX:x y:y put:newClr
+ ].
+
+ imageEditView image:newImage.
+ imageEditView setModified.
+ self updateImage.
+ self updateImagePreView.
+
+ self fetchImageData.
+ usedColors := newImage usedColorsMax:10000.
+ usedColors size == 10000 ifTrue:[
+ Dialog information:('>= ' , usedColors size printString , ' colors used.')
+ ] ifFalse:[
+ Dialog information:(usedColors size printString , ' colors used.')
+ ]
].
!