colorMap fixes
authorpenk
Fri, 19 Nov 2004 13:33:50 +0100
changeset 1896 ab2b45d8ccc8
parent 1895 b7d6683ebaca
child 1897 9e6538dcba4b
colorMap fixes
ImageEditor.st
--- a/ImageEditor.st	Thu Nov 11 10:12:57 2004 +0100
+++ b/ImageEditor.st	Fri Nov 19 13:33:50 2004 +0100
@@ -1818,6 +1818,11 @@
                   translateLabel: true
                 )
                (MenuItem
+                  label: 'Inspect Image'
+                  itemValue: doInspectImage
+                  translateLabel: true
+                )
+               (MenuItem
                   label: '-'
                 )
                (MenuItem
@@ -2824,14 +2829,15 @@
 !
 
 listOfColors
-    "returns the list of colors in a List"
-
-    |holder|
-    (holder := builder bindingAt:#listOfColors) isNil ifTrue:[
-        builder aspectAt:#listOfColors put:(holder :=  List new).
-        holder addDependent:self.
+    "returns the list of colors"
+
+    |list|
+
+    (list := builder bindingAt:#listOfColors) isNil ifTrue:[
+        builder aspectAt:#listOfColors put:(list :=  List new).
+        list addDependent:self.
     ].
-    ^ holder
+    ^ list
 !
 
 previewBackgroundColor
@@ -2886,12 +2892,12 @@
     image := self image.
 
     image mask notNil ifTrue: [             
-        colorMapModeKey := 'masked' , image depth printString.
+        colorMapModeKey := 'masked'.
     ] ifFalse:[
-        colorMapModeKey := 'depth' , image depth printString.
+        colorMapModeKey := 'depth'.
     ].
-
-    colorMapMode value:colorMapModeKey.
+    colorMapModeKey := colorMapModeKey , image depth printString.
+    colorMapMode setValue:colorMapModeKey.
 
     image depth > 12 ifTrue:[
         self listOfColors removeAll.
@@ -2910,13 +2916,13 @@
                                     with: (listOfColors at:1) 
                                     with: (listOfColors at:2 ifAbsent:[listOfColors at:1])).
 
-    image mask notNil ifTrue: [             
-        (listOfColors detect: [:clr| clr = (Color colorId:0)] ifNone: nil) isNil
-        ifTrue:[
+    self hasMask "image mask" notNil ifTrue: [             
+        (listOfColors contains: [:clr| clr = (Color colorId:0)]) 
+        ifFalse:[
             listOfColors addFirst:(Color colorId:0).
             imageEditView drawingColors: (Array 
-                                            with:(listOfColors at:2 ifAbsent:[listOfColors at:1]) 
-                                            with:(listOfColors at:1)).
+                                            with: (listOfColors at:2) 
+                                            with: (listOfColors at:3 ifAbsent:[listOfColors at:2])).
         ]
     ].
     self selectionOfColor 
@@ -2951,6 +2957,7 @@
         something == #at: ifTrue:[
             "/ colormap entry changed at aParameter
 
+self halt.
             clrIndex := aParameter.
             (self hasMask) ifTrue:[
                 clrIndex := clrIndex - 1.
@@ -2960,6 +2967,7 @@
             self colorMapChanged.
             ^ self
         ].
+        ^ self
     ].
 
     changedObject == imageEditView undoImages ifTrue:[
@@ -3270,8 +3278,10 @@
     (imageEditView loadFromMessage: aMessage) notNil ifTrue:[
         (img := self image) notNil ifTrue:[
             img := img onDevice:device.
-            self listOfColors contents:(img usedColors asSet asOrderedCollection).
-            self findColorMapMode.
+            img colorMap isNil ifTrue:[
+                self listOfColors contents:(img usedColors asSet asOrderedCollection).
+            ].
+"/            self findColorMapMode.
             self updateLabelsAndHistory.
             "/ imageEditView image:img.
         ] ifFalse:[
@@ -4012,7 +4022,6 @@
     |image|
 
     (image := imageEditView image) notNil ifTrue:[
-        self listOfColors contents:(image colorMap).
         self findColorMapMode.
         self updateLabelsAndHistory.
     ]
@@ -4221,18 +4230,18 @@
         ^ nil
     ].
     clrIndex := self selectionOfColor value.
-    img mask notNil ifTrue: [ 
+    self hasMask "img mask notNil" ifTrue: [ 
         clrIndex == 1 ifTrue:[^ nil].
-        clrIndex := clrIndex - 1 
+        ^ clrIndex - 1 
     ].
     ^ clrIndex
 !
 
 selectedColorOrNil
-    |img cMap|
-
-    selectedColorIndex := self selectedColorIndexOrNil.
-    selectedColorIndex isNil ifTrue:[^ self].
+    |cmapIndex img cMap|
+
+    cmapIndex := self selectedColorIndexOrNil.
+    cmapIndex isNil ifTrue:[^ self].
 
     img := self image.
     cMap := img colorMap.
@@ -4240,8 +4249,7 @@
         self warn:('Image has no colormap.\Please change the colorMap mode first.' withCRs).
         ^ self
     ].
-
-    ^ cMap at:selectedColorIndex.
+    ^ cMap at:cmapIndex.
 !
 
 sortColorMap
@@ -4497,6 +4505,12 @@
     imageEditView flipVertical
 !
 
+doInspectImage
+    "opens a System Browser on the resourceClass and the resourceSelector"
+
+    self image inspect
+!
+
 doMagnifyDown
     "magnifies current image one step down"