mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
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.
This commit is contained in:
committed by
Willem Jan Palenstijn
parent
94378d0644
commit
07770eeafb
+10
-21
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user