Fix a coloring bug on mono. If we colorize a transparent area, it leaks through. This messes up the coloring on the VPN puzzles. Only colorize non-transparent areas of an image.

This commit is contained in:
Tim Young 2017-06-21 11:05:33 -05:00
parent efd3f26431
commit 30f21dc71d

View File

@ -657,21 +657,26 @@ namespace EduNetworkBuilder
if (PowerOff)
{
byte bcol = data[i];
byte gcol = data[i + 1];
byte rcol = data[i + 2];
byte bcol = data[i]; //This is the blue color
byte gcol = data[i + 1]; //this is the green color
byte rcol = data[i + 2]; //This is the red color
byte acol = data[i + 3]; //this is the transparency
//Check to see if it is green. If so, we make it mostly not-green.
if (rcol == 70 && gcol == 217 && bcol == 31)
data[i + 1] = 0; //set green to none
}
//data[i] is the first of 3 bytes of color
if (MorphColor != Color.Empty)
{
if (data[i + 3] != 0) //We only change the color if it is not transparent.
{
data[i] = (byte)((data[i] + MorphColor.B) / 2);
data[i + 1] = (byte)((data[i + 1] + MorphColor.G) / 2);
data[i + 2] = (byte)((data[i + 2] + MorphColor.R) / 2);
}
}
}
/* This override copies the data back into the location specified */
System.Runtime.InteropServices.Marshal.Copy(data, 0, bData.Scan0, data.Length);