From 5c694b082edece97738c3d7206497fb7be042284 Mon Sep 17 00:00:00 2001 From: totaam Date: Sat, 26 Nov 2022 15:26:11 +0700 Subject: [PATCH] #3374 spng uses unpremultiplied alpha --- xpra/codecs/spng/encoder.pyx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xpra/codecs/spng/encoder.pyx b/xpra/codecs/spng/encoder.pyx index 0629a89731..3efc82d5ca 100644 --- a/xpra/codecs/spng/encoder.pyx +++ b/xpra/codecs/spng/encoder.pyx @@ -10,6 +10,7 @@ log = Logger("decoder", "spng") from xpra.net.compression import Compressed from xpra.codecs.codec_debug import may_save_image +from xpra.codecs.argb.argb import unpremultiply_argb from xpra.codecs.spng.spng cimport ( SPNG_VERSION_MAJOR, SPNG_VERSION_MINOR, SPNG_VERSION_PATCH, SPNG_CTX_ENCODER, @@ -78,11 +79,13 @@ def encode(coding, image, options=None): rgb_format = image.get_pixel_format() alpha = options.get("alpha", rgb_format.find("A")>=0) - if rgb_format not in INPUT_FORMATS or (resize and len(rgb_format)!=4) or rowstride!=width*len(rgb_format) or grayscale: + if rgb_format not in INPUT_FORMATS or (resize and len(rgb_format)!=4) or rowstride!=width*len(rgb_format) or grayscale or alpha: #best to restride before byte-swapping to trim extra unused data: if rowstride!=width*len(rgb_format): image.restride(width*len(rgb_format)) input_formats = INPUT_FORMATS + if alpha: + image.set_pixels(unpremultiply_argb(image.get_pixels())) if grayscale: input_formats = ("BGRX", "BGRA", "BGR", "RGB") if rgb_format not in input_formats: