I fixed the problem in an other way now.
VideoDriver::writeImageToFile has a parameter param. This is not used for png writing.
I now adapted the png writer, so that it does a conversion from RGBA8888 to RGB888 when param is 1.
Now the screenshots look correctly.
If needed, I can provide a patch for Irrlicht, so that this feature is in the upcoming releases.
But I have one further question:
Code: Select all
void CColorConverter::convert_A8R8G8B8toR8G8B8(const void* sP, s32 sN, void* dP)
{
u8* sB = (u8*)sP;
u8* dB = (u8*)dP;
for (s32 x = 0; x < sN; ++x)
{
// sB[3] is alpha
dB[0] = sB[2];
dB[1] = sB[1];
dB[2] = sB[0];
sB += 4;
dB += 3;
}
}
void CColorConverter::convert_A8R8G8B8toB8G8R8(const void* sP, s32 sN, void* dP)
{
u8* sB = (u8*)sP;
u8* dB = (u8*)dP;
for (s32 x = 0; x < sN; ++x)
{
// sB[3] is alpha
dB[0] = sB[0];
dB[1] = sB[1];
dB[2] = sB[2];
sB += 4;
dB += 3;
}
}
In the color converter RGB and BGR seems to be flipped (see code). But the conversion works as the function name tells.
Can anyone explain me that RGB<->BGR flip?