读书人

C# 绘图保存有关问题!

发布时间: 2012-12-19 14:13:14 作者: rapoo

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);
}

[其他解释]
你的写法是对的,我测试过了,可以保存为bmp的。png没有测试。
Bitmap bmp = new Bitmap(picBoxMain.Width, picBoxMain.Height);
然后就是你写的那两行代码,不过最后我保存的bmp格式。
[其他解释]
DrawToBitmap 这个是呈现绘好的位图 我要的是打印功能,如何把上面的文字打印出来
[其他解释]
有没有更好的方法
[其他解释]
该回复于2011-02-18 10:56:06被版主删除
[其他解释]
该回复于2011-02-18 13:49:10被版主删除
[其他解释]
引用:
DrawToBitmap就可以得到Bitmap,Bitmap可以Save成为jpg,png等等,就保存下来了,至于要打印什么的,可以直接打印界面,可以打印bitmap。自己多看书,别懒。

不是吧,这个方法的返回值是void啊 怎么会得到bitmap
[其他解释]
this.picBoxMain.DrawToBitmap(bp, new Rectangle(new Point(0, 0), new Size(this.picBoxMain.Width, this.picBoxMain.Height)));
bp.Save("E:\\项目素材\\1.png", ImageFormat.Png);

难道像这样写,但是这样写的效果还是一样的.
[其他解释]
没人来,我自己顶!!!!------------------------->三次无法回复
[其他解释]
啊 13楼你头像好恐怖!!!12楼我先拿去测试一下
------其他解决方案--------------------


引用:
这样子写就可以了

C# code

Bitmap bitmap;
private void Form1_Load(object sender, EventArgs e)
{
bitmap = new Bitmap(pictureBox1.Width,pictureBox1.Height);
pict……

我把你的代码原封不动的复制下来,但是还是不行啊
下面是我的代码:
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);
}

[其他解释]


上面是图片,我怎么可以打印出那三个label
[其他解释]
解,把分你了
[其他解释]
该回复于2011-02-19 10:21:08被版主删除
[其他解释]
哎 这个问题应该不难吧 怎么没有解决呢。。。

读书人网 >C#

热点推荐