--- a/ImageEditor.st Tue Dec 16 16:42:47 2008 +0100
+++ b/ImageEditor.st Tue Dec 16 19:44:42 2008 +0100
@@ -3176,7 +3176,7 @@
findColorMapMode
"finds the colorMapMode for a new image"
- |image listOfColors colorMapModeKey drawColor1 drawColor2 someOrAllUsedColors|
+ |image newListOfColors colorMapModeKey drawColor1 drawColor2 someOrAllUsedColors|
image := self image.
image isNil ifTrue:[^ self ].
@@ -3189,46 +3189,45 @@
colorMapModeKey := colorMapModeKey , image depth printString.
self colorMapMode setValue:colorMapModeKey.
- listOfColors := self listOfColors.
+ newListOfColors := OrderedCollection withAll:(self listOfColors).
image depth > 12 ifTrue:[
- listOfColors removeAll.
+ newListOfColors removeAll.
image colorMap isEmptyOrNil ifTrue:[
someOrAllUsedColors := image usedColorsMax:10000.
someOrAllUsedColors notNil ifTrue:[
someOrAllUsedColors := someOrAllUsedColors asArray.
someOrAllUsedColors sort:self sortBlockForColors.
- listOfColors addAll:someOrAllUsedColors.
+ newListOfColors addAll:someOrAllUsedColors.
"/ listOfColors add:Color black; add:Color white.
]
] ifFalse:[
- listOfColors addAll:(image colorMap).
+ newListOfColors addAll:(image colorMap).
].
] ifFalse:[
- listOfColors isEmpty ifTrue:[
+ newListOfColors isEmpty ifTrue:[
self colorMapMode: colorMapMode value.
image := self image.
].
].
- listOfColors notEmptyOrNil ifTrue:[
- drawColor1 := listOfColors at:1.
- drawColor2 := listOfColors at:2 ifAbsent:drawColor1.
+ newListOfColors notEmptyOrNil ifTrue:[
+ drawColor1 := newListOfColors at:1.
+ drawColor2 := newListOfColors at:2 ifAbsent:drawColor1.
self hasMask ifTrue: [
- (listOfColors contains: [:clr| clr = (Color colorId:0)])
+ (newListOfColors contains: [:clr| clr = (Color colorId:0)])
ifFalse:[
- listOfColors addFirst:(Color colorId:0).
- drawColor1 := listOfColors at:2.
- drawColor2 := listOfColors at:3 ifAbsent:drawColor1.
+ newListOfColors addFirst:(Color colorId:0).
+ drawColor1 := newListOfColors at:2.
+ drawColor2 := newListOfColors at:3 ifAbsent:drawColor1.
]
].
-
- imageEditView drawingColors:(Array with: drawColor1 with: drawColor2).
-
- self selectionOfColor
- setValue: 0;
- value: (listOfColors indexOf: imageEditView selectedColor).
+"/ imageEditView drawingColors:(Array with: drawColor1 with: drawColor2).
+"/ self selectionOfColor
+"/ setValue: 0;
+"/ value: (listOfColors indexOf: imageEditView selectedColor).
].
+ self listOfColors contents:newListOfColors.
"Modified: / 07-07-2006 / 12:27:43 / cg"
!
@@ -3387,7 +3386,9 @@
!
updateListOfColorsAndColormapMode
- |colorMap image|
+ |selectedColor colorMap image|
+
+ selectedColor := self selectedColorOrNil.
image := self image.
image isNil ifTrue:[
@@ -3395,6 +3396,9 @@
] ifFalse:[
colorMap := image colorMap.
colorMap size <= 4096 ifTrue:[
+ image mask notNil ifTrue:[
+ colorMap := (Array with:(Color noColor)),colorMap.
+ ].
self listOfColors contents:colorMap.
] ifFalse:[
self listOfColors removeAll.
@@ -3411,6 +3415,9 @@
].
].
self findColorMapMode.
+ selectedColor notNil ifTrue:[
+ self selectColor:selectedColor.
+ ].
! !
!ImageEditor methodsFor:'data access'!
@@ -4938,6 +4945,30 @@
"Modified: / 07-07-2006 / 13:10:42 / cg"
!
+selectColor:aColor
+ |idx img cMap|
+
+ aColor isNil ifTrue:[
+ idx := nil.
+ ] ifFalse:[
+ aColor == Color noColor ifTrue:[
+ img mask notNil ifTrue:[
+ idx := 1.
+ ]
+ ] ifFalse:[
+ (img := self image) notNil ifTrue:[
+ (cMap := img colorMap) notNil ifTrue:[
+ idx := cMap indexOf:aColor ifAbsent:nil.
+ img mask notNil ifTrue:[
+ idx := idx + 1.
+ ].
+ ]
+ ].
+ ].
+ ].
+ self selectionOfColor value:idx.
+!
+
selectedColorIndexOrNil
| img clrIndex|