--- a/ImageEditor.st Fri Aug 05 16:44:27 2005 +0200
+++ b/ImageEditor.st Fri Aug 05 18:37:40 2005 +0200
@@ -2972,17 +2972,7 @@
image colorMap isEmptyOrNil ifTrue:[
someOrAllUsedColors := image usedColorsMax:10000.
someOrAllUsedColors := someOrAllUsedColors asArray.
- someOrAllUsedColors sort:[:a :b |
- a redByte == b redByte ifTrue:[
- a greenByte == b greenByte ifTrue:[
- a blueByte < b blueByte
- ] ifFalse:[
- a greenByte < b greenByte
- ]
- ] ifFalse:[
- a redByte < b redByte
- ]
- ].
+ someOrAllUsedColors sort:self sortBlockForColors.
listOfColors addAll:someOrAllUsedColors.
"/ listOfColors add:Color black; add:Color white.
] ifFalse:[
@@ -3465,6 +3455,20 @@
!ImageEditor methodsFor:'private'!
+sortBlockForColors
+ ^ [:a :b |
+ a redByte == b redByte ifTrue:[
+ a greenByte == b greenByte ifTrue:[
+ a blueByte < b blueByte
+ ] ifFalse:[
+ a greenByte < b greenByte
+ ]
+ ] ifFalse:[
+ a redByte < b redByte
+ ]
+ ]
+!
+
updateImage
|img|
@@ -4057,17 +4061,7 @@
"/ translation table
oldToNew := ByteArray new:(1 bitShift:depth).
newColorMap := usedColors asArray.
- newColorMap sort:[:a :b |
- a redByte == b redByte ifTrue:[
- a greenByte == b greenByte ifTrue:[
- a blueByte < b blueByte
- ] ifFalse:[
- a greenByte < b greenByte
- ]
- ] ifFalse:[
- a redByte < b redByte
- ]
- ].
+ newColorMap sort:self sortBlockForColors.
oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr |
|newPixel|
@@ -4361,21 +4355,16 @@
s := Dialog request:'Rounding Interval red (2..) ?' initialAnswer:4.
s size == 0 ifTrue:[^ self].
rndR := Integer readFrom:s onError:0.
- (rndR > 1) ifFalse:[
- Dialog warn:'Image unchanged'.
- ^ self
- ].
+
s := Dialog request:'Rounding Interval green (2..) ?' initialAnswer:2.
s size == 0 ifTrue:[^ self].
rndG := Integer readFrom:s onError:0.
- (rndG > 1) ifFalse:[
- Dialog warn:'Image unchanged'.
- ^ self
- ].
+
s := Dialog request:'Rounding Interval blue (2..) ?' initialAnswer:10.
s size == 0 ifTrue:[^ self].
rndB := Integer readFrom:s onError:0.
- (rndB > 1) ifFalse:[
+
+ ((rndR > 1) or:[(rndG > 1) or:[(rndB > 1)]]) ifFalse:[
Dialog warn:'Image unchanged'.
^ self
].
@@ -4452,6 +4441,13 @@
sortColorMap
"calculates a new color map for the image, sorting colors"
+ self
+ sortColorMapWith:self sortBlockForColors
+!
+
+sortColorMapWith:sortBlock
+ "calculates a new color map for the image, sorting colors"
+
|depth newColorMap newImage oldImage usedColors oldToNew oldBits newBits tmpBits|
oldImage := self image.
@@ -4472,17 +4468,7 @@
"/ translation table
oldToNew := ByteArray new:(1 bitShift:depth).
newColorMap := usedColors asArray.
- newColorMap sort:[:a :b |
- a redByte == b redByte ifTrue:[
- a greenByte == b greenByte ifTrue:[
- a blueByte < b blueByte
- ] ifFalse:[
- a greenByte < b greenByte
- ]
- ] ifFalse:[
- a redByte < b redByte
- ]
- ].
+ newColorMap sort:sortBlock.
oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr |
|newPixel|