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,9 +657,11 @@ namespace EduNetworkBuilder
if (PowerOff) if (PowerOff)
{ {
byte bcol = data[i]; byte bcol = data[i]; //This is the blue color
byte gcol = data[i + 1]; byte gcol = data[i + 1]; //this is the green color
byte rcol = data[i + 2]; 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. //Check to see if it is green. If so, we make it mostly not-green.
if (rcol == 70 && gcol == 217 && bcol == 31) if (rcol == 70 && gcol == 217 && bcol == 31)
data[i + 1] = 0; //set green to none data[i + 1] = 0; //set green to none
@ -667,9 +669,12 @@ namespace EduNetworkBuilder
//data[i] is the first of 3 bytes of color //data[i] is the first of 3 bytes of color
if (MorphColor != Color.Empty) if (MorphColor != Color.Empty)
{ {
data[i] = (byte)((data[i] + MorphColor.B) / 2); if (data[i + 3] != 0) //We only change the color if it is not transparent.
data[i + 1] = (byte)((data[i + 1] + MorphColor.G) / 2); {
data[i + 2] = (byte)((data[i + 2] + MorphColor.R) / 2); 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);
}
} }
} }