Convert byte array to Bitmap - CSharp System.Drawing

CSharp examples for System.Drawing:Image Convert

Description

Convert byte array to Bitmap

Demo Code


using System.Drawing;

public class Main{
        /// <summary>
        /// Converte um array de bytes em um bitmap
        /// </summary>
        /// <param name="instance">Objeto a ser convertido</param>
        /// <returns>Bitmap convertido</returns>
        public static Bitmap ToBitmap(this byte[] instance)
        {//w  w  w .ja va2  s  .  c  o m
            ImageConverter ic = new ImageConverter();
            System.Drawing.Image img = (System.Drawing.Image)ic.ConvertFrom(instance);
            Bitmap bitmap = new Bitmap(img);
            return bitmap;
        }
}

Related Tutorials