aboutsummaryrefslogtreecommitdiff
path: root/engines/gob
diff options
context:
space:
mode:
authorSven Hesse2011-01-16 16:28:17 +0000
committerSven Hesse2011-01-16 16:28:17 +0000
commit7de179c2c816700629e8e53307ae7c1d995edae0 (patch)
tree4d4ad5bcf5fd51a8d6430db8c5102938a60e80f9 /engines/gob
parentfaa66fc01a343c66b1006e6ee22045770094b7b7 (diff)
downloadscummvm-rg350-7de179c2c816700629e8e53307ae7c1d995edae0.tar.gz
scummvm-rg350-7de179c2c816700629e8e53307ae7c1d995edae0.tar.bz2
scummvm-rg350-7de179c2c816700629e8e53307ae7c1d995edae0.zip
GOB: Add setBPP()
To allow converting the surface's bytes per pixel without destroying it first. svn-id: r55260
Diffstat (limited to 'engines/gob')
-rw-r--r--engines/gob/surface.cpp18
-rw-r--r--engines/gob/surface.h4
2 files changed, 20 insertions, 2 deletions
diff --git a/engines/gob/surface.cpp b/engines/gob/surface.cpp
index 554edfc753..fa2d9cf9ab 100644
--- a/engines/gob/surface.cpp
+++ b/engines/gob/surface.cpp
@@ -167,7 +167,7 @@ uint16 Surface::getHeight() const {
return _height;
}
-uint16 Surface::getBPP() const {
+uint8 Surface::getBPP() const {
return _bpp;
}
@@ -186,6 +186,22 @@ void Surface::resize(uint16 width, uint16 height) {
memset(_vidMem, 0, _bpp * _width * _height);
}
+void Surface::setBPP(uint8 bpp) {
+ if (_bpp == bpp)
+ return;
+
+ if (_ownVidMem) {
+ delete[] _vidMem;
+
+ _vidMem = new byte[bpp * _width * _height];
+ } else
+ _width = (_width * _bpp) / bpp;
+
+ _bpp = bpp;
+
+ memset(_vidMem, 0, _bpp * _width * _height);
+}
+
byte *Surface::getData(uint16 x, uint16 y) {
return _vidMem + (y * _width * _bpp) + (x * _bpp);
}
diff --git a/engines/gob/surface.h b/engines/gob/surface.h
index 9a26dbc79b..b22bfb9222 100644
--- a/engines/gob/surface.h
+++ b/engines/gob/surface.h
@@ -82,13 +82,15 @@ public:
uint16 getWidth () const;
uint16 getHeight() const;
- uint16 getBPP () const;
+ uint8 getBPP () const;
byte *getData(uint16 x = 0, uint16 y = 0);
const byte *getData(uint16 x = 0, uint16 y = 0) const;
void resize(uint16 width, uint16 height);
+ void setBPP(uint8 bpp);
+
Pixel get(uint16 x = 0, uint16 y = 0);
ConstPixel get(uint16 x = 0, uint16 y = 0) const;