mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-14 08:30:49 +00:00
Fixed alpha channel issue with textures
This commit is contained in:
parent
38aba81dcc
commit
e72a032a11
2 changed files with 9 additions and 3 deletions
|
@ -724,8 +724,9 @@ void FPNGTexture::MakeTextureBgra ()
|
||||||
{
|
{
|
||||||
for (y = Height; y > 0; --y)
|
for (y = Height; y > 0; --y)
|
||||||
{
|
{
|
||||||
|
// output as premultiplied alpha
|
||||||
uint32_t alpha = in[1];
|
uint32_t alpha = in[1];
|
||||||
uint32_t gray = in[0];
|
uint32_t gray = (in[0] * alpha + 127) / 255;
|
||||||
*out++ = (alpha << 24) | (gray << 16) | (gray << 8) | gray;
|
*out++ = (alpha << 24) | (gray << 16) | (gray << 8) | gray;
|
||||||
in += pitch;
|
in += pitch;
|
||||||
}
|
}
|
||||||
|
@ -740,7 +741,12 @@ void FPNGTexture::MakeTextureBgra ()
|
||||||
{
|
{
|
||||||
for (y = Height; y > 0; --y)
|
for (y = Height; y > 0; --y)
|
||||||
{
|
{
|
||||||
*out++ = (((uint32_t)in[3]) << 24) | (((uint32_t)in[0]) << 16) | (((uint32_t)in[1]) << 8) | ((uint32_t)in[2]);
|
// output as premultiplied alpha
|
||||||
|
uint32_t alpha = in[3];
|
||||||
|
uint32_t red = (in[0] * alpha + 127) / 255;
|
||||||
|
uint32_t green = (in[1] * alpha + 127) / 255;
|
||||||
|
uint32_t blue = (in[2] * alpha + 127) / 255;
|
||||||
|
*out++ = (alpha << 24) | (red << 16) | (green << 8) | blue;
|
||||||
in += pitch;
|
in += pitch;
|
||||||
}
|
}
|
||||||
in -= backstep;
|
in -= backstep;
|
||||||
|
|
|
@ -203,7 +203,7 @@ const uint32_t *FTexture::GetPixelsBgra()
|
||||||
PixelsBgra.resize(Width * Height);
|
PixelsBgra.resize(Width * Height);
|
||||||
for (int i = 0; i < Width * Height; i++)
|
for (int i = 0; i < Width * Height; i++)
|
||||||
{
|
{
|
||||||
PixelsBgra[i] = GPalette.BaseColors[indices[i]].d;
|
PixelsBgra[i] = 0xff000000 | GPalette.BaseColors[indices[i]].d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return PixelsBgra.data();
|
return PixelsBgra.data();
|
||||||
|
|
Loading…
Reference in a new issue