How to save PictureBox.Image to file?(如何将 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 保存到文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!