diff options
-rw-r--r-- | graphics/surface.cpp | 8 |
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; |