aboutsummaryrefslogtreecommitdiff
path: root/graphics/surface.cpp
diff options
context:
space:
mode:
authorMax Horn2005-05-08 21:24:33 +0000
committerMax Horn2005-05-08 21:24:33 +0000
commit315943f19a3d7b9acb64e9fb8b7e1587d81c1ae5 (patch)
treec1ab2da9c01c134176a671efd074940c25552962 /graphics/surface.cpp
parentcf936916db8375a504ec8e10ff478cd8827b059d (diff)
downloadscummvm-rg350-315943f19a3d7b9acb64e9fb8b7e1587d81c1ae5.tar.gz
scummvm-rg350-315943f19a3d7b9acb64e9fb8b7e1587d81c1ae5.tar.bz2
scummvm-rg350-315943f19a3d7b9acb64e9fb8b7e1587d81c1ae5.zip
Added convenience methods create/free to Graphics::Surface (part of patch #1163026)
svn-id: r17973
Diffstat (limited to 'graphics/surface.cpp')
-rw-r--r--graphics/surface.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/graphics/surface.cpp b/graphics/surface.cpp
index 4d7cc713bf..b0585eab15 100644
--- a/graphics/surface.cpp
+++ b/graphics/surface.cpp
@@ -46,6 +46,25 @@ void Surface::drawLine(int x0, int y0, int x1, int y1, uint32 color) {
error("Surface::drawLine: bytesPerPixel must be 1 or 2");
}
+void Surface::create(uint16 width, uint16 height, uint8 bytesPP) {
+ free();
+
+ w = width;
+ h = height;
+ bytesPerPixel = bytesPP;
+ pitch = w * bytesPP;
+
+ pixels = calloc(width * height, bytesPP);
+ assert(pixels);
+}
+
+void Surface::free() {
+ ::free(pixels);
+ pixels = 0;
+ w = h = pitch = 0;
+ bytesPerPixel = 0;
+}
+
void Surface::hLine(int x, int y, int x2, uint32 color) {
// Clipping
if (y < 0 || y >= h)