2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 17:44:56 +00:00

Fix IA4 encoding/decoding

This commit is contained in:
2019-02-11 17:58:12 -08:00
parent a28a7e9500
commit c1c22eb065
10 changed files with 319 additions and 29 deletions

View File

@@ -238,8 +238,8 @@ static void DecodeIA4(png_structp png, png_infop info, const uint8_t* texels, in
for (int y = height - 1; y >= 0; --y) {
for (int x = 0; x < width; ++x) {
uint8_t texel = Lookup8BPP(texels, width, x, y);
buf[x * 2] = Convert4To8(texel >> 4 & 0xf);
buf[x * 2 + 1] = Convert4To8(texel & 0xf);
buf[x * 2 ] = Convert4To8(texel & 0xf);
buf[x * 2 + 1] = Convert4To8(texel >> 4 & 0xf);
}
png_write_row(png, buf.get());
}
@@ -252,8 +252,8 @@ static void EncodeIA4(const uint8_t* rgbaIn, uint8_t* texels, int width, int hei
{
for (int x=0 ; x<width ; ++x)
{
uint8_t texel = Convert8To4(rgbaIn[x*2]) << 4;
texel |= Convert8To4(rgbaIn[x*2+1]);
uint8_t texel = Convert8To4(rgbaIn[x*2+1]) << 4;
texel |= Convert8To4(rgbaIn[x*2]);
Set8BPP(texels, width, x, y, texel);
rgbaIn += width * 2;
}