diff --git a/vendor/librw/src/d3d-x/d3d.cpp b/vendor/librw/src/d3d-x/d3d.cpp index 9e722a14..3fc95b7f 100644 --- a/vendor/librw/src/d3d-x/d3d.cpp +++ b/vendor/librw/src/d3d-x/d3d.cpp @@ -902,10 +902,15 @@ rasterToImage(Raster *raster) depth = 16; conv = conv_ARGB1555_from_RGB555; break; - - default: case Raster::C565: + depth = 24; + conv = conv_RGB888_from_BGR565; + break; case Raster::C4444: + depth = 32; + conv = conv_RGBA8888_from_BGRA4444; + break; + default: case Raster::LUM8: RWERROR((ERR_INVRASTER)); return nil; diff --git a/vendor/librw/src/raster.cpp b/vendor/librw/src/raster.cpp index a675122e..e2b1f2cc 100644 --- a/vendor/librw/src/raster.cpp +++ b/vendor/librw/src/raster.cpp @@ -313,6 +313,34 @@ conv_ARGB1555_from_RGBA5551(uint8 *out, uint8 *in) out[1] = g>>3 | r<<2 | a<<7; } +void conv_RGB888_from_BGR565(uint8 *out, uint8 *in) +{ + uint16_t col = in[0] | in[1]<<8; + + uint32 r, g, b; + r = (col>>11) & 0x1F; + g = (col>>5) & 0x3F; + b = (col>>0) & 0x1F; + out[0] = r*0xFF/0x1f; + out[1] = g*0xFF/0x3f; + out[2] = b*0xFF/0x1f; +} + +void conv_RGBA8888_from_BGRA4444(uint8 *out, uint8 *in) +{ + uint16_t col = in[0] | in[1]<<8; + + uint32 r, g, b, a; + a = (col>>12) & 0xF; + r = (col>>8) & 0xF; + g = (col>>4) & 0xF; + b = (col>>0) & 0xF; + out[0] = r*0xFF/0xf; + out[1] = g*0xFF/0xf; + out[2] = b*0xFF/0xf; + out[3] = a*0xFF/0xf; +} + void conv_RGBA8888_from_ARGB1555(uint8 *out, uint8 *in) { diff --git a/vendor/librw/src/rwobjects.h b/vendor/librw/src/rwobjects.h index a74f0c02..88559908 100644 --- a/vendor/librw/src/rwobjects.h +++ b/vendor/librw/src/rwobjects.h @@ -328,6 +328,8 @@ void conv_ARGB1555_from_ARGB1555(uint8 *out, uint8 *in); void conv_ARGB1555_from_RGB555(uint8 *out, uint8 *in); void conv_RGBA5551_from_ARGB1555(uint8 *out, uint8 *in); void conv_ARGB1555_from_RGBA5551(uint8 *out, uint8 *in); +void conv_RGB888_from_BGR565(uint8 *out, uint8 *in); +void conv_RGBA8888_from_BGRA4444(uint8 *out, uint8 *in); void conv_RGBA8888_from_ARGB1555(uint8 *out, uint8 *in); void conv_ABGR1555_from_ARGB1555(uint8 *out, uint8 *in); inline void conv_8_from_8(uint8 *out, uint8 *in) { *out = *in; }