aboutsummaryrefslogtreecommitdiff
path: root/graphics/surface.cpp
diff options
context:
space:
mode:
authorCameron Cawley2019-03-01 00:10:39 +0000
committerBastien Bouclet2019-03-02 07:29:22 +0100
commitfd1162cb7106130d328f9d7d523a8e73c42a53a3 (patch)
tree21989285573836c2133fe842b28de25fd2dfbd12 /graphics/surface.cpp
parent5d912b6923c231d8be15fcfa155f998ef55ef126 (diff)
downloadscummvm-rg350-fd1162cb7106130d328f9d7d523a8e73c42a53a3.tar.gz
scummvm-rg350-fd1162cb7106130d328f9d7d523a8e73c42a53a3.tar.bz2
scummvm-rg350-fd1162cb7106130d328f9d7d523a8e73c42a53a3.zip
GRAPHICS: Support converting to 3Bpp surfaces
Diffstat (limited to 'graphics/surface.cpp')
-rw-r--r--graphics/surface.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/graphics/surface.cpp b/graphics/surface.cpp
index 699e1ccd22..de921a7269 100644
--- a/graphics/surface.cpp
+++ b/graphics/surface.cpp
@@ -434,8 +434,8 @@ Graphics::Surface *Surface::convertTo(const PixelFormat &dstFormat, const byte *
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(): Can only convert to 2Bpp and 4Bpp");
+ if (dstFormat.bytesPerPixel < 2 && dstFormat.bytesPerPixel > 4)
+ error("Surface::convertTo(): Can only convert to 2Bpp, 3Bpp and 4Bpp");
surface->create(w, h, dstFormat);
@@ -457,6 +457,8 @@ Graphics::Surface *Surface::convertTo(const PixelFormat &dstFormat, const byte *
if (dstFormat.bytesPerPixel == 2)
*((uint16 *)dstRow) = color;
+ else if (dstFormat.bytesPerPixel == 3)
+ WRITE_UINT24(dstRow, color);
else
*((uint32 *)dstRow) = color;
@@ -487,6 +489,8 @@ Graphics::Surface *Surface::convertTo(const PixelFormat &dstFormat, const byte *
if (dstFormat.bytesPerPixel == 2)
*((uint16 *)dstRow) = color;
+ else if (dstFormat.bytesPerPixel == 3)
+ WRITE_UINT24(dstRow, color);
else
*((uint32 *)dstRow) = color;