如何将 PictureBox.Image 保存到文件? [英] How to save PictureBox.Image to file?

查看:40
本文介绍了如何将 PictureBox.Image 保存到文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下内容将 jpgImage 写入 PictureBox.Image.

I use the following to write jpgImage to a PictureBox.Image.

var jpgImage = new Byte[jpgImageSize];
...
pictureBox.Image = new Bitmap(new MemoryStream(jpgImage));

我可以使用以下内容将字节数组写入文件

and I can use the following to write a byte array to a file

using (var bw =
    new BinaryWriter(File.Open(filename, FileMode.Create,
        FileAccess.Write, FileShare.None)))
{
    bw.Write(jpgImage);
}

但是如何从 PictureBox.Image 获取 jpgImage 字节数组,以便将其写入文件?IOW:如何反转以下内容以从 PictureBox.Image 中获取字节数组?

but how can I get the jpgImage byte array from the PictureBox.Image so I can write it to the file? IOW: how do I reverse the following to get the byte array from the PictureBox.Image?

pictureBox.Image = new Bitmap(new MemoryStream(jpgImage));

推荐答案

试试这个

pictureBox.Image.Save(@"Path",ImageFormat.Jpeg);

这篇关于如何将 PictureBox.Image 保存到文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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