--- a/ImageEditor.st Sun Jun 24 18:42:06 2012 +0200
+++ b/ImageEditor.st Tue Jul 17 14:37:18 2012 +0200
@@ -5111,70 +5111,14 @@
compressColorMap
"calculates a new color map for the image, using only used colors"
- |depth newColorMap newImage oldImage usedColors oldToNew oldBits newBits tmpBits|
-
- oldImage := self image.
- depth := oldImage depth.
-
- usedColors := oldImage realUsedColors.
-
- "/ translation table
- oldToNew := ByteArray new:(1 bitShift:depth).
- newColorMap := usedColors asArray.
- newColorMap sort:self sortBlockForColors.
- oldImage colorMap notNil ifTrue:[
- oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr |
- |newPixel|
-
- (usedColors includes:clr) ifTrue:[
- newPixel := newColorMap indexOf:clr.
- oldToNew at:oldIdx put:newPixel-1.
- ]
- ].
- ].
-
- oldBits := oldImage bits.
- newBits := ByteArray new:(oldBits size).
- depth ~~ 8 ifTrue:[
- "/ expand/compress can only handle 8bits
- tmpBits := ByteArray uninitializedNew:(oldImage width*oldImage height).
- oldBits
- expandPixels:depth
- width:oldImage width
- height:oldImage height
- into:tmpBits
- mapping:oldToNew.
- tmpBits
- compressPixels:depth
- width:oldImage width
- height:oldImage height
- into:newBits
- mapping:nil
- ] ifFalse:[
- oldBits
- expandPixels:depth
- width:oldImage width
- height:oldImage height
- into:newBits
- mapping:oldToNew.
- ].
-
- newImage := oldImage species new
- width:oldImage width
- height:oldImage height
- depth:depth
- fromArray:newBits.
-
- newImage colorMap:newColorMap.
- newImage fileName:oldImage fileName.
- newImage mask:(oldImage mask copy).
+ |newImage|
+
+ newImage := self image.
+ newImage compressColorMap.
(imageEditView image:newImage) notNil ifTrue:[
self fetchImageData.
]
-
- "Created: / 28.7.1998 / 20:03:11 / cg"
- "Modified: / 15.9.1998 / 17:53:32 / cg"
!
copyColorFromColormap
@@ -5423,21 +5367,18 @@
menu_compressColorMap
"calculates a new color map for the image, using only used colors"
- |depth oldImage usedColors|
+ |depth oldImage usedColors colorMap|
oldImage := self image.
- depth := oldImage depth.
oldImage photometric ~~ #palette ifTrue:[
self information:'Compress colorMap: Only palette images have colormaps.'.
^ self
].
+ depth := oldImage depth.
+ colorMap := oldImage colorMap asArray asSet.
usedColors := oldImage realUsedColors.
- usedColors size == (1 bitShift:depth) ifTrue:[
- self information:'Compress colorMap: All colors are used - no compression.'.
- ^ self
- ].
- usedColors size == oldImage colorMap size ifTrue:[
+ usedColors size == colorMap size ifTrue:[
self information:'Compress colorMap: Colormap already compressed - no compression.'.
^ self
].