aboutsummaryrefslogtreecommitdiff
path: root/graphics/surface.cpp
diff options
context:
space:
mode:
authorJohannes Schickel2011-04-17 15:17:42 +0200
committerJohannes Schickel2011-04-17 15:17:42 +0200
commit4fd3e3d6fe72b6b978fbc5e9e0b5218741d15c83 (patch)
tree1f81a65bd83045e39794067a4e1adf958188ef10 /graphics/surface.cpp
parent886ea29bbfe5556729843d97637ea9f691382ddc (diff)
downloadscummvm-rg350-4fd3e3d6fe72b6b978fbc5e9e0b5218741d15c83.tar.gz
scummvm-rg350-4fd3e3d6fe72b6b978fbc5e9e0b5218741d15c83.tar.bz2
scummvm-rg350-4fd3e3d6fe72b6b978fbc5e9e0b5218741d15c83.zip
GRAPHICS: Add a PixelFormat member to Surface.
Diffstat (limited to 'graphics/surface.cpp')
-rw-r--r--graphics/surface.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/graphics/surface.cpp b/graphics/surface.cpp
index f06c24c2cd..eadc464da4 100644
--- a/graphics/surface.cpp
+++ b/graphics/surface.cpp
@@ -53,13 +53,27 @@ void Surface::create(uint16 width, uint16 height, uint8 bytesPP) {
w = width;
h = height;
- bytesPerPixel = bytesPP;
+ format = PixelFormat();
+ format.bytesPerPixel = bytesPerPixel = bytesPP;
pitch = w * bytesPP;
pixels = calloc(width * height, bytesPP);
assert(pixels);
}
+void Surface::create(uint16 width, uint16 height, const PixelFormat &f) {
+ free();
+
+ w = width;
+ h = height;
+ format = f;
+ bytesPerPixel = format.bytesPerPixel;
+ pitch = w * bytesPerPixel;
+
+ pixels = calloc(width * height, bytesPerPixel);
+ assert(pixels);
+}
+
void Surface::free() {
::free(pixels);
pixels = 0;
@@ -69,6 +83,7 @@ void Surface::free() {
void Surface::copyFrom(const Surface &surf) {
create(surf.w, surf.h, surf.bytesPerPixel);
+ format = surf.format;
memcpy(pixels, surf.pixels, h * pitch);
}