如何将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));
试试这个
pictureBox.Image.Save(@"Path",ImageFormat.Jpeg);
你可以用,
pictureBox.Image.Save(stream,System.Drawing.Imaging.ImageFormat.Jpeg);
例:
上述就是C#学习教程:如何将PictureBox.Image保存到文件?分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
System.IO.MemoryStream ms = new System.IO.MemoryStream(); pictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] ar = new byte[ms.Length]; ms.Write(ar, 0, ar.Length);
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/961177.html