[Scummvm-cvs-logs] scummvm master -> b253a05454cd4088a70ac1a90589ebf5db85ed5a

clone2727 clone2727 at gmail.com
Mon May 14 16:05:26 CEST 2012


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
d789df8945 GRAPHICS: Add palette start index and color count functions to ImageDecoder
b253a05454 GRAPHICS: Hide the WinCursor implementation


Commit: d789df894552bf73709628f09a0282b462df797e
    https://github.com/scummvm/scummvm/commit/d789df894552bf73709628f09a0282b462df797e
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-05-14T06:56:56-07:00

Commit Message:
GRAPHICS: Add palette start index and color count functions to ImageDecoder

Changed paths:
    graphics/decoders/bmp.cpp
    graphics/decoders/bmp.h
    graphics/decoders/image_decoder.h
    graphics/decoders/pict.cpp
    graphics/decoders/pict.h
    graphics/decoders/png.cpp
    graphics/decoders/png.h



diff --git a/graphics/decoders/bmp.cpp b/graphics/decoders/bmp.cpp
index 0d44881..5f764e1 100644
--- a/graphics/decoders/bmp.cpp
+++ b/graphics/decoders/bmp.cpp
@@ -31,6 +31,7 @@ namespace Graphics {
 BitmapDecoder::BitmapDecoder() {
 	_surface = 0;
 	_palette = 0;
+	_paletteColorCount = 0;
 }
 
 BitmapDecoder::~BitmapDecoder() {
@@ -44,6 +45,7 @@ void BitmapDecoder::destroy() {
 	}
 
 	delete[] _palette; _palette = 0;
+	_paletteColorCount = 0;
 }
 
 bool BitmapDecoder::loadStream(Common::SeekableReadStream &stream) {
@@ -95,16 +97,16 @@ bool BitmapDecoder::loadStream(Common::SeekableReadStream &stream) {
 	/* uint32 imageSize = */ stream.readUint32LE();
 	/* uint32 pixelsPerMeterX = */ stream.readUint32LE();
 	/* uint32 pixelsPerMeterY = */ stream.readUint32LE();
-	uint32 colorsUsed = stream.readUint32LE();
+	_paletteColorCount = stream.readUint32LE();
 	/* uint32 colorsImportant = */ stream.readUint32LE();
 
-	if (colorsUsed == 0)
-		colorsUsed = 256;
+	if (_paletteColorCount == 0)
+		_paletteColorCount = 256;
 
 	if (bitsPerPixel == 8) {
 		// Read the palette
-		_palette = new byte[colorsUsed * 3];
-		for (uint16 i = 0; i < colorsUsed; i++) {
+		_palette = new byte[_paletteColorCount * 3];
+		for (uint16 i = 0; i < _paletteColorCount; i++) {
 			_palette[i * 3 + 2] = stream.readByte();
 			_palette[i * 3 + 1] = stream.readByte();
 			_palette[i * 3 + 0] = stream.readByte();
diff --git a/graphics/decoders/bmp.h b/graphics/decoders/bmp.h
index 8a37538..59da682 100644
--- a/graphics/decoders/bmp.h
+++ b/graphics/decoders/bmp.h
@@ -52,10 +52,12 @@ public:
 	virtual bool loadStream(Common::SeekableReadStream &stream);
 	virtual const Surface *getSurface() const { return _surface; }
 	const byte *getPalette() const { return _palette; }
+	uint16 getPaletteColorCount() const { return _paletteColorCount; }
 
 private:
 	Surface *_surface;
 	byte *_palette;
+	uint16 _paletteColorCount;
 };
 
 } // End of namespace Graphics
diff --git a/graphics/decoders/image_decoder.h b/graphics/decoders/image_decoder.h
index e768f7f..7fa0074 100644
--- a/graphics/decoders/image_decoder.h
+++ b/graphics/decoders/image_decoder.h
@@ -78,6 +78,11 @@ public:
 	 * @return the decoded palette, or 0 if no palette is present
 	 */
 	virtual const byte *getPalette() const { return 0; }
+
+	/** Return the starting index of the palette. */
+	virtual byte getPaletteStartIndex() const { return 0; }
+	/** Return the number of colors in the palette. */
+	virtual uint16 getPaletteColorCount() const { return 0; }
 };
 
 } // End of namespace Graphics
diff --git a/graphics/decoders/pict.cpp b/graphics/decoders/pict.cpp
index bdb733a..7eddd3b 100644
--- a/graphics/decoders/pict.cpp
+++ b/graphics/decoders/pict.cpp
@@ -38,6 +38,7 @@ namespace Graphics {
 
 PICTDecoder::PICTDecoder() {
 	_outputSurface = 0;
+	_paletteColorCount = 0;
 }
 
 PICTDecoder::~PICTDecoder() {
@@ -50,6 +51,8 @@ void PICTDecoder::destroy() {
 		delete _outputSurface;
 		_outputSurface = 0;
 	}
+
+	_paletteColorCount = 0;
 }
 
 #define OPCODE(a, b, c) _opcodes.push_back(PICTOpcode(a, &PICTDecoder::b, c))
@@ -298,9 +301,9 @@ void PICTDecoder::unpackBitsRect(Common::SeekableReadStream &stream, bool hasPal
 		// See http://developer.apple.com/legacy/mac/library/documentation/mac/QuickDraw/QuickDraw-267.html
 		stream.readUint32BE(); // seed
 		stream.readUint16BE(); // flags
-		uint16 colorCount = stream.readUint16BE() + 1;
+		_paletteColorCount = stream.readUint16BE() + 1;
 
-		for (uint32 i = 0; i < colorCount; i++) {
+		for (uint32 i = 0; i < _paletteColorCount; i++) {
 			stream.readUint16BE();
 			_palette[i * 3] = stream.readUint16BE() >> 8;
 			_palette[i * 3 + 1] = stream.readUint16BE() >> 8;
diff --git a/graphics/decoders/pict.h b/graphics/decoders/pict.h
index 1d07df1..417a7c5 100644
--- a/graphics/decoders/pict.h
+++ b/graphics/decoders/pict.h
@@ -57,6 +57,7 @@ public:
 	void destroy();
 	const Surface *getSurface() const { return _outputSurface; }
 	const byte *getPalette() const { return _palette; }
+	uint16 getPaletteColorCount() const { return _paletteColorCount; }
 
 	struct PixMap {
 		uint32 baseAddr;
@@ -81,6 +82,7 @@ public:
 private:
 	Common::Rect _imageRect;
 	byte _palette[256 * 3];
+	uint16 _paletteColorCount;
 	Graphics::Surface *_outputSurface;
 	bool _continueParsing;
 
diff --git a/graphics/decoders/png.cpp b/graphics/decoders/png.cpp
index b87b6fd..492c697 100644
--- a/graphics/decoders/png.cpp
+++ b/graphics/decoders/png.cpp
@@ -99,7 +99,7 @@ enum PNGFilters {
 };
 
 PNGDecoder::PNGDecoder() : _compressedBuffer(0), _compressedBufferSize(0),
-			_transparentColorSpecified(false), _outputSurface(0) {
+			_transparentColorSpecified(false), _outputSurface(0), _paletteEntries(0) {
 }
 
 PNGDecoder::~PNGDecoder() {
@@ -112,6 +112,8 @@ void PNGDecoder::destroy() {
 		delete _outputSurface;
 		_outputSurface = 0;
 	}
+
+	_paletteEntries = 0;
 }
 
 bool PNGDecoder::loadStream(Common::SeekableReadStream &stream) {
diff --git a/graphics/decoders/png.h b/graphics/decoders/png.h
index 1da0bea..ca204f6 100644
--- a/graphics/decoders/png.h
+++ b/graphics/decoders/png.h
@@ -73,6 +73,7 @@ public:
 	void destroy();
 	const Graphics::Surface *getSurface() const { return _outputSurface; }
 	const byte *getPalette() const { return _palette; }
+	uint16 getPaletteColorCount() const { return _paletteEntries; }
 
 private:
 	enum PNGColorType {


Commit: b253a05454cd4088a70ac1a90589ebf5db85ed5a
    https://github.com/scummvm/scummvm/commit/b253a05454cd4088a70ac1a90589ebf5db85ed5a
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-05-14T06:56:56-07:00

Commit Message:
GRAPHICS: Hide the WinCursor implementation

Changed paths:
    engines/mohawk/cursors.cpp
    engines/scumm/he/resource_he.cpp
    graphics/wincursor.cpp
    graphics/wincursor.h



diff --git a/engines/mohawk/cursors.cpp b/engines/mohawk/cursors.cpp
index 8c72c98..3cf5ac7 100644
--- a/engines/mohawk/cursors.cpp
+++ b/engines/mohawk/cursors.cpp
@@ -157,7 +157,7 @@ void NECursorManager::setCursor(uint16 id) {
 		Graphics::WinCursorGroup *cursorGroup = Graphics::WinCursorGroup::createCursorGroup(*_exe, id);
 
 		if (cursorGroup) {
-			Graphics::WinCursor *cursor = cursorGroup->cursors[0].cursor;
+			Graphics::Cursor *cursor = cursorGroup->cursors[0].cursor;
 			CursorMan.replaceCursor(cursor->getSurface(), cursor->getWidth(), cursor->getHeight(), cursor->getHotspotX(), cursor->getHotspotY(), cursor->getKeyColor());
 			CursorMan.replaceCursorPalette(cursor->getPalette(), 0, 256);
 			return;
@@ -257,7 +257,7 @@ void PECursorManager::setCursor(uint16 id) {
 		Graphics::WinCursorGroup *cursorGroup = Graphics::WinCursorGroup::createCursorGroup(*_exe, id);
 
 		if (cursorGroup) {
-			Graphics::WinCursor *cursor = cursorGroup->cursors[0].cursor;
+			Graphics::Cursor *cursor = cursorGroup->cursors[0].cursor;
 			CursorMan.replaceCursor(cursor->getSurface(), cursor->getWidth(), cursor->getHeight(), cursor->getHotspotX(), cursor->getHotspotY(), cursor->getKeyColor());
 			CursorMan.replaceCursorPalette(cursor->getPalette(), 0, 256);
 			delete cursorGroup;
diff --git a/engines/scumm/he/resource_he.cpp b/engines/scumm/he/resource_he.cpp
index 42748d0..ce4b223 100644
--- a/engines/scumm/he/resource_he.cpp
+++ b/engines/scumm/he/resource_he.cpp
@@ -129,7 +129,7 @@ bool Win32ResExtractor::extractResource(int id, CachedCursor *cc) {
 	if (!group)
 		return false;
 
-	Graphics::WinCursor *cursor = group->cursors[0].cursor;
+	Graphics::Cursor *cursor = group->cursors[0].cursor;
 
 	cc->bitmap = new byte[cursor->getWidth() * cursor->getHeight()];
 	cc->width = cursor->getWidth();
diff --git a/graphics/wincursor.cpp b/graphics/wincursor.cpp
index 2db72a2..1d599f7 100644
--- a/graphics/wincursor.cpp
+++ b/graphics/wincursor.cpp
@@ -30,6 +30,46 @@
 
 namespace Graphics {
 
+/** A Windows cursor. */
+class WinCursor : public Cursor {
+public:
+	WinCursor();
+	~WinCursor();
+
+	/** Return the cursor's width. */
+	uint16 getWidth() const;
+	/** Return the cursor's height. */
+	uint16 getHeight() const;
+	/** Return the cursor's hotspot's x coordinate. */
+	uint16 getHotspotX() const;
+	/** Return the cursor's hotspot's y coordinate. */
+	uint16 getHotspotY() const;
+	/** Return the cursor's transparent key. */
+	byte getKeyColor() const;
+
+	const byte *getSurface() const { return _surface; }
+
+	const byte *getPalette() const { return _palette; }
+	byte getPaletteStartIndex() const { return 0; }
+	uint16 getPaletteCount() const { return 256; }
+
+	/** Read the cursor's data out of a stream. */
+	bool readFromStream(Common::SeekableReadStream &stream);
+
+private:
+	byte *_surface;
+	byte _palette[256 * 3];
+
+	uint16 _width;    ///< The cursor's width.
+	uint16 _height;   ///< The cursor's height.
+	uint16 _hotspotX; ///< The cursor's hotspot's x coordinate.
+	uint16 _hotspotY; ///< The cursor's hotspot's y coordinate.
+	byte   _keyColor; ///< The cursor's transparent key
+
+	/** Clear the cursor. */
+	void clear();
+};
+
 WinCursor::WinCursor() {
 	_width    = 0;
 	_height   = 0;
diff --git a/graphics/wincursor.h b/graphics/wincursor.h
index e6b35dc..9e73e3a 100644
--- a/graphics/wincursor.h
+++ b/graphics/wincursor.h
@@ -36,46 +36,6 @@ class SeekableReadStream;
 
 namespace Graphics {
 
-/** A Windows cursor. */
-class WinCursor : public Cursor {
-public:
-	WinCursor();
-	~WinCursor();
-
-	/** Return the cursor's width. */
-	uint16 getWidth() const;
-	/** Return the cursor's height. */
-	uint16 getHeight() const;
-	/** Return the cursor's hotspot's x coordinate. */
-	uint16 getHotspotX() const;
-	/** Return the cursor's hotspot's y coordinate. */
-	uint16 getHotspotY() const;
-	/** Return the cursor's transparent key. */
-	byte getKeyColor() const;
-
-	const byte *getSurface() const { return _surface; }
-
-	const byte *getPalette() const { return _palette; }
-	byte getPaletteStartIndex() const { return 0; }
-	uint16 getPaletteCount() const { return 256; }
-
-	/** Read the cursor's data out of a stream. */
-	bool readFromStream(Common::SeekableReadStream &stream);
-
-private:
-	byte *_surface;
-	byte _palette[256 * 3];
-
-	uint16 _width;    ///< The cursor's width.
-	uint16 _height;   ///< The cursor's height.
-	uint16 _hotspotX; ///< The cursor's hotspot's x coordinate.
-	uint16 _hotspotY; ///< The cursor's hotspot's y coordinate.
-	byte   _keyColor; ///< The cursor's transparent key
-
-	/** Clear the cursor. */
-	void clear();
-};
-
 /**
  * A structure holding an array of cursors from a single Windows Executable cursor group.
  *
@@ -91,7 +51,7 @@ struct WinCursorGroup {
 
 	struct CursorItem {
 		Common::WinResourceID id;
-		WinCursor *cursor;
+		Cursor *cursor;
 	};
 
 	Common::Array<CursorItem> cursors;






More information about the Scummvm-git-logs mailing list