如何将PictureBox.Image保存到文件?
我使用以下命令将 jpgImage 写入 PictureBox.Image。
var jpgImage = new Byte[jpgImageSize];
...
pictureBox.Image = new Bitmap(new MemoryStream(jpgImage));
我可以使用以下命令将字节数组写入文件
using (var bw =
new BinaryWriter(File.Open(filename, FileMode.Create,
FileAccess.Write, FileShare.None)))
{
bw.Write(jpgImage);
}
,但如何从 PictureBox.Image 获取 jpgImage 字节数组,以便将其写入文件? IOW:如何反转以下内容以从 PictureBox.Image 获取字节数组?
pictureBox.Image = new Bitmap(new MemoryStream(jpgImage));
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);
}
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));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
试试这个
Try this
您可以使用,
示例:
You may use,
Example:
使用下面的代码保存到自定义位置
Use below code for save into custom location