fix indexing again, because apparently I'm bad at math now?
This commit is contained in:
parent
a3b8546ec8
commit
496c438be2
|
@ -219,15 +219,17 @@ namespace StardewModdingAPI.Framework.Content
|
||||||
// merge pixels
|
// merge pixels
|
||||||
for (int i = startIndex; i <= endIndex; i++)
|
for (int i = startIndex; i <= endIndex; i++)
|
||||||
{
|
{
|
||||||
|
int targetIndex = i - sourceoffset;
|
||||||
|
|
||||||
// ref locals here? Not sure.
|
// ref locals here? Not sure.
|
||||||
Color above = sourceData[i];
|
Color above = sourceData[i];
|
||||||
Color below = mergedData[i - sourceoffset];
|
Color below = mergedData[targetIndex];
|
||||||
|
|
||||||
// shortcut transparency
|
// shortcut transparency
|
||||||
if (above.A < MinOpacity)
|
if (above.A < MinOpacity)
|
||||||
continue;
|
continue;
|
||||||
if (below.A < MinOpacity || above.A == byte.MaxValue)
|
if (below.A < MinOpacity || above.A == byte.MaxValue)
|
||||||
mergedData[i] = above;
|
mergedData[targetIndex] = above;
|
||||||
|
|
||||||
// merge pixels
|
// merge pixels
|
||||||
else
|
else
|
||||||
|
@ -236,7 +238,7 @@ namespace StardewModdingAPI.Framework.Content
|
||||||
// premultiplied by the content pipeline. The formula is derived from
|
// premultiplied by the content pipeline. The formula is derived from
|
||||||
// https://blogs.msdn.microsoft.com/shawnhar/2009/11/06/premultiplied-alpha/.
|
// https://blogs.msdn.microsoft.com/shawnhar/2009/11/06/premultiplied-alpha/.
|
||||||
float alphaBelow = 1 - (above.A / 255f);
|
float alphaBelow = 1 - (above.A / 255f);
|
||||||
mergedData[i] = new Color(
|
mergedData[targetIndex] = new Color(
|
||||||
r: (int)(above.R + (below.R * alphaBelow)),
|
r: (int)(above.R + (below.R * alphaBelow)),
|
||||||
g: (int)(above.G + (below.G * alphaBelow)),
|
g: (int)(above.G + (below.G * alphaBelow)),
|
||||||
b: (int)(above.B + (below.B * alphaBelow)),
|
b: (int)(above.B + (below.B * alphaBelow)),
|
||||||
|
|
Loading…
Reference in New Issue