开发者

how to save an Image to a file in wpf

开发者 https://www.devze.com 2023-01-31 02:41 出处:网络
hello i am abit new i开发者_JAVA百科n wpf and i have been trying to save an image to afile with no success.

hello i am abit new i开发者_JAVA百科n wpf and i have been trying to save an image to afile with no success. thanks in advance for your help.


If you want to save it as a PNG for example, you can do something like:

using (var fileStream = new FileStream(filePath, FileMode.Create))
{
    BitmapEncoder encoder = new PngBitmapEncoder();
    encoder.Frames.Add(BitmapFrame.Create(image));
    encoder.Save(fileStream);
}

Or you can use some other encoders derived from the BitmapEncoder class.

0

精彩评论

暂无评论...
验证码 换一张
取 消