开发者

Help with GDI+ image drawing

I've recently taken my first step into GDI+, and am trying to draw an image from a bitmap. The code I have is this:

using System.Drawing;
using System.Drawing.Drawing2D;

namespace Windowstuffs
{
    class AnimEngine : Form
    {
        public Graphics X;
        public Bitmap Y = new Bitmap(/* File Path */);

       void draw(object sender, PaintEventArgs e)
        {
            Bitmap Y = new Bitmap(/* File Path */);
            e.Graphics.DrawImage(Y, 0, 0);
            return;
        }

       public static void Main()
        {

            AnimEngine f1 = new AnimEngine();
            Application.Run(f1);
            f1.Paint += new PaintEventHandler(f1.draw);
            f1.Refresh();
            return;
        }

    }
}

It compiles just fine, however, it doesn't draw anything. Everything else is completely functional, and after searchin开发者_如何学编程g through MSDN and various tutorials, I still cannot find what I did wrong.

Thank you for your help.


public static void Main()
{

    AnimEngine f1 = new AnimEngine();
    f1.Paint += new PaintEventHandler(f1.draw);
    Application.Run(f1);
    f1.Refresh();
    return;
}

Just put the event subscription line above the Application.Run(f1) line :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜