Exemplo n.º 1
0
        private void LoadFromBitmap(string textureKey, Bitmap bitmap, TextureProperties properties = default)
        {
            using (var stream = new MemoryStream())
            {
                if (properties.Rounded)
                {
                    bitmap = bitmap.Round(this.textureRoundRatio.GetRatio(textureKey));
                }
                else if (properties.Squared)
                {
                    bitmap = bitmap.Square();
                }

                if (!properties.ColorRatio.IsZero)
                {
                    bitmap = bitmap.AdjustColor(properties.ColorRatio);
                }

                if (properties.Brightness != 0)
                {
                    bitmap = bitmap.AdjustBrightness(properties.Brightness);
                }

                bitmap.Save(stream, ImageFormat.Png);
                bitmap.Dispose();

                this.LoadFromStream(textureKey, stream);
            }
        }