FSO.Files.ImageLoader.ManualTextureMaskSingleThreaded C# (CSharp) Method

ManualTextureMaskSingleThreaded() public static method

public static ManualTextureMaskSingleThreaded ( Microsoft.Xna.Framework.Graphics.Texture2D &Texture, uint ColorsFrom ) : void
Texture Microsoft.Xna.Framework.Graphics.Texture2D
ColorsFrom uint
return void
        public static void ManualTextureMaskSingleThreaded(ref Texture2D Texture, uint[] ColorsFrom)
        {
            var ColorTo = Microsoft.Xna.Framework.Color.Transparent.PackedValue;

            var size = Texture.Width * Texture.Height;
            uint[] buffer = new uint[size];

            Texture.GetData<uint>(buffer);

            var didChange = false;

            for (int i = 0; i < size; i++)
            {

                if (ColorsFrom.Contains(buffer[i]))
                {
                    didChange = true;
                    buffer[i] = ColorTo;
                }
            }

            if (didChange)
            {
                Texture.SetData(buffer, 0, size);
            }
            else return;
        }