mirror of
https://github.com/yuzu-emu/FasTC
synced 2024-11-22 22:53:39 +00:00
Add option to flip image along Y-axis to accomodate different image formats.
This commit is contained in:
parent
baced12633
commit
5d93d4d7e9
3 changed files with 10 additions and 7 deletions
|
@ -94,7 +94,7 @@ class ImageLoader {
|
|||
|
||||
uint32 GetChannelForPixel(uint32 x, uint32 y, uint32 ch);
|
||||
|
||||
bool LoadFromPixelBuffer(uint32 *data);
|
||||
bool LoadFromPixelBuffer(uint32 *data, bool flipY = false);
|
||||
|
||||
public:
|
||||
virtual ~ImageLoader() {
|
||||
|
|
|
@ -137,7 +137,7 @@ unsigned int ImageLoader::GetChannelForPixel(uint32 x, uint32 y, uint32 ch) {
|
|||
return val;
|
||||
}
|
||||
|
||||
bool ImageLoader::LoadFromPixelBuffer(uint32 *data) {
|
||||
bool ImageLoader::LoadFromPixelBuffer(uint32 *data, bool flipY) {
|
||||
m_RedChannelPrecision = 8;
|
||||
m_GreenChannelPrecision = 8;
|
||||
m_BlueChannelPrecision = 8;
|
||||
|
@ -152,11 +152,14 @@ bool ImageLoader::LoadFromPixelBuffer(uint32 *data) {
|
|||
for (uint32 i = 0; i < m_Width; i++) {
|
||||
for (uint32 j = 0; j < m_Height; j++) {
|
||||
uint32 idx = j*m_Height + i;
|
||||
uint32 pIdx = idx;
|
||||
if(flipY)
|
||||
idx = (m_Height - j - 1)*m_Height + i;
|
||||
uint32 pixel = data[idx];
|
||||
m_RedData[idx] = pixel & 0xFF;
|
||||
m_GreenData[idx] = (pixel >> 8) & 0xFF;
|
||||
m_BlueData[idx] = (pixel >> 16) & 0xFF;
|
||||
m_AlphaData[idx] = (pixel >> 24) & 0xFF;
|
||||
m_RedData[pIdx] = pixel & 0xFF;
|
||||
m_GreenData[pIdx] = (pixel >> 8) & 0xFF;
|
||||
m_BlueData[pIdx] = (pixel >> 16) & 0xFF;
|
||||
m_AlphaData[pIdx] = (pixel >> 24) & 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,6 @@ bool ImageLoaderTGA::ReadData() {
|
|||
|
||||
assert(static_cast<uint32>(tga.imageLength) == m_Width * m_Height * 4);
|
||||
|
||||
return LoadFromPixelBuffer(reinterpret_cast<uint32 *>(tga.image));
|
||||
return LoadFromPixelBuffer(reinterpret_cast<uint32 *>(tga.image), true);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue