some changes to support drawing into 24-bit images
authorClaus Gittinger <cg@exept.de>
Sat, 02 Nov 2002 19:47:43 +0100
changeset 1643 91b7ea254a3b
parent 1642 8119edd52cf8
child 1644 df1f5a97b8e9
some changes to support drawing into 24-bit images
ImageEditor.st
--- a/ImageEditor.st	Thu Oct 31 17:32:36 2002 +0100
+++ b/ImageEditor.st	Sat Nov 02 19:47:43 2002 +0100
@@ -14,7 +14,7 @@
 
 ToolApplicationModel subclass:#ImageEditor
 	instanceVariableNames:'imageEditView colorMapMode editMode mouseKeyColorMode
-		selectedColorIndex postOpenAction imageSeqNr'
+		selectedColorIndex postOpenAction imageSeqNr drawingColormap'
 	classVariableNames:'LastDirectory LastSizeString MaskClipboard LastColormapMode
 		DefaultRelativeSizes'
 	poolDictionaries:''
@@ -2498,7 +2498,7 @@
                 clrIndex := clrIndex - 1.
             ].
 
-            img colorMap at:clrIndex put:(changedObject at:aParameter).
+            (img colorMap ? drawingColormap) at:clrIndex put:(changedObject at:aParameter).
             self colorMapChanged.
             ^ self
         ].
@@ -2989,7 +2989,7 @@
 !ImageEditor methodsFor:'user actions - colormap'!
 
 addColorToColormap
-    |depth img cMap newColorMap newImage oldCListSize newMode|
+    |depth img cMap newColorMap newImage oldCListSize newMode listOfColors|
 
     img := self image.
     img isNil ifTrue:[
@@ -3000,7 +3000,15 @@
     depth := img depth.
     cMap := img colorMap.
     cMap isNil ifTrue:[
-        self warn:'Image has no colormap.\Change colorMap mode first.' withCRs.
+        drawingColormap isNil ifTrue:[
+            self information:'Image has no colormap.\The shown colorMap is for drawing only.' withCRs.
+            drawingColormap := OrderedCollection new.
+        ].
+        drawingColormap add:(Color black).
+        self listOfColors contents:drawingColormap.
+        self selectionOfColor value:(drawingColormap size).
+
+        "/ self warn:'Image has no colormap.\Change colorMap mode first.' withCRs.
         ^ self
     ].
 
@@ -3023,7 +3031,8 @@
     ].
 
     cMap := cMap asArray.
-    oldCListSize := self listOfColors size.
+    listOfColors := self listOfColors.
+    oldCListSize := listOfColors size.
 
 "/    (colorMapMode value asString endsWith:'mask') ifTrue:[
 "/        cMap last = Color noColor ifTrue:[
@@ -3049,13 +3058,13 @@
     newImage mask:(img mask copy).
 
     (imageEditView image:newImage) notNil ifTrue:[
-        self listOfColors contents: newImage colorMap.
+        listOfColors contents: newImage colorMap.
         self findColorMapMode.
         "/ mhmh - somehow, we get two colors added ... (sigh findColorMapMode adds another one ...)
-        self listOfColors size > (oldCListSize + 1) ifTrue:[
-            self listOfColors removeLast
+        listOfColors size > (oldCListSize + 1) ifTrue:[
+            listOfColors removeLast
         ].
-        self selectionOfColor value:(self listOfColors size).
+        self selectionOfColor value:(listOfColors size).
         self updateLabelsAndHistory.
     ]