mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
loaders: decode the image with premultiplied alpha.
basically, the renderer requires images with premultiplied alpha.
This commit is contained in:
parent
ccb5a5d1fb
commit
886b6b365b
5 changed files with 7 additions and 5 deletions
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue