From 496c438be244c6e51f34cbcf238913edf55a8618 Mon Sep 17 00:00:00 2001 From: atravita-mods <94934860+atravita-mods@users.noreply.github.com> Date: Tue, 23 Aug 2022 14:34:23 -0400 Subject: [PATCH] fix indexing again, because apparently I'm bad at math now? --- src/SMAPI/Framework/Content/AssetDataForImage.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/SMAPI/Framework/Content/AssetDataForImage.cs b/src/SMAPI/Framework/Content/AssetDataForImage.cs index f00d2d4c..2bbcc60c 100644 --- a/src/SMAPI/Framework/Content/AssetDataForImage.cs +++ b/src/SMAPI/Framework/Content/AssetDataForImage.cs @@ -219,15 +219,17 @@ namespace StardewModdingAPI.Framework.Content // merge pixels for (int i = startIndex; i <= endIndex; i++) { + int targetIndex = i - sourceoffset; + // ref locals here? Not sure. Color above = sourceData[i]; - Color below = mergedData[i - sourceoffset]; + Color below = mergedData[targetIndex]; // shortcut transparency if (above.A < MinOpacity) continue; if (below.A < MinOpacity || above.A == byte.MaxValue) - mergedData[i] = above; + mergedData[targetIndex] = above; // merge pixels else @@ -236,7 +238,7 @@ namespace StardewModdingAPI.Framework.Content // premultiplied by the content pipeline. The formula is derived from // https://blogs.msdn.microsoft.com/shawnhar/2009/11/06/premultiplied-alpha/. float alphaBelow = 1 - (above.A / 255f); - mergedData[i] = new Color( + mergedData[targetIndex] = new Color( r: (int)(above.R + (below.R * alphaBelow)), g: (int)(above.G + (below.G * alphaBelow)), b: (int)(above.B + (below.B * alphaBelow)),