将图像转换为字节arry [英] convert the image to byte arry

查看:85
本文介绍了将图像转换为字节arry的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用C#开发智能设备应用程序.在这种情况下,我称其为Web服务. Web服务方法返回google map.该方法的返回类型是object.该对象包含字节格式的图像.该对象以base64binary格式对图像进行配色.我需要在应用程序中显示实际图像.我需要执行哪种类型的投射才能显示图像.您能提供给我代码或任何链接来解决上述问题吗?

I am developing smart device application in C#. In that I am calling the web services. The web service method return google map. The return type of the method is object. The object contains the image in byte format. The object conatins the image in base64binary format. I need to display the actual image in my application. What type of casting I need to do to display the image. Can you provide me the code or any link through which I can resolve the above issue?

推荐答案

这是一个简单的代码.

图像,图标,光标以及Base-64转换器实用程序以外的所有内容 [ ^ ]

还是简单地应该这样做:

This is a simple one.

Image, Icon, Cursor, and Anything Else to Base-64 Converter Utility[^]

Or simply this should do:

string scontent = "/9j/4AAQSkZJRgABAQEAyADIAA.......igAooooA//Z";
Byte[] imagebytes = Convert.FromBase64String(scontent);
System.IO.MemoryStream ms = new System.IO.MemoryStream(imagebytes);
System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
img.Save(@"myimg.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);



干杯



Cheers


看看下面的链接.

http://www.dailycoding.com/Posts/convert_image_to_base64_string_and_base6464_string_to_image.aspx [
Have a look at below link.

http://www.dailycoding.com/Posts/convert_image_to_base64_string_and_base64_string_to_image.aspx[^]


您也可以看看我的有关使用扩展方法将Image转换为Byte数组或Base64String的博客文章.

检查一下:
http://tarundotnet .wordpress.com/2011/06/29/using-extension-methods-convert-image-to-byte-or-base64/ [
You can also have a look at my blog article on converting Image to Byte array or to Base64String using Extension methods.

Check it out : http://tarundotnet.wordpress.com/2011/06/29/using-extension-methods-convert-image-to-byte-or-base64/[^]

Hope this helps. :thumbsup:


这篇关于将图像转换为字节arry的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆