OnPaint绘制2个重叠的透明图像

时间:2016-03-20 18:44:53

标签: c# graphics onpaint

嗨我试图重叠2个图像与透明背景。我听说我可以用OnPaint方法做这个,所以我试过

    protected override void OnPaint(PaintEventArgs e)
    {
        System.Drawing.Graphics obj;
        obj = this.CreateGraphics();
        int x = 0;
        int y = 0;
        System.Drawing.Point point = new Point(x, y);
        obj.Clear(Color.White);
        obj.DrawImage(System.Drawing.Image.FromFile(@"C:\Users\William\Documents\Sprites\Player\Male\Default\Light.png"), point);
        obj.Dispose();
    }

但我不确定如何在它上面绘制另一个,如果它是透明的,任何帮助都是适当的

1 个答案:

答案 0 :(得分:0)

只需在第一张图片的顶部绘制另一张图片,就像这样:

e.Graphics.DrawImage(Image.FromFile(@"C:\Picture1.png"), point);
e.Graphics.DrawImage(Image.FromFile(@"C:\Picture2WithTransparentBackground.png"), point);
相关问题