From 94ceabacf03c8fc04ff71a4199e8d1db2710dcfd Mon Sep 17 00:00:00 2001 From: itsmeow Date: Mon, 1 Jan 2024 01:23:26 -0500 Subject: [PATCH] Don't multiply alpha when blending onto a transparent pixel (#1577) --- OpenDreamRuntime/Objects/DreamIcon.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/OpenDreamRuntime/Objects/DreamIcon.cs b/OpenDreamRuntime/Objects/DreamIcon.cs index ec954527c9..4d8320433c 100644 --- a/OpenDreamRuntime/Objects/DreamIcon.cs +++ b/OpenDreamRuntime/Objects/DreamIcon.cs @@ -333,6 +333,14 @@ protected void BlendPixel(Rgba32[] pixels, int dstPixelPosition, Rgba32 src) { } case BlendType.Overlay: { + // When overlaying onto 0 alpha, don't multiply the RGB values by alpha. + if (dst.A == 0) { + pixels[dstPixelPosition].R = src.R; + pixels[dstPixelPosition].G = src.G; + pixels[dstPixelPosition].B = src.B; + pixels[dstPixelPosition].A = src.A; + break; + } pixels[dstPixelPosition].R = (byte) (dst.R + (src.R - dst.R) * src.A / 255); pixels[dstPixelPosition].G = (byte) (dst.G + (src.G - dst.G) * src.A / 255); pixels[dstPixelPosition].B = (byte) (dst.B + (src.B - dst.B) * src.A / 255);