Skip to content

Commit

Permalink
Don't multiply alpha when blending onto a transparent pixel (OpenDrea…
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmeow authored Jan 1, 2024
1 parent a9bf040 commit 94ceaba
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions OpenDreamRuntime/Objects/DreamIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 94ceaba

Please sign in to comment.