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 保存到文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何将 PictureBox.Image 保存到文件?
基础教程推荐
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
