# HG changeset patch # User Claus Gittinger # Date 1579174862 -3600 # Node ID bf667c58b12e4c5b1c816fa0e6ae1dfd5125a4de # Parent 7a5b398e1316ccb4179d699c9e449b1e64d42e97 #BUGFIX by cg class: ImageEditor changed: #colorMapMode: diff -r 7a5b398e1316 -r bf667c58b12e ImageEditor.st --- a/ImageEditor.st Wed Dec 18 19:07:20 2019 +0100 +++ b/ImageEditor.st Thu Jan 16 12:41:02 2020 +0100 @@ -1,5 +1,3 @@ -"{ Encoding: utf8 }" - " COPYRIGHT (c) 1997-1998 by eXept Software AG All Rights Reserved @@ -5843,8 +5841,8 @@ resourceSelector notNil ifTrue:[ ^ resources string:(self modified - ifTrue:['ImageEditor (modified): %1 » %2'] - ifFalse:['ImageEditor: %1 » %2']) + ifTrue:['ImageEditor (modified): %1 » %2'] + ifFalse:['ImageEditor: %1 » %2']) with:resourceClass name with:resourceSelector ]. @@ -5877,8 +5875,8 @@ resourceSelector notNil ifTrue:[ ^ resources string:(self modified - ifTrue:['Image (modified) from: %1 » %2'] - ifFalse:['Image from: %1 » %2']) + ifTrue:['Image (modified) from: %1 » %2'] + ifFalse:['Image from: %1 » %2']) with:resourceClass name with:resourceSelector ]. @@ -7019,7 +7017,7 @@ |depth numColors newColorMap newImage oldImage image newColors realColorMap oldFileName usedColors useNearest usageCounts tmpBits tmpMap quest - prevMode maskThreshold maskImage| + prevMode maskThreshold maskImage oldColors| oldImage := self image. @@ -7110,8 +7108,13 @@ ]. usageCounts := tmpBits usageCounts. tmpMap := Array new:usageCounts size. - oldImage colorMap asArray keysAndValuesDo:[:i :clr | - tmpMap at:i put:clr + oldColors := oldImage colorMap asArray. + "/ sigh: there seem to be images around where the cmap has more entries + "/ than expected (i.e. 257 colors in an 8 bit image) + oldColors keysAndValuesDo:[:i :clr | + i <= tmpMap size ifTrue:[ + tmpMap at:i put:clr + ] ]. usageCounts sort:[:a :b | a > b] with:tmpMap.