C#asp.net与Wnfrom常见问题实例
2010-04-04 19:51 苏飞 阅读(177) 评论(0) 收藏 举报1.怎么样把图片保存成字节?
第一种方式
代码
//Save image from PictureBox into MemoryStream object.
MemoryStream ms = new MemoryStream();
pictureBox1.Image.Save(ms, ImageFormat.Jpeg);
//Read from MemoryStream into Byte array.
Byte[] bytBLOBData = new Byte[ms.Length];
ms.Position = 0;
ms.Read(bytBLOBData, 0, Convert.ToInt32(ms.Length));
MemoryStream ms = new MemoryStream();
pictureBox1.Image.Save(ms, ImageFormat.Jpeg);
//Read from MemoryStream into Byte array.
Byte[] bytBLOBData = new Byte[ms.Length];
ms.Position = 0;
ms.Read(bytBLOBData, 0, Convert.ToInt32(ms.Length));
bytBLOBData就是你要的字节数组了
第二种方式
代码
codeMemoryStream ms = new MemoryStream();
pictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
byte[] bytes = ms.GetBuffer();
ms.Close();
ms.Dispose();
pictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
byte[] bytes = ms.GetBuffer();
ms.Close();
ms.Dispose();
bytes就是你想要的字节数组了
2.C#是怎么们存取图片的?
3.怎么样强制清理界面缓存
<meta http-equiv="pragma " content="no-cache ">
<meta http-equiv="Cache-Control " content="no-cache, must-revalidate ">
<meta http-equiv="expires " content="Wed, 26 Feb 1978 08:21:57 GMT ">
<meta http-equiv="Cache-Control " content="no-cache, must-revalidate ">
<meta http-equiv="expires " content="Wed, 26 Feb 1978 08:21:57 GMT ">
本人的博客不再维护从2013年就不再维护了
需要我帮助的朋友请到我的个人论坛 http://www.sufeinet.com 进行讨论,感谢大家对我的支持!

浙公网安备 33010602011771号