From b841473a0bd4a1a74a0b64f1ec2ab199035c349f Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sun, 6 Jul 2025 15:22:25 +0200 Subject: [PATCH] png: libpng is straight alpha, but cairo is premult ref #23 --- src/image/formats/Png.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/image/formats/Png.cpp b/src/image/formats/Png.cpp index e31cdd8..914d797 100644 --- a/src/image/formats/Png.cpp +++ b/src/image/formats/Png.cpp @@ -111,6 +111,10 @@ static std::expected loadPNG(png_structp png, png uint8_t g = rawData[i + 1]; uint8_t b = rawData[i + 2]; uint8_t a = rawData[i + 3]; + + r *= ((float)a) / 255.F; + g *= ((float)a) / 255.F; + b *= ((float)a) / 255.F; *(uint32_t*)&rawData[i] = (a << 24) | (r << 16) | (g << 8) | b; }