开发者

how to save an Image to a file in wpf

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜