Ejemplo n.º 1
0
        private void OpenFont()
        {
            var GlyphList   = fnt.Compressed.GetDecompressedData();
            var pallete     = new BitmapPalette(AuxiliaryLibraries.Media.ImageHelper.GetGrayPalette(8).Select(x => Color.FromArgb(x.A, x.R, x.G, x.B)).ToArray());
            var pixelFormat = PixelFormats.Indexed8;

            foreach (var glyph in GlyphList)
            {
                var image = BitmapSource.Create(fnt.Width, fnt.Height, 96, 96,
                                                pixelFormat, pallete, glyph.Skip(6).ToArray(),
                                                (pixelFormat.BitsPerPixel * fnt.Width + 7) / 8);
                image.Freeze();
                GlyphCuts.Add(new FNT0GlyphCut(image, glyph[0], glyph[0] + glyph[2], glyph[1], glyph[1] + glyph[3]));
            }
        }
Ejemplo n.º 2
0
        private void OpenFont()
        {
            var GlyphList = fnt.Compressed.GetDecompressedData();
            var CutList   = fnt.WidthTable.WidthTable;

            PixelFormat pixelFormat;

            if (fnt.Header.Glyphs.BitsPerPixel == 4)
            {
                pixelFormat = PixelFormats.Indexed4;
            }
            else if (fnt.Header.Glyphs.BitsPerPixel == 8)
            {
                pixelFormat = PixelFormats.Indexed8;
            }
            else
            {
                pixelFormat = PixelFormats.Default;
            }

            if (pixelFormat == PixelFormats.Indexed4)
            {
                ArrayTool.ReverseByteInList(GlyphList);
            }

            var pallete = new BitmapPalette(fnt.Palette.GetImagePalette().Select(x => Color.FromArgb(x.A, x.R, x.G, x.B)).ToArray());

            if (GlyphList.Count <= CutList.Count)
            {
                for (int i = 0; i < GlyphList.Count; i++)
                {
                    var image = BitmapSource.Create(fnt.Header.Glyphs.Size1,
                                                    fnt.Header.Glyphs.Size2,
                                                    96, 96, pixelFormat, pallete,
                                                    GlyphList[i],
                                                    (pixelFormat.BitsPerPixel * fnt.Header.Glyphs.Size2 + 7) / 8);
                    image.Freeze();
                    GlyphCuts.Add(new GlyphCut(image, CutList[i], i));
                }
            }
        }