Better handling of BGRA8 dds saving and loading

This commit is contained in:
baldurk
2016-08-19 17:36:36 +02:00
parent 79b860c1d5
commit 8183c0d2ac
+8 -1
View File
@@ -734,7 +734,8 @@ bool write_dds_to_file(FILE *f, const dds_data &data)
// special case a couple of formats to write out non-DX10 style, for
// backwards compatibility
if(data.format.compByteWidth == 1 && data.format.compCount == 4)
if(data.format.compByteWidth == 1 && data.format.compCount == 4 &&
data.format.compType == eCompType_UNorm)
{
header.ddspf.dwFlags = DDPF_RGBA;
header.ddspf.dwRGBBitCount = 32;
@@ -742,6 +743,9 @@ bool write_dds_to_file(FILE *f, const dds_data &data)
header.ddspf.dwGBitMask = 0x0000ff00;
header.ddspf.dwBBitMask = 0x00ff0000;
header.ddspf.dwABitMask = 0xff000000;
if(data.format.bgraOrder)
std::swap(header.ddspf.dwRBitMask, header.ddspf.dwBBitMask);
}
else if(data.format.specialFormat == eSpecial_BC1)
{
@@ -956,6 +960,9 @@ dds_data load_dds_from_file(FILE *f)
ret.format.compCount = header.ddspf.dwRGBBitCount / 8;
ret.format.compType = eCompType_UNorm;
ret.format.special = false;
if(header.ddspf.dwBBitMask < header.ddspf.dwRBitMask)
ret.format.bgraOrder = true;
}
uint32_t bytesPerPixel = 1;