From 30f21dc71df40c1767ca3e93e9fc74af44499b68 Mon Sep 17 00:00:00 2001 From: Tim Young Date: Wed, 21 Jun 2017 11:05:33 -0500 Subject: [PATCH] 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. --- EduNetworkBuilder/NetworkDevice.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/EduNetworkBuilder/NetworkDevice.cs b/EduNetworkBuilder/NetworkDevice.cs index 9addf6d..a2a666e 100644 --- a/EduNetworkBuilder/NetworkDevice.cs +++ b/EduNetworkBuilder/NetworkDevice.cs @@ -657,9 +657,11 @@ 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 @@ -667,9 +669,12 @@ namespace EduNetworkBuilder //data[i] is the first of 3 bytes of color if (MorphColor != Color.Empty) { - 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); + 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); + } } }