From fd1162cb7106130d328f9d7d523a8e73c42a53a3 Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Fri, 1 Mar 2019 00:10:39 +0000 Subject: GRAPHICS: Support converting to 3Bpp surfaces --- graphics/surface.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'graphics/surface.cpp') 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; -- cgit v1.2.3