读书人

急如果小弟我用Graphics绘制好图后要如

发布时间: 2011-12-30 23:30:45 作者: rapoo

急!!!!如果我用Graphics绘制好图后要怎么打印呢!?
如题,在CS下,怎么实现

[解决办法]
用PrintDocument对象,注册其PrintPage事件,使用PrintPageEventArgs中包含的Graphics进行绘制。最后调用PrintDocument的Print方法打印。在此之前,需要设置PrintDocument的PrinterSettings属性,设置打印相关的信息。可以使用PrintDialog进行配置。
[解决办法]
int height = System.Windows.Forms.SystemInformation.CaptionHeight;
Bitmap bit = new Bitmap(this.Width , this.Height);
this.DrawToBitmap(bit, new Rectangle(0,0,this.Width ,this.Height));

Bitmap b = new Bitmap(bit.Width, bit.Height - height);
Graphics g = Graphics.FromImage(b);
g.DrawImage(bit, new Rectangle(0, 0, b.Width, b.Height), new Rectangle(0, height, bit.Width, bit.Height - height), GraphicsUnit.Pixel);
b.Save( "D:\\a.bmp ");
bit.Dispose();
b.Dispose();

[解决办法]
路过..接分.学习...
[解决办法]
顶了
[解决办法]
也顶
[解决办法]
没做过

[解决办法]
再学习
[解决办法]
假如你的画图方法:
paint(Graphics g){
//画图;
}

你只要在printdocument的print方法中
private void pdEditor_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
paint(e.Graphics);
e.HasMorePages = true;
}

读书人网 >C#

热点推荐