diff options
author | Matthew Hoops | 2012-03-07 22:00:22 -0500 |
---|---|---|
committer | Johannes Schickel | 2012-03-20 01:06:48 +0100 |
commit | a7740fb6de17967e0187b606e94d8b7f91951f79 (patch) | |
tree | aea75f1efa9d7a6958171deccd1437b2eff2d426 /graphics | |
parent | 4d65be826412e8a41fb714f19deb804bfd7599a0 (diff) | |
download | scummvm-rg350-a7740fb6de17967e0187b606e94d8b7f91951f79.tar.gz scummvm-rg350-a7740fb6de17967e0187b606e94d8b7f91951f79.tar.bz2 scummvm-rg350-a7740fb6de17967e0187b606e94d8b7f91951f79.zip |
GRAPHICS: Add support for converting surfaces from 24bpp
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/surface.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/graphics/surface.cpp b/graphics/surface.cpp index 0a5b109eb0..fcd702241a 100644 --- a/graphics/surface.cpp +++ b/graphics/surface.cpp @@ -20,6 +20,7 @@ */ #include "common/algorithm.h" +#include "common/endian.h" #include "common/util.h" #include "common/rect.h" #include "common/textconsole.h" @@ -281,8 +282,11 @@ Graphics::Surface *Surface::convertTo(const PixelFormat &dstFormat, const byte * return surface; } + if (format.bytesPerPixel == 0 || format.bytesPerPixel > 4) + error("Surface::convertTo(): Can only convert from 1Bpp, 2Bpp, 3Bpp, and 4Bpp"); + if (dstFormat.bytesPerPixel != 2 && dstFormat.bytesPerPixel != 4) - error("Surface::convertTo(): Only 2Bpp and 4Bpp supported"); + error("Surface::convertTo(): Can only convert to 2Bpp and 4Bpp"); surface->create(w, h, dstFormat); @@ -319,9 +323,11 @@ Graphics::Surface *Surface::convertTo(const PixelFormat &dstFormat, const byte * for (int x = 0; x < w; x++) { uint32 srcColor; if (format.bytesPerPixel == 2) - srcColor = *((uint16 *)srcRow); + srcColor = READ_UINT16(srcRow); + else if (format.bytesPerPixel == 3) + srcColor = READ_UINT24(srcRow); else - srcColor = *((uint32 *)srcRow); + srcColor = READ_UINT32(srcRow); srcRow += format.bytesPerPixel; |