public ActionResult GlyphToIcon(string code, string pinColor, string glyphColor, string backgroundColor, int squaredSize, bool pinOnly)
        {
            var post = new ExGlyphDataPost
            {
                GlyphColor      = ColorTranslator.FromHtml(glyphColor),
                FontCode        = char.ConvertFromUtf32(Convert.ToUInt16(code, 16)),
                FontCodeNumber  = code,
                PinColor        = ColorTranslator.FromHtml(pinColor),
                PinOnly         = pinOnly,
                SquaredSize     = squaredSize,
                BackgroundColor = ColorTranslator.FromHtml(backgroundColor),
            };

            var result = GlyphConverter.GetGlyph(post);

            return(File(result.ImageData, "image/png"));
        }
        /// <summary>
        ///     Glyph laden und bei bedarf erzeugen
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static ExGlyphData GetGlyph(ExGlyphDataPost data)
        {
            var result = new ExGlyphData();

            result.ImageUri = Constants.ServiceClientEndPointWithApiPrefix + nameof(ShopController.GlyphToIcon) + $"/{data.FontCodeNumber}" +
                              $"/{data.PinColor.ToArgb()}" +
                              $"/{data.GlyphColor.ToArgb()}" +
                              $"/{data.BackgroundColor.ToArgb()}" +
                              $"/{data.SquaredSize}" +
                              $"/{data.PinOnly}";

            string fileName;

            if (data.PinOnly)
            {
                fileName = $"Pin{data.PinColor.ToArgb()}_{data.SquaredSize}.png";
            }
            else
            {
                fileName = $"Pin{data.GlyphColor.ToArgb()}_{data.PinColor.ToArgb()}_{data.BackgroundColor.ToArgb()}_{data.FontCode.Trim()}_{data.SquaredSize}.png";
            }

            result.Name = fileName;
            string localFile = Path.Combine(AppContext.BaseDirectory, "Images", fileName);

            if (File.Exists(localFile))
            {
                result.ImageData = File.ReadAllBytes(localFile);

                return(result);
            }

            Bitmap image;

            if (data.PinOnly)
            {
                image = GetColoredPin(data.PinColor, data.SquaredSize);
            }
            else
            {
                string fontFamiliesFileName = Path.Combine("Resources", "DigitalShopping.ttf");
                var    fontfamily           = GetFontFamilyFromFile("DigitalShopping", fontFamiliesFileName);
                image = GeneratePin(data.PinColor, data.FontCode, fontfamily, data.GlyphColor, data.BackgroundColor, data.SquaredSize);
            }

            // Nochmal checken, ob nicht in der Zwischenzeit ein anderer Thread das Bild erzeugt hat
            if (File.Exists(localFile))
            {
                result.ImageData = File.ReadAllBytes(localFile);

                return(result);
            }

            try
            {
                image.Save(localFile);
                using (var stream = new MemoryStream())
                {
                    image.Save(stream, ImageFormat.Png);
                    result.ImageData = stream.ToArray();
                }
            }
            catch (Exception e)
            {
                Logging.Log.LogError($"Fehler beim erzeugen des Glyphs! {e}");
            }

            if (!File.Exists(localFile))
            {
                using (var stream = new MemoryStream())
                {
                    image.Save(stream, ImageFormat.Png);
                    result.ImageData = stream.ToArray();
                }
            }

            return(result);
        }