#BUGFIX by cg
authorClaus Gittinger <cg@exept.de>
Thu, 16 Jan 2020 12:41:02 +0100
changeset 3830bf667c58b12e
parent 3829 7a5b398e1316
child 3831 669f318049d2
#BUGFIX by cg
class: ImageEditor
changed: #colorMapMode:
ImageEditor.st
     1.1 --- a/ImageEditor.st	Wed Dec 18 19:07:20 2019 +0100
     1.2 +++ b/ImageEditor.st	Thu Jan 16 12:41:02 2020 +0100
     1.3 @@ -1,5 +1,3 @@
     1.4 -"{ Encoding: utf8 }"
     1.5 -
     1.6  "
     1.7   COPYRIGHT (c) 1997-1998 by eXept Software AG
     1.8                All Rights Reserved
     1.9 @@ -5843,8 +5841,8 @@
    1.10          resourceSelector notNil ifTrue:[
    1.11              ^ resources 
    1.12                      string:(self modified 
    1.13 -                            ifTrue:['ImageEditor (modified): %1 » %2']
    1.14 -                            ifFalse:['ImageEditor: %1 » %2'])
    1.15 +                            ifTrue:['ImageEditor (modified): %1  %2']
    1.16 +                            ifFalse:['ImageEditor: %1  %2'])
    1.17                      with:resourceClass name
    1.18                      with:resourceSelector
    1.19          ].
    1.20 @@ -5877,8 +5875,8 @@
    1.21          resourceSelector notNil ifTrue:[
    1.22              ^ resources 
    1.23                      string:(self modified 
    1.24 -                            ifTrue:['Image (modified) from: %1 » %2']
    1.25 -                            ifFalse:['Image from: %1 » %2'])
    1.26 +                            ifTrue:['Image (modified) from: %1  %2']
    1.27 +                            ifFalse:['Image from: %1  %2'])
    1.28                      with:resourceClass name
    1.29                      with:resourceSelector
    1.30          ].
    1.31 @@ -7019,7 +7017,7 @@
    1.32      |depth numColors newColorMap newImage 
    1.33       oldImage image newColors realColorMap oldFileName
    1.34       usedColors useNearest usageCounts tmpBits tmpMap quest
    1.35 -     prevMode maskThreshold maskImage| 
    1.36 +     prevMode maskThreshold maskImage oldColors| 
    1.37  
    1.38      oldImage := self image.
    1.39  
    1.40 @@ -7110,8 +7108,13 @@
    1.41                          ].
    1.42                          usageCounts := tmpBits usageCounts.
    1.43                          tmpMap := Array new:usageCounts size.
    1.44 -                        oldImage colorMap asArray keysAndValuesDo:[:i :clr |
    1.45 -                            tmpMap at:i put:clr
    1.46 +                        oldColors := oldImage colorMap asArray.
    1.47 +                        "/ sigh: there seem to be images around where the cmap has more entries
    1.48 +                        "/ than expected (i.e. 257 colors in an 8 bit image)
    1.49 +                        oldColors keysAndValuesDo:[:i :clr |
    1.50 +                            i <= tmpMap size ifTrue:[
    1.51 +                                tmpMap at:i put:clr
    1.52 +                            ]
    1.53                          ].
    1.54                          usageCounts sort:[:a :b | a > b] with:tmpMap.
    1.55