[Scummvm-cvs-logs] scummvm master -> ed2be9d873cb69d2f06f38665342082e4ec157d0
clone2727
clone2727 at gmail.com
Sun Sep 9 23:28:19 CEST 2012
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
ed2be9d873 GRAPHICS: Fix ImageDecoder inconsistency with getPalette()
Commit: ed2be9d873cb69d2f06f38665342082e4ec157d0
https://github.com/scummvm/scummvm/commit/ed2be9d873cb69d2f06f38665342082e4ec157d0
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-09-09T14:20:07-07:00
Commit Message:
GRAPHICS: Fix ImageDecoder inconsistency with getPalette()
Per LordHoto's suggestion
Changed paths:
engines/mohawk/bitmap.cpp
graphics/decoders/image_decoder.h
graphics/decoders/pict.cpp
graphics/decoders/pict.h
diff --git a/engines/mohawk/bitmap.cpp b/engines/mohawk/bitmap.cpp
index 952b6da..65a697c 100644
--- a/engines/mohawk/bitmap.cpp
+++ b/engines/mohawk/bitmap.cpp
@@ -652,10 +652,10 @@ MohawkSurface *MystBitmap::decodeImage(Common::SeekableReadStream* stream) {
}
// Copy the palette to one of our own
- const byte *palette = bitmapDecoder.getPalette();
byte *newPal = 0;
- if (palette) {
+ if (bitmapDecoder.hasPalette()) {
+ const byte *palette = bitmapDecoder.getPalette();
newPal = (byte *)malloc(256 * 3);
memcpy(newPal, palette, 256 * 3);
}
diff --git a/graphics/decoders/image_decoder.h b/graphics/decoders/image_decoder.h
index 830645d..49e31c6 100644
--- a/graphics/decoders/image_decoder.h
+++ b/graphics/decoders/image_decoder.h
@@ -78,10 +78,15 @@ public:
* The palette's format is the same as PaletteManager's palette
* (interleaved RGB values).
*
- * @return the decoded palette, or 0 if no palette is present
+ * @return the decoded palette, or undefined if no palette is present
*/
virtual const byte *getPalette() const { return 0; }
+ /**
+ * Query if the decoded image has a palette.
+ */
+ virtual bool hasPalette() const { return getPaletteColorCount() != 0; }
+
/** Return the starting index of the palette. */
virtual byte getPaletteStartIndex() const { return 0; }
/** Return the number of colors in the palette. */
diff --git a/graphics/decoders/pict.cpp b/graphics/decoders/pict.cpp
index 7eddd3b..9e619df 100644
--- a/graphics/decoders/pict.cpp
+++ b/graphics/decoders/pict.cpp
@@ -292,12 +292,12 @@ struct PackBitsRectData {
uint16 mode;
};
-void PICTDecoder::unpackBitsRect(Common::SeekableReadStream &stream, bool hasPalette) {
+void PICTDecoder::unpackBitsRect(Common::SeekableReadStream &stream, bool withPalette) {
PackBitsRectData packBitsData;
- packBitsData.pixMap = readPixMap(stream, !hasPalette);
+ packBitsData.pixMap = readPixMap(stream, !withPalette);
// Read in the palette if there is one present
- if (hasPalette) {
+ if (withPalette) {
// See http://developer.apple.com/legacy/mac/library/documentation/mac/QuickDraw/QuickDraw-267.html
stream.readUint32BE(); // seed
stream.readUint16BE(); // flags
@@ -469,10 +469,10 @@ void PICTDecoder::outputPixelBuffer(byte *&out, byte value, byte bitsPerPixel) {
}
}
-void PICTDecoder::skipBitsRect(Common::SeekableReadStream &stream, bool hasPalette) {
+void PICTDecoder::skipBitsRect(Common::SeekableReadStream &stream, bool withPalette) {
// Step through a PackBitsRect/DirectBitsRect function
- if (!hasPalette)
+ if (!withPalette)
stream.readUint32BE();
uint16 rowBytes = stream.readUint16BE();
@@ -492,7 +492,7 @@ void PICTDecoder::skipBitsRect(Common::SeekableReadStream &stream, bool hasPalet
stream.readUint16BE(); // pixelSize
stream.skip(16);
- if (hasPalette) {
+ if (withPalette) {
stream.readUint32BE();
stream.readUint16BE();
stream.skip((stream.readUint16BE() + 1) * 8);
diff --git a/graphics/decoders/pict.h b/graphics/decoders/pict.h
index 417a7c5..fa352e6 100644
--- a/graphics/decoders/pict.h
+++ b/graphics/decoders/pict.h
@@ -87,9 +87,9 @@ private:
bool _continueParsing;
// Utility Functions
- void unpackBitsRect(Common::SeekableReadStream &stream, bool hasPalette);
+ void unpackBitsRect(Common::SeekableReadStream &stream, bool withPalette);
void unpackBitsLine(byte *out, uint32 length, Common::SeekableReadStream *stream, byte bitsPerPixel, byte bytesPerPixel);
- void skipBitsRect(Common::SeekableReadStream &stream, bool hasPalette);
+ void skipBitsRect(Common::SeekableReadStream &stream, bool withPalette);
void decodeCompressedQuickTime(Common::SeekableReadStream &stream);
void outputPixelBuffer(byte *&out, byte value, byte bitsPerPixel);
More information about the Scummvm-git-logs
mailing list