[Scummvm-cvs-logs] SF.net SVN: scummvm:[55260] scummvm/trunk/engines/gob

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Sun Jan 16 17:28:17 CET 2011


Revision: 55260
          http://scummvm.svn.sourceforge.net/scummvm/?rev=55260&view=rev
Author:   drmccoy
Date:     2011-01-16 16:28:17 +0000 (Sun, 16 Jan 2011)

Log Message:
-----------
GOB: Add setBPP()

To allow converting the surface's bytes per pixel
without destroying it first.

Modified Paths:
--------------
    scummvm/trunk/engines/gob/surface.cpp
    scummvm/trunk/engines/gob/surface.h

Modified: scummvm/trunk/engines/gob/surface.cpp
===================================================================
--- scummvm/trunk/engines/gob/surface.cpp	2011-01-16 16:27:52 UTC (rev 55259)
+++ scummvm/trunk/engines/gob/surface.cpp	2011-01-16 16:28:17 UTC (rev 55260)
@@ -167,7 +167,7 @@
 	return _height;
 }
 
-uint16 Surface::getBPP() const {
+uint8 Surface::getBPP() const {
 	return _bpp;
 }
 
@@ -186,6 +186,22 @@
 	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);
 }

Modified: scummvm/trunk/engines/gob/surface.h
===================================================================
--- scummvm/trunk/engines/gob/surface.h	2011-01-16 16:27:52 UTC (rev 55259)
+++ scummvm/trunk/engines/gob/surface.h	2011-01-16 16:28:17 UTC (rev 55260)
@@ -82,13 +82,15 @@
 
 	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;
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list