picture.image转换为byte[]

shangjunqi 2008-01-25 04:04:50
大家好,有人能告诉我
怎么能把pictureBox.image直接转换为byte[]格式吗
如果不能直接转化,间接转换也可以的
谢谢
...全文
165 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
shangjunqi 2008-01-25
  • 打赏
  • 举报
回复
小弟是个新手,大家给的意见都很好,谢谢你们
sn_wolf 2008-01-25
  • 打赏
  • 举报
回复
楼上正解
Eddie005 2008-01-25
  • 打赏
  • 举报
回复
System.Drawing.Image img = this.pictureBox1.Image;
System.IO.MemoryStream ms = new System.IO.MemoryStream();
img.Save(ms, img.RawFormat);
byte[] by = new byte[ms.Length ];
ms.Position = 0;
ms.Read(by, 0, (int)ms.Length);
shangjunqi 2008-01-25
  • 打赏
  • 举报
回复
pic.Save(imgStream, System.Drawing.Imaging.ImageFormat.Bmp);
改为
pic.Save(imgStream, System.Drawing.Imaging.ImageFormat.gif);
也可以吧
shangjunqi 2008-01-25
  • 打赏
  • 举报
回复
第一次提问,不知道怎么给分,你们说一下,我马上给
yumanqing 2008-01-25
  • 打赏
  • 举报
回复
up
nbdjt 2008-01-25
  • 打赏
  • 举报
回复
保存到文件里再读出来
this.pictureBox.Image.Save("file");
shangjunqi 2008-01-25
  • 打赏
  • 举报
回复
谢谢你,我一直以为picture.image是个image对象呢,结果试了好几种转换也没有成功
cnfixit 2008-01-25
  • 打赏
  • 举报
回复


MemoryStream imgStream = new MemoryStream();
pic.Save(imgStream, System.Drawing.Imaging.ImageFormat.Bmp);//pic为bitmap类型的对象
byte[] imageb ={ };
imageb = imgStream.ToArray();

111,119

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧