From 7de179c2c816700629e8e53307ae7c1d995edae0 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sun, 16 Jan 2011 16:28:17 +0000 Subject: GOB: Add setBPP() To allow converting the surface's bytes per pixel without destroying it first. svn-id: r55260 --- engines/gob/surface.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'engines/gob/surface.cpp') 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); } -- cgit v1.2.3