示例#1
0
        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            pipeline.Begin();
            if (skeleton != null && checkBox1.Checked)
            {
                skeletonAnimation.Apply(skeleton);
                GdiRenderer.Draw(skeleton, pipeline);
            }
            e.Graphics.ResetTransform();
            e.Graphics.TranslateTransform(Center.X, Center.Y);
            e.Graphics.ScaleTransform(Zoom, -Zoom);
            pipeline.End(e.Graphics);

            e.Graphics.ResetTransform();
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            checkBox1.Checked = false;
            foreach (var a in mSkeletonData.Animations)
            {
                skeletonAnimation.SetAnimation(0, a.Name, false);
                float  interval = 1f / 30f;
                int    frameNum = (int)(a.Duration / interval);
                int    pos      = 0;
                string dir      = ".\\output\\" + a.Name;
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
                for (int i = 0; i < frameNum; i++)
                {
                    string path = dir + "\\" + pos + ".png";
                    skeletonAnimation.Update(interval);
                    skeletonAnimation.Apply(skeleton);
                    pipeline.Begin();
                    Bitmap   img = new Bitmap(panel1.Width, panel1.Height);
                    Graphics g   = Graphics.FromImage(img);
                    if (skeleton != null)
                    {
                        skeletonAnimation.Apply(skeleton);
                        GdiRenderer.Draw(skeleton, pipeline);
                    }
                    g.ResetTransform();
                    g.TranslateTransform(Center.X, Center.Y);
                    g.ScaleTransform(Zoom, -Zoom);
                    pipeline.End(g);

                    g.ResetTransform();
                    g.Dispose();

                    Bitmap   imgScaled = new Bitmap((int)(img.Width / 1.6), (int)(img.Height / 1.6));
                    Graphics g2        = Graphics.FromImage(imgScaled);
                    g2.DrawImage(img, new Rectangle(0, 0, imgScaled.Width, imgScaled.Height));
                    g2.Dispose();
                    imgScaled.Save(path);
                    pos++;
                }
            }
        }