Add support for C565 and C4444 on texture import, some game distro uses those in particle.txd

This commit is contained in:
Stefanos Kornilios Mitsis Poiitidis 2024-12-26 21:01:15 +02:00
parent d523140fa4
commit 4e8f09ac66
3 changed files with 37 additions and 2 deletions

View File

@ -902,10 +902,15 @@ rasterToImage(Raster *raster)
depth = 16; depth = 16;
conv = conv_ARGB1555_from_RGB555; conv = conv_ARGB1555_from_RGB555;
break; break;
default:
case Raster::C565: case Raster::C565:
depth = 24;
conv = conv_RGB888_from_BGR565;
break;
case Raster::C4444: case Raster::C4444:
depth = 32;
conv = conv_RGBA8888_from_BGRA4444;
break;
default:
case Raster::LUM8: case Raster::LUM8:
RWERROR((ERR_INVRASTER)); RWERROR((ERR_INVRASTER));
return nil; return nil;

View File

@ -313,6 +313,34 @@ conv_ARGB1555_from_RGBA5551(uint8 *out, uint8 *in)
out[1] = g>>3 | r<<2 | a<<7; 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 void
conv_RGBA8888_from_ARGB1555(uint8 *out, uint8 *in) conv_RGBA8888_from_ARGB1555(uint8 *out, uint8 *in)
{ {

View File

@ -328,6 +328,8 @@ void conv_ARGB1555_from_ARGB1555(uint8 *out, uint8 *in);
void conv_ARGB1555_from_RGB555(uint8 *out, uint8 *in); void conv_ARGB1555_from_RGB555(uint8 *out, uint8 *in);
void conv_RGBA5551_from_ARGB1555(uint8 *out, uint8 *in); void conv_RGBA5551_from_ARGB1555(uint8 *out, uint8 *in);
void conv_ARGB1555_from_RGBA5551(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_RGBA8888_from_ARGB1555(uint8 *out, uint8 *in);
void conv_ABGR1555_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; } inline void conv_8_from_8(uint8 *out, uint8 *in) { *out = *in; }