Base To Image - CSharp System

CSharp examples for System:String Convert

Description

Base To Image

Demo Code


using System.IO;//from   w  ww.ja  v a  2 s  . c  o  m
using System.Drawing;
using System;

public class Main{
        public static Image Base64ToImage(this string base64String)
        {
            // Convert Base64 String to byte[]
            byte[] imageBytes = Convert.FromBase64String(base64String);
            var 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;
        }
}

Related Tutorials