Convert Base64 String to Image in C#

By: Syed Emailed: 1728 times Printed: 2338 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

This tutorial will help you to learn how we can convert base64 string back to image.
public Image Base64ToImage(string base64String)
{
  // Convert Base64 String to byte[]
  byte[] imageBytes = Convert.FromBase64String(base64String);
  MemoryStream ms = new MemoryStream(imageBytes, 0, 
    imageBytes.Length);

  // Convert byte[] to Image
  ms.Write(imageBytes, 0, imageBytes.Length);
  Image image = Image.FromStream(ms, true);
  return image;
}

Csharp Home | All Csharp Tutorials | Latest Csharp Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(3)


1. View Comment

good

View Tutorial          By: osman at 2011-11-21 22:23:02
2. View Comment

hi
very tnx for your code


View Tutorial          By: Moji at 2012-08-19 16:06:53
3. View Comment

How to Use Code in my Page ? plz give me the sugeestion

View Tutorial          By: jaty at 2015-08-19 12:25:20

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by Syed
Convert Base64 String to Image in C#
Convert Image to Base64 String in C#

More Tutorials in Csharp
Major features of C#
Categories of datatypes in C#
Boxing and unboxing in C#
Preprocessor directives in C#
Comments in C#
Hello World sample program in C#
SOAP serialization in C#
What is C#?
Design Goals of C#
Why it was named C#?
History of C#?
Which version of C# to use?
Convert Image to Base64 String in C#
Convert Base64 String to Image in C#

More Latest News
Most Viewed Articles (in Csharp )
Convert Base64 String to Image in C#
Hello World sample program in C#
Convert Image to Base64 String in C#
SOAP serialization in C#
What is C#?
Design Goals of C#
Why it was named C#?
History of C#?
Which version of C# to use?
Major features of C#
Categories of datatypes in C#
Boxing and unboxing in C#
Preprocessor directives in C#
Comments in C#
Most Emailed Articles (in Csharp)
Boxing and unboxing in C#
SOAP serialization in C#
Design Goals of C#
Why it was named C#?
Which version of C# to use?
Major features of C#
Preprocessor directives in C#
Comments in C#
Hello World sample program in C#
Convert Image to Base64 String in C#
Convert Base64 String to Image in C#
What is C#?
History of C#?
Categories of datatypes in C#