C# 绘图保存问题!!!
现在我绘好了一张图片,这张图片上有很多文字,这些文字是用label控件写上去的,而不是绘图绘上去的,问题就是我如何把这些文字和图形一起保存成为一张图片?
[最优解释]
使用你容器..或则窗体的DrawToBitmap方法看看.
[其他解释]
DrawToBitmap就可以得到Bitmap,Bitmap可以Save成为jpg,png等等,就保存下来了,至于要打印什么的,可以直接打印界面,可以打印bitmap。自己多看书,别懒。
[其他解释]
利用 DrawToBitmap 保存成位图,再把位图打印不就行了。
[其他解释]
帮顶。
楼上的哥们咱能不能换换头像?
每次看到感觉很不好。
哎~~
[其他解释]
这样子写就可以了
Bitmap bitmap;
private void Form1_Load(object sender, EventArgs e)
{
bitmap = new Bitmap(pictureBox1.Width,pictureBox1.Height);
pictureBox1.DrawToBitmap(bitmap, new Rectangle(0, 0, pictureBox1.Width, pictureBox1.Height));
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
pd.Print();
}
void pd_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawImage(bitmap,0,0);
}
Bitmap bitmap;
private void button10_Click(object sender, EventArgs e)
{
bitmap = new Bitmap(picMain.Width, picMain.Height);
picMain.DrawToBitmap(bitmap, new Rectangle(0, 0, picMain.Width, picMain.Height));
//bitmap.Save("E:\\1.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
pd.Print();
}
void pd_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawImage(bitmap, 0, 0);
}