FSO.Client.UI.Framework.UIElement.ManualTextureMask C# (CSharp) Method

ManualTextureMask() protected method

Manually replaces a specified color in a texture with transparent black, thereby masking it.
protected ManualTextureMask ( Microsoft.Xna.Framework.Graphics.Texture2D &Texture, Color ColorFrom ) : void
Texture Microsoft.Xna.Framework.Graphics.Texture2D The texture on which to apply the mask.
ColorFrom Color The color to mask away.
return void
        protected void ManualTextureMask(ref Texture2D Texture, Color ColorFrom)
        {
            Color ColorTo = Color.Transparent;

            Color[] data = new Color[Texture.Width * Texture.Height];
            Texture.GetData(data);

            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] == ColorFrom)
                    data[i] = ColorTo;
            }

            Texture.SetData(data);
        }