图片转换二进制,然后二进制转换成图片

yueluo888 2008-08-04 09:03:33
先换取一张图片转换成二进制,然后在把二进制转换成图片,请高手帮帮。在线等,搞定立马给分!
...全文
2416 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
梦回自己 2011-08-06
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 guying999 的回复:]
向数据库中保存图片:
http://dotnet.aspx.cc/article/2a5dd7c6-a45a-48ab-a2e8-342a29f17506/read.aspx
从SQL Server数据库提取图片并显示在DataGrid:
http://dotnet.aspx.cc/article/ecd9ae16-8ff0-4a1c-9b9f-5e8b641cb1b1/read.aspx
[/Quote]
这个网页怎么打不开啊
GabrielCNMao 2008-08-04
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 h_w_king 的回复:]
C# codeImage aa = new Bitmap(@"E:\photo\tm.jpg");

System.IO.MemoryStream stream = new System.IO.MemoryStream();
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
formatter.Serialize(stream, aa); //将图像序列化成二进制流

st…
[/Quote]
可以
suyiming 2008-08-04
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 guying999 的回复:]
向数据库中保存图片:
http://dotnet.aspx.cc/article/2a5dd7c6-a45a-48ab-a2e8-342a29f17506/read.aspx
从SQL Server数据库提取图片并显示在DataGrid:
http://dotnet.aspx.cc/article/ecd9ae16-8ff0-4a1c-9b9f-5e8b641cb1b1/read.aspx
[/Quote]
yueluo888 2008-08-04
  • 打赏
  • 举报
回复
谢谢大家,分数已经结了。在文个问题 AES对图片加密有会的吗?还是立马给分。
ljm66 2008-08-04
  • 打赏
  • 举报
回复
楼上的都那么全了,我就不多说了,帮顶
asdcvc6489 2008-08-04
  • 打赏
  • 举报
回复
这个问题我以前也接触过,开始的时候我也找不到问题的原因,后来我进了一个技术交

流群,这个群里的人挺多的,在里面可以沟通技术,你可以进去看一下.群号是:陆肆柒

玖捌柒玖贰。另外,这个群里可以接项目。
wdgphc 2008-08-04
  • 打赏
  • 举报
回复

图片转2进制
//读取某文件夹下的图片存于picbyte中
Stream ms;
byte[] picbyte;
OpenFileDialog ofdSelectPic = new OpenFileDialog();
ofdSelectPic.ShowDialog();
ms = ofdSelectPic.OpenFile();
picbyte = new byte[ms.Length];
ms.Position = 0;
ms.Read(picbyte, 0, Convert.ToInt32(ms.Length));

2进制转图片
MemoryStream ms = new MemoryStream((byte[])picbyte);
Image image = Image.FromStream(ms);
//pictureBox1.Image = image;
CsToD 2008-08-04
  • 打赏
  • 举报
回复
byte[] BitmapToBytes(Bitmap bmp)
{
MemoryStream ms=new MemoryStream();
bmp.Save(ms,System.Drawing.Imaging.ImageFormat.Jpeg);
ms.Close();
return ms.ToArray();
}
Bitmap BytesToBitmap(byte[] bytes)
{
MemoryStream ms=new MemoryStream(bytes);
Bitmap bmp=new Bitmap(ms);
ms.Close();
return bmp;
}


说是立马给分,恐怕很久都不结贴吧
h_w_king 2008-08-04
  • 打赏
  • 举报
回复
Image aa = new Bitmap(@"E:\photo\tm.jpg");

System.IO.MemoryStream stream = new System.IO.MemoryStream();
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
formatter.Serialize(stream, aa); //将图像序列化成二进制流

stream.Position = 0;
Image bb = (Image)formatter.Deserialize(stream); //将二进制流序列成Image


this.pictureBox1.Image = bb;
优途科技 2008-08-04
  • 打赏
  • 举报
回复
不是很懂。帮顶!
twtetg 2008-08-04
  • 打赏
  • 举报
回复
资料很详细了,帮你顶下
yueluo888 2008-08-04
  • 打赏
  • 举报
回复
byte[] 我不是向插入数据库的,我只是向转换!
Adechen 2008-08-04
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 guying999 的回复:]
向数据库中保存图片:
http://dotnet.aspx.cc/article/2a5dd7c6-a45a-48ab-a2e8-342a29f17506/read.aspx
从SQL Server数据库提取图片并显示在DataGrid:
http://dotnet.aspx.cc/article/ecd9ae16-8ff0-4a1c-9b9f-5e8b641cb1b1/read.aspx
[/Quote]
hopewoo 2008-08-04
  • 打赏
  • 举报
回复
是 bit 还是byte?
guying999 2008-08-04
  • 打赏
  • 举报
回复
向数据库中保存图片:
http://dotnet.aspx.cc/article/2a5dd7c6-a45a-48ab-a2e8-342a29f17506/read.aspx
从SQL Server数据库提取图片并显示在DataGrid:
http://dotnet.aspx.cc/article/ecd9ae16-8ff0-4a1c-9b9f-5e8b641cb1b1/read.aspx
GhostAdai 2008-08-04
  • 打赏
  • 举报
回复
结这么快啊,接都没来得及。

110,536

社区成员

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

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

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