ImageEditor.st
changeset 996 9423ae277168
parent 990 4303f0064410
child 1008 327f93d57c7b
equal deleted inserted replaced
995:245dcca31eec 996:9423ae277168
  2070     imageEditView makeUndo.
  2070     imageEditView makeUndo.
  2071 
  2071 
  2072     self information:('Compress colorMap: %1 colors used.' bindWith:usedColors size).
  2072     self information:('Compress colorMap: %1 colors used.' bindWith:usedColors size).
  2073 
  2073 
  2074     self withExecuteCursorDo:[
  2074     self withExecuteCursorDo:[
  2075         newColorMap := Array new:usedColors size.
  2075 "/        newColorMap := Array new:usedColors size.
  2076 
  2076 
  2077         "/ translation table
  2077         "/ translation table
  2078         oldToNew := ByteArray new:(1 bitShift:depth).
  2078         oldToNew := ByteArray new:(1 bitShift:depth).
  2079         newColorMap := usedColors asArray.
  2079         newColorMap := usedColors asArray.
       
  2080         newColorMap sort:[:a :b |
       
  2081                                 a redByte == b redByte ifTrue:[
       
  2082                                     a greenByte == b greenByte ifTrue:[
       
  2083                                         a blueByte < b blueByte
       
  2084                                     ] ifFalse:[
       
  2085                                         a greenByte < b greenByte 
       
  2086                                     ]
       
  2087                                 ] ifFalse:[
       
  2088                                     a redByte < b redByte 
       
  2089                                 ]
       
  2090                           ].
       
  2091 
  2080         oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr |
  2092         oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr |
  2081             |newPixel|
  2093             |newPixel|
  2082 
  2094 
  2083             (usedColors includes:clr) ifTrue:[
  2095             (usedColors includes:clr) ifTrue:[
  2084                 newPixel := newColorMap indexOf:clr.
  2096                 newPixel := newColorMap indexOf:clr.
  2129             self updateLabelsAndHistory.
  2141             self updateLabelsAndHistory.
  2130         ]
  2142         ]
  2131     ]
  2143     ]
  2132 
  2144 
  2133     "Created: / 28.7.1998 / 20:03:11 / cg"
  2145     "Created: / 28.7.1998 / 20:03:11 / cg"
  2134     "Modified: / 31.7.1998 / 01:13:57 / cg"
  2146     "Modified: / 15.9.1998 / 17:53:32 / cg"
  2135 ! !
  2147 ! !
  2136 
  2148 
  2137 !ImageEditor methodsFor:'user actions - editing'!
  2149 !ImageEditor methodsFor:'user actions - editing'!
  2138 
  2150 
  2139 doBrowseClass
  2151 doBrowseClass