예제 #1
0
        public static Bitmap CreateCharacterSetBitmap(Font font, string characters, List <object> pensAndBrushes, out System.Xml.XmlDocument doc)
        {
            //TODO: not an Xml doc, return a Endogine.Node instead! where node.Name = character
            Bitmap[] bitmaps = FontGenerator.Generate(font, characters, pensAndBrushes);

            string[] names = new string[bitmaps.Length];
            for (int i = 0; i < characters.Length; i++)
            {
                names[i] = ((int)characters[i]).ToString();
            }
            ERectangle[] rects;
            EPoint[]     offsets;
            Bitmap       bmpLarge = Endogine.BitmapHelpers.TexturePacking.TreePack(bitmaps, out rects, out offsets);       //.PackBitmapsIntoOneLarge(trimmedBmps, null, out node);

            doc = Endogine.BitmapHelpers.TexturePacking.CreateDocFromRectsAndOffsets(rects, offsets, names);
            return(bmpLarge);
        }
예제 #2
0
        public static Dictionary <char, int[, ]> CreatePicRefs(Font font, string characters, List <object> pensAndBrushes)
        {
            Bitmap[]     bitmaps = FontGenerator.Generate(font, characters, pensAndBrushes);
            ERectangle[] rects;
            EPoint[]     offsets;

            Bitmap bmpLarge = Endogine.BitmapHelpers.TexturePacking.TreePack(bitmaps, out rects, out offsets);             //.PackBitmapsIntoOneLarge(trimmedBmps, null, out node);

            Dictionary <char, int[, ]> profiles = new Dictionary <char, int[, ]>();

            for (int i = 0; i < bitmaps.Length; i++)
            {
                Bitmap bmp = bitmaps[i];
                int[,] profile = GetProfile(bmp);
                profiles.Add(characters[i], profile);
            }

            MemberSpriteBitmap mb   = new MemberSpriteBitmap(bmpLarge);
            string             name = GetPrefix(font);

            mb.Name = name;

            string[] names = new string[characters.Length];
            for (int i = 0; i < characters.Length; i++)
            {
                names[i] = ((int)characters[i]).ToString();
            }

            //bmpLarge.Save("_fonttest.png");
            //Endogine.BitmapHelpers.TexturePacking.CreateDocFromRectsAndOffsets(rects, offsets, names).Save("_fonttest.xml");

            for (int i = 0; i < bitmaps.Length; i++)
            {
                PicRef pic = new PicRef(name + "_" + characters.Substring(i, 1), mb);
                pic.Offset          = new EPoint(0, offsets[i].Y);       //Ignore the X offset
                pic.SourceRectangle = rects[i];
                //EH.Instance.CastLib.Pictures.AddPicture(pic);
            }

            return(profiles);
        }