Exemplo n.º 1
0
        public bool Close()
        {
            if (edited)
            {
                var result = MessageBox.Show("Save changes?", "Saving", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);

                if (result == MessageBoxResult.Yes)
                {
                    fnt.SetGlyphRect(GlyphCuts.Select(x => new System.Drawing.Rectangle(x.Left, x.Top, x.Right - x.Left, x.Bottom - x.Top)).ToArray());
                    return(true);
                }
                else if (result == MessageBoxResult.No)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }
Exemplo n.º 2
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]));
            }
        }
Exemplo n.º 3
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));
                }
            }
        }