保存GDI +绘制的图形 [英] Save GDI+ drawn graphics

查看:77
本文介绍了保存GDI +绘制的图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我 在图片框中加载图片,然后在其上绘制组合图形。
保存时,我发现只保存了我加载的原始图像。
如何更正代码?

I  loaded a picture in a picturebox and then draw a combined graphic on it. When saving, I found that only the original image I loaded was saved. How can I correct the code?

  private void btnSave_Click(object sender,EventArgs e)

         {

 private void btnSave_Click(object sender, EventArgs e)
        {

            string strr;

           位图bmp =新位图(pictureBox1.Width,pictureBox1.Height);

            pictureBox1.DrawToBitmap(BMP,新的Rectangle(0,0,bmp.Width,bmp.Height));

         &NBSP ;  SaveFileDialog sfdlg = new SaveFileDialog();

            sfdlg.Filter = QUOT; GIF(* GIF)| * .GIF |所有文件(*。*)| *。*英寸;

     &NBSP ;      sfdlg.ShowDialog();

            strr = sfdlg.FileName;

            bmp.Save(strr);
$


        }

            string strr;
            Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
            pictureBox1.DrawToBitmap(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height));
            SaveFileDialog sfdlg = new SaveFileDialog();
            sfdlg.Filter = "gif(*.GIF)|*.GIF|All file(*.*)|*.*";
            sfdlg.ShowDialog();
            strr = sfdlg.FileName;
            bmp.Save(strr);

        }

推荐答案

你可能不会在绘图过程中改变图像。试试这个:

使用
var g = Graphics.FromImage(pictureBox1.Image))

{

   
//画一些东西

   
g.DrawString( " some text" ,Font,Brushes.Red,10,10);

    g.DrawString( "Some text", Font, Brushes.Red, 10, 10 );

   
。 。 。

}

pictureBox1.Invalidate();


这篇关于保存GDI +绘制的图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆