#BUGFIX by cg
class: Image
changed:
#colorMap:
#setColorMap:
#storeOn:
care for FixedPalette
--- a/Image.st Fri Feb 03 14:07:15 2017 +0100
+++ b/Image.st Fri Feb 03 16:57:28 2017 +0100
@@ -18,11 +18,11 @@
maxPixelValue rowByteSize bitsPerSample samplesPerPixel
photometric device deviceForm monoDeviceForm fullColorDeviceForm
mask maskedPixelsAre0 fileName imageSequence metaData'
- classVariableNames:'Lobby DitherAlgorithm NumberOfDitherColors
- CollectGarbageWhenRunningOutOfColors ImageErrorSignal
- ImageNotFoundQuerySignal BadImageFormatQuerySignal
- ImageSaveErrorSignal ImageLoadErrorSignal FileCreationErrorSignal
- CannotRepresentImageSignal InformationLostQuerySignal
+ classVariableNames:'BadImageFormatQuerySignal CannotRepresentImageSignal
+ CollectGarbageWhenRunningOutOfColors DitherAlgorithm
+ FileCreationErrorSignal ImageErrorSignal ImageLoadErrorSignal
+ ImageNotFoundQuerySignal ImageSaveErrorSignal
+ InformationLostQuerySignal Lobby NumberOfDitherColors
UnrepresentableColorSignal'
poolDictionaries:''
category:'Graphics-Images'
@@ -2686,37 +2686,42 @@
^ colorMap
!
-colorMap:aColorMap
+colorMap:newColorMap
"set the colorMap; this also sets the photometric to a useful default."
|oldSize "{ Class: SmallInteger }"
sameColors|
- (aColorMap isNil and:[colorMap isNil]) ifTrue:[^ self].
+ (newColorMap isNil and:[colorMap isNil]) ifTrue:[^ self].
sameColors := false.
photometric == #palette ifTrue:[
"/ any change at all ?
oldSize := colorMap size.
- aColorMap size >= oldSize ifTrue:[
+ newColorMap size >= oldSize ifTrue:[
sameColors := true.
1 to:oldSize do:[:idx |
- (aColorMap at:idx) = (colorMap at:idx) ifFalse:[
+ (newColorMap at:idx) = (colorMap at:idx) ifFalse:[
sameColors := false.
]
].
].
].
- self setColorMap:aColorMap.
+ self setColorMap:newColorMap.
sameColors ifTrue:[
^ self
].
- colorMap notNil ifTrue:[
- photometric := #palette.
+ newColorMap notNil ifTrue:[
+ newColorMap isFixedPalette ifTrue:[
+ photometric := #rgb
+ ] ifFalse:[
+ self assert:(self depth <= 8).
+ photometric := #palette.
+ ].
] ifFalse:[
(photometric == #palette) ifTrue:[
photometric := #blackIs0
@@ -2727,8 +2732,8 @@
]
"Modified: / 31-08-1995 / 03:05:59 / claus"
- "Modified: / 22-08-1998 / 12:29:58 / cg"
"Modified: / 31-01-2017 / 14:48:56 / stefan"
+ "Modified: / 03-02-2017 / 16:52:33 / cg"
!
colorMapFromArray: anArray
@@ -2942,14 +2947,15 @@
"Modified: 10.6.1996 / 18:03:30 / cg"
!
-setColorMap:aColorMap
- colorMap isColormap ifTrue:[
- colorMap := aColorMap.
+setColorMap:newColorMap
+ newColorMap isColormap ifTrue:[
+ colorMap := newColorMap.
] ifFalse:[
- colorMap := MappedPalette withColors:aColorMap.
+ colorMap := MappedPalette withColors:newColorMap.
].
"Modified: / 30-01-2017 / 19:15:34 / stefan"
+ "Modified (format): / 03-02-2017 / 16:39:48 / cg"
!
width
@@ -12867,9 +12873,11 @@
aStream cr; spaces:12; nextPutAll:'colorMapFromArray:'.
colorMapArray asByteArray storeOn:aStream.
] ifFalse:[
- aStream ct; spaces:12; nextPutAll:'colorMap:('.
- colorMap storeOn:aStream.
- aStream nextPutAll:')'
+ false ifTrue:[
+ aStream cr; spaces:12; nextPutAll:'colorMap:('.
+ colorMap storeOn:aStream.
+ aStream nextPutAll:')'
+ ]
]
].
mask notNil ifTrue:[
@@ -12879,7 +12887,7 @@
].
aStream nextPutAll:'; yourself'
- "Modified: / 22.8.1998 / 12:55:21 / cg"
+ "Modified: / 03-02-2017 / 16:56:29 / cg"
! !
!Image methodsFor:'private'!