GRAPHICS: Add support for converting surfaces from 24bpp
This commit is contained in:
parent
4d65be8264
commit
a7740fb6de
1 changed files with 9 additions and 3 deletions
|
@ -20,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "common/algorithm.h"
|
#include "common/algorithm.h"
|
||||||
|
#include "common/endian.h"
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
#include "common/rect.h"
|
#include "common/rect.h"
|
||||||
#include "common/textconsole.h"
|
#include "common/textconsole.h"
|
||||||
|
@ -281,8 +282,11 @@ Graphics::Surface *Surface::convertTo(const PixelFormat &dstFormat, const byte *
|
||||||
return surface;
|
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)
|
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);
|
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++) {
|
for (int x = 0; x < w; x++) {
|
||||||
uint32 srcColor;
|
uint32 srcColor;
|
||||||
if (format.bytesPerPixel == 2)
|
if (format.bytesPerPixel == 2)
|
||||||
srcColor = *((uint16 *)srcRow);
|
srcColor = READ_UINT16(srcRow);
|
||||||
|
else if (format.bytesPerPixel == 3)
|
||||||
|
srcColor = READ_UINT24(srcRow);
|
||||||
else
|
else
|
||||||
srcColor = *((uint32 *)srcRow);
|
srcColor = READ_UINT32(srcRow);
|
||||||
|
|
||||||
srcRow += format.bytesPerPixel;
|
srcRow += format.bytesPerPixel;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue