--- a/GIFReader.st Tue May 31 15:15:03 2016 +0200
+++ b/GIFReader.st Tue May 31 15:21:21 2016 +0200
@@ -668,24 +668,26 @@
assignTransparentPixelIn:image
"find an usused pixelValue in the colorMap (or image)."
- |cmap usedPixelValues unusedValues|
+ |cmap cmapSize imgDepth usedPixelValues unusedValues|
- (cmap := image colorMap) size > 0 ifTrue:[
- cmap size < 256 ifTrue:[
- maskPixel := cmap size.
- ^ self
- ]
+ cmap := image colorMap.
+ cmapSize := cmap size.
+ ((cmapSize > 0) and:[cmapSize < 256]) ifTrue:[
+ maskPixel := cmapSize.
+ ^ self
].
+
image compressColorMap.
+ imgDepth := image depth.
usedPixelValues := image usedValues.
- usedPixelValues size < (1 bitShift:image depth) ifFalse:[
- Image informationLostQuerySignal
- raiseRequestWith:image
- errorString:('GIF writer cannot assign a transparent pixel - all pixelValues used by image').
+ usedPixelValues size < (1 bitShift:imgDepth) ifFalse:[
+ Image informationLostQuerySignal
+ raiseRequestWith:image
+ errorString:('GIF writer cannot assign a transparent pixel - all pixelValues used by image').
].
"/ there must be an unused pixelValue
- unusedValues := (0 to:(1 bitShift:image depth)-1) asSet.
+ unusedValues := (0 to:(1 bitShift:imgDepth)-1) asSet.
unusedValues removeAll:usedPixelValues.
maskPixel := unusedValues first.