Translate

> > Converting Image To Byte Array

Converting Image To Byte Array

Posted on Saturday, July 14, 2012 | No Comments

#region Converting Image To Byte Array


    private void byteArrayToImage(byte[] byteArrayIn)
    {
        System.Drawing.Image newImage;

        string strFileName = GetTempFolderName() + "yourfilename.gif";
        if (byteArrayIn != null)
        {
            using (MemoryStream stream = new MemoryStream(byteArrayIn))
            {
                newImage = System.Drawing.Image.FromStream(stream);

                newImage.Save(strFileName);

                img.Attributes.Add("src", strFileName);
            }

            lblMessage.Text = "The image conversion was successful.";
        }
        else
        {
            Response.Write("No image data found!");
        }
    }

    #endregion

Leave a Reply

Powered by Blogger.