[Common] Abstract out the decode5A3Image and decodeCI8Image functions in BannerLoaderGC, BannerLoaderWii, and GCMemcard into ColorUtil.cpp. Makes for less copied code and remains functionally the same.

This commit is contained in:
Lioncash
2013-10-02 18:18:54 -04:00
parent b1268bfcd2
commit 1ec4894bc5
7 changed files with 50 additions and 89 deletions

View File

@ -103,7 +103,7 @@ std::vector<u32> CBannerLoaderWii::GetBanner(int* pWidth, int* pHeight)
SWiiBanner* pBanner = (SWiiBanner*)m_pBannerFile;
std::vector<u32> Buffer;
Buffer.resize(192 * 64);
decode5A3image(&Buffer[0], (u16*)pBanner->m_BannerTexture, 192, 64);
ColorUtil::decode5A3image(&Buffer[0], (u16*)pBanner->m_BannerTexture, 192, 64);
*pWidth = 192;
*pHeight = 64;
return Buffer;
@ -153,22 +153,4 @@ std::vector<std::string> CBannerLoaderWii::GetDescriptions()
return result;
}
void CBannerLoaderWii::decode5A3image(u32* dst, u16* src, int width, int height)
{
for (int y = 0; y < height; y += 4)
{
for (int x = 0; x < width; x += 4)
{
for (int iy = 0; iy < 4; iy++, src += 4)
{
for (int ix = 0; ix < 4; ix++)
{
u32 RGBA = ColorUtil::Decode5A3(Common::swap16(src[ix]));
dst[(y + iy) * width + (x + ix)] = RGBA;
}
}
}
}
}
} // namespace