覆盖现有图像 [英] Overwrite Existing Image

查看:181
本文介绍了覆盖现有图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的code

    private void saveImage()
    {
        Bitmap bmp1 = new Bitmap(pictureBox.Image);
        bmp1.Save("c:\\t.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
        // Dispose of the image files.
        bmp1.Dispose();
    }

我已经有一个形象的 t.jpg 是在我的硬盘C:\\结果
我想与每一个我的程序运行时间的新形象来代替它。但GDI +错误显示出来结果
我该如何解决呢?

i already have an image t.jpg at my drive "c:\".
i wanted to replace it with a new image every time my program runs. but a GDI+ error shows up
how could i fix it?

推荐答案

您必须删除你的形象,如果这是已经存在。

You must remove your image if that is already exists.

private void saveImage()
    {
        Bitmap bmp1 = new Bitmap(pictureBox.Image);

       if(System.IO.File.Exists("c:\\t.jpg"))
              System.IO.File.Delete("c:\\t.jpg");

        bmp1.Save("c:\\t.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
        // Dispose of the image files.
        bmp1.Dispose();
    }

这篇关于覆盖现有图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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