diff options
author | Matthew Hoops | 2012-05-25 00:21:51 -0400 |
---|---|---|
committer | Matthew Hoops | 2012-05-25 00:35:38 -0400 |
commit | f1f6a82cd57fceb52afdd393f44a80c40f3c9a15 (patch) | |
tree | 06a04072df44bd5f337ff79b43684d8109a72f59 /graphics | |
parent | b2506abccf6aa64da31b497b45fe0e1949530053 (diff) | |
parent | beef27fc10bb714fe37f2ee0c35cd143dc706829 (diff) | |
download | scummvm-rg350-f1f6a82cd57fceb52afdd393f44a80c40f3c9a15.tar.gz scummvm-rg350-f1f6a82cd57fceb52afdd393f44a80c40f3c9a15.tar.bz2 scummvm-rg350-f1f6a82cd57fceb52afdd393f44a80c40f3c9a15.zip |
Merge remote branch 'upstream/master' into pegasus
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/decoders/bmp.cpp | 12 | ||||
-rw-r--r-- | graphics/decoders/bmp.h | 2 | ||||
-rw-r--r-- | graphics/decoders/image_decoder.h | 5 | ||||
-rw-r--r-- | graphics/decoders/pict.cpp | 7 | ||||
-rw-r--r-- | graphics/decoders/pict.h | 2 | ||||
-rw-r--r-- | graphics/decoders/png.cpp | 4 | ||||
-rw-r--r-- | graphics/decoders/png.h | 1 | ||||
-rw-r--r-- | graphics/wincursor.cpp | 40 | ||||
-rw-r--r-- | graphics/wincursor.h | 42 |
9 files changed, 66 insertions, 49 deletions
diff --git a/graphics/decoders/bmp.cpp b/graphics/decoders/bmp.cpp index 0d44881d7c..5f764e1bd3 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 8a37538ee1..59da682e4d 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 e768f7f9a2..7fa00749ff 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 bdb733a87d..7eddd3b893 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 1d07df1ab9..417a7c5134 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 b87b6fdc7a..492c69779f 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 1da0bea1ab..ca204f6dd3 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 { diff --git a/graphics/wincursor.cpp b/graphics/wincursor.cpp index 2db72a2874..1d599f7130 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 e6b35dc80c..9e73e3a12f 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; |