编辑图片 [英] Editing Pictures

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

问题描述

这是我在这里的第一个问题,我希望它会有所帮助。


我正在尝试将图片上传到pictureBox然后旋转这张图片

但我的问题是,当我想在旋转后保存图片时,他向我发送错误信息并告诉我另一个程序使用此文件(可能是我的程序)。


任何想法如何克服这个问题?

this is my first question here and i hope it will be helpfull.

I''m trying to upload a picture to pictureBox and then to rotate this picture
but my problem is that when i want to save the picture after I rotate it he send me error message and told me that another program use this file (probably my program).

any ideas how to overcome this problame?

推荐答案

我想你用Bitmap.FromFile(或Image.FromFile)打开文件

它保持文件句柄打开。你要做的是.Clone()它到另一个Image / Bitmap对象。然后。第一个的Dispose()(关闭文件句柄)


现在你有图片对象,文件句柄已关闭。您可以自由覆盖该文件。
I imagine you are opening the file with something like Bitmap.FromFile (or Image.FromFile)
It keeps the filehandle open. What you would do is .Clone() it to another Image/Bitmap object. Then .Dispose() of the first one (closes the file handle)

You now have you picture object and the filehandle is closed. You are free to overwrite the file.


谢谢,但它仍然不能正常工作

有没有其他方法可以打开文件而不是image.fromFile

以便流保持关闭?
thanks, but it''s still don''t work
is there any other way to open file not with image.fromFile
so that the stream will stay close?


好的,我的错误,Clone()也保持文件句柄打开。


这似乎有效:
Ok, my mistake, the Clone() keeps the filehandle open too.

This seemed to work though:
展开 | 选择 | Wrap | 行号


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

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