--- a/ImageEditor.st Thu Apr 14 11:24:30 2005 +0200
+++ b/ImageEditor.st Mon May 02 12:13:10 2005 +0200
@@ -2886,7 +2886,7 @@
findColorMapMode
"finds the colorMapMode for a new image"
- |image listOfColors colorMapModeKey|
+ |image listOfColors colorMapModeKey drawColor1 drawColor2|
image := self image.
@@ -2898,35 +2898,38 @@
colorMapModeKey := colorMapModeKey , image depth printString.
colorMapMode setValue:colorMapModeKey.
+ listOfColors := self listOfColors.
image depth > 12 ifTrue:[
- self listOfColors removeAll.
- listOfColors := image colorMap.
- listOfColors isEmptyOrNil ifTrue:[
- listOfColors := Array with:Color black with:Color white.
+ listOfColors removeAll.
+ image colorMap isEmptyOrNil ifTrue:[
+ listOfColors add:Color black; add:Color white.
+ ] ifFalse:[
+ listOfColors addAll:(image colorMap).
].
] ifFalse:[
- (listOfColors := self listOfColors) isEmpty ifTrue:[
+self halt.
+ listOfColors isEmpty ifTrue:[
self colorMapMode: colorMapMode value.
- listOfColors := self listOfColors.
image := self image.
].
].
- imageEditView drawingColors:(Array
- with: (listOfColors at:1)
- with: (listOfColors at:2 ifAbsent:[listOfColors at:1])).
+ drawColor1 := listOfColors at:1.
+ drawColor2 := listOfColors at:2 ifAbsent:drawColor1.
self hasMask ifTrue: [
(listOfColors contains: [:clr| clr = (Color colorId:0)])
ifFalse:[
listOfColors addFirst:(Color colorId:0).
- imageEditView drawingColors: (Array
- with: (listOfColors at:2)
- with: (listOfColors at:3 ifAbsent:[listOfColors at:2])).
+ drawColor1 := listOfColors at:2.
+ drawColor2 := listOfColors at:3 ifAbsent:drawColor1.
]
].
+
+ imageEditView drawingColors:(Array with: drawColor1 with: drawColor2).
+
self selectionOfColor
setValue: 0;
- value: (self listOfColors indexOf: imageEditView selectedColor).
+ value: (listOfColors indexOf: imageEditView selectedColor).
!
update:something with:aParameter from:changedObject
@@ -3029,12 +3032,11 @@
updateColorsFromImage:image
|colors|
- image colorMap notNil ifTrue:[
- colors := image colorMap asOrderedCollection.
- ] ifFalse:[
- colors := image usedColors asSet asOrderedCollection.
+ colors := image colorMap.
+ colors isNil ifTrue:[
+ colors := image usedColors asSet.
].
- self listOfColors contents:colors.
+ self listOfColors contents:(colors asOrderedCollection).
!
updateForNoImage
@@ -3280,6 +3282,7 @@
(img := self image) notNil ifTrue:[
img := img onDevice:device.
self updateColorsFromImage:img.
+ self findColorMapMode.
self updateLabelsAndHistory.
] ifFalse:[
self updateForNoImage
@@ -4219,6 +4222,7 @@
clrIndex := self selectionOfColor value.
self hasMask "img mask notNil" ifTrue: [
clrIndex == 1 ifTrue:[^ nil].
+ clrIndex == 0 ifTrue:[^ nil].
^ clrIndex - 1
].
^ clrIndex