loaders: decode the image with premultiplied alpha.

basically, the renderer requires images with premultiplied alpha.
This commit is contained in:
Hermet Park 2024-02-07 11:54:07 +09:00
parent ccb5a5d1fb
commit 886b6b365b
5 changed files with 7 additions and 5 deletions

View file

@ -104,6 +104,7 @@ bool PngLoader::read()
surface.h = (uint32_t)h;
surface.channelSize = sizeof(uint32_t);
surface.cs = ColorSpace::ARGB8888;
//TODO: we can acquire a pre-multiplied image. See "png_structrp"
surface.premultiplied = false;
clear();

View file

@ -33,9 +33,8 @@
void WebpLoader::run(unsigned tid)
{
//TODO: acquire the current colorspace format & pre-multiplied alpha image.
surface.buf8 = WebPDecodeBGRA(data, size, nullptr, nullptr);
//setup the surface
surface.stride = (uint32_t)w;
surface.w = (uint32_t)w;
surface.h = (uint32_t)h;

View file

@ -44,7 +44,9 @@ void PngLoader::run(unsigned tid)
surface.w = width;
surface.h = height;
surface.channelSize = sizeof(uint32_t);
surface.premultiplied = false;
if (state.info_png.color.colortype == LCT_RGBA) surface.premultiplied = false;
else surface.premultiplied = true;
}

View file

@ -651,7 +651,7 @@ int WebPIoInitFromOptions(const WebPDecoderOptions* const options,
uint8_t* WebPDecodeBGRA(const uint8_t* data, size_t data_size,
int* width, int* height) {
return Decode(MODE_BGRA, data, data_size, width, height, NULL);
return Decode(MODE_bgrA, data, data_size, width, height, NULL);
}

View file

@ -42,7 +42,7 @@ void WebpLoader::run(unsigned tid)
surface.h = static_cast<uint32_t>(h);
surface.cs = ColorSpace::ARGB8888;
surface.channelSize = sizeof(uint32_t);
surface.premultiplied = false;
surface.premultiplied = true;
clear();
}