请问:怎样在Paint以外的函数画线?
我在其它函数里定义不了PaintEventArgs e,画不了线!应该怎么做才画得了?大家帮帮忙!
2008-09-02 13:21
程序代码:
using System.Drawing;
private void button1_Click(object sender, EventArgs e)
{
Graphics g = CreateGraphics();
Pen pen = new Pen(Color.Red, 1);
g.DrawLine(pen, 50,50,100,100);
pen.Dispose();
g.Dispose();
}
2008-09-02 13:26
2008-09-02 13:47
Graphics g = CreateGraphics();//System.Drawing.Graphics g = this.CreateGraphics();
g.Clear(Color.White);
2008-09-02 13:53
2008-09-02 14:07
程序代码: Bitmap bmp = new Bitmap("1.bmp");
PixelFormat format = bmp.PixelFormat;
RectangleF cloneRect = new RectangleF(50, 50, 10, 10);// 取图片的一块
Bitmap pic = bmp.Clone(cloneRect, format);
Graphics g = CreateGraphics();
g.DrawImage(pic, 50, 50, pic.Width, pic.Height,GraphicsUnit.Pixel, null);
// 在50,50的位置上贴 pic,注意最后一个属性为 ImageAttributes 对象的透明色,也就是 pic 的透明度
2008-09-02 14:43
2008-09-02 14:59
2008-09-02 15:34
2008-09-02 15:42
2008-09-02 15:51