diff options
author | richiesams | 2013-08-29 02:01:04 -0500 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-09-24 13:59:38 +0200 |
commit | 07770eeafbf72fa4ffcee2f474b212d2a67ee234 (patch) | |
tree | d7ab6ca781a6b196ef2c9e3f75d58d059ddc344e /engines | |
parent | 94378d064405992905a9ffcb24c72f0c86d51bd4 (diff) | |
download | scummvm-rg350-07770eeafbf72fa4ffcee2f474b212d2a67ee234.tar.gz scummvm-rg350-07770eeafbf72fa4ffcee2f474b212d2a67ee234.tar.bz2 scummvm-rg350-07770eeafbf72fa4ffcee2f474b212d2a67ee234.zip |
ZVISION: Convert cursors to RBG 565
This is part of a series of commits converting all game assets to RBG 565 from
RBG 555. The argument is that certain backends do not support RGB 555.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/zvision/cursor.cpp | 31 | ||||
-rw-r--r-- | engines/zvision/cursor.h | 7 |
2 files changed, 13 insertions, 25 deletions
diff --git a/engines/zvision/cursor.cpp b/engines/zvision/cursor.cpp index 601c58fa2c..57859b9b46 100644 --- a/engines/zvision/cursor.cpp +++ b/engines/zvision/cursor.cpp @@ -34,16 +34,14 @@ ZorkCursor::ZorkCursor() : _width(0), _height(0), _hotspotX(0), - _hotspotY(0), - _surface(0) { + _hotspotY(0) { } ZorkCursor::ZorkCursor(const Common::String &fileName) : _width(0), _height(0), _hotspotX(0), - _hotspotY(0), - _surface(0) { + _hotspotY(0) { Common::File file; if (!file.open(fileName)) return; @@ -59,10 +57,13 @@ ZorkCursor::ZorkCursor(const Common::String &fileName) _width = file.readUint16LE(); _height = file.readUint16LE(); - uint dataSize = _width * _height * 2; - _surface = new byte[dataSize]; - uint32 bytesRead = file.read(_surface, dataSize); + uint dataSize = _width * _height * sizeof(uint16); + _surface.create(_width, _height, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0)); + uint32 bytesRead = file.read(_surface.getPixels(), dataSize); assert(bytesRead == dataSize); + + // Convert to RGB 565 + _surface.convertToInPlace(Graphics::PixelFormat(2, 5, 6, 6, 0, 11, 5, 0, 0)); } ZorkCursor::ZorkCursor(const ZorkCursor &other) { @@ -71,10 +72,7 @@ ZorkCursor::ZorkCursor(const ZorkCursor &other) { _hotspotX = other._hotspotX; _hotspotY = other._hotspotY; - uint dataSize = _width * _height * 2; - _surface = new byte[dataSize]; - - memcpy(_surface, other._surface, dataSize); + _surface.copyFrom(other._surface); } ZorkCursor &ZorkCursor::operator=(const ZorkCursor &other) { @@ -83,18 +81,9 @@ ZorkCursor &ZorkCursor::operator=(const ZorkCursor &other) { _hotspotX = other._hotspotX; _hotspotY = other._hotspotY; - uint dataSize = _width * _height * 2; - _surface = new byte[dataSize]; - - memcpy(_surface, other._surface, dataSize); + _surface.copyFrom(other._surface); return *this; } -ZorkCursor::~ZorkCursor() { - if (_surface != 0) { - delete[] _surface; - } -} - } // End of namespace ZVision diff --git a/engines/zvision/cursor.h b/engines/zvision/cursor.h index 9a561fcac3..ec9f5ed0d7 100644 --- a/engines/zvision/cursor.h +++ b/engines/zvision/cursor.h @@ -25,7 +25,7 @@ #include "common/types.h" -#include "graphics/cursor.h" +#include "graphics/surface.h" namespace Common { class String; @@ -42,14 +42,13 @@ public: ZorkCursor(); ZorkCursor(const Common::String &fileName); ZorkCursor(const ZorkCursor &other); - ~ZorkCursor(); private: uint16 _width; uint16 _height; uint16 _hotspotX; uint16 _hotspotY; - byte *_surface; + Graphics::Surface _surface; public: ZorkCursor &operator=(const ZorkCursor &other); @@ -59,7 +58,7 @@ public: uint16 getHotspotX() const { return _hotspotX; } uint16 getHotspotY() const { return _hotspotY; } byte getKeyColor() const { return 0; } - const byte *getSurface() const { return _surface; } + const byte *getSurface() const { return (const byte *)_surface.getPixels(); } }; } // End of namespace ZVision |