sort colors when compressing the colorMap
authorClaus Gittinger <cg@exept.de>
Tue, 15 Sep 1998 18:39:38 +0200
changeset 996 9423ae277168
parent 995 245dcca31eec
child 997 2a8a32256d4a
sort colors when compressing the colorMap
ImageEditor.st
--- a/ImageEditor.st	Mon Sep 14 20:00:14 1998 +0200
+++ b/ImageEditor.st	Tue Sep 15 18:39:38 1998 +0200
@@ -2072,11 +2072,23 @@
     self information:('Compress colorMap: %1 colors used.' bindWith:usedColors size).
 
     self withExecuteCursorDo:[
-        newColorMap := Array new:usedColors size.
+"/        newColorMap := Array new:usedColors size.
 
         "/ 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 
+                                ]
+                          ].
+
         oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr |
             |newPixel|
 
@@ -2131,7 +2143,7 @@
     ]
 
     "Created: / 28.7.1998 / 20:03:11 / cg"
-    "Modified: / 31.7.1998 / 01:13:57 / cg"
+    "Modified: / 15.9.1998 / 17:53:32 / cg"
 ! !
 
 !ImageEditor methodsFor:'user actions - editing'!