Click here to Skip to main content
15,889,853 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?
Posted

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
 
Share this answer
 
v3
 
Share this answer
 
v2
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:
 
Share this answer
 
You can use this method:
C#
public static byte[] ImageToByte(Image img)
        {
            ImageConverter converter = new ImageConverter();
            return (byte[])converter.ConvertTo(img, typeof(byte[]));
        }
 
Share this answer
 
There is a article in the code project which describes about this, please visit
- C# Image to Byte Array and Byte Array to Image Converter Class[^]

:)
 
Share this answer
 
You can see this links
Click
Click
Click
Click
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900