Click here to Skip to main content
15,117,549 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The code is given below,

var html = String.Format("<body>Hello world: {0}</body>", DateTime.Now);
            var htmlToImageConv = new NReco.ImageGenerator.HtmlToImageConverter();
            var jpegBytes = htmlToImageConv.GenerateImage(html, ImageFormat.Jpeg);

In the above code jpegBytes contains the byte array how to convert the byte array to image

pls help me...
Thanks in Advance
Updated 8-Nov-15 22:58pm
BillWoodruff 9-Nov-15 7:24am
If you paid US $99 for the NReco component, you are entitled to tech support:

"Feel free to contact us if you have any questions, propositions or suggestions:
generic requests:
commercial support requests:"

Save byte array to file
File.WriteAllBytes(string path, byte[] bytes)
I think this should help. If no, please explain a little bit more about your difficulties.
Athul MS 9-Nov-15 4:01am
pls send me the code for save byte array to file
Sergey Kizyan 9-Nov-15 4:05am
Here is example for string that I found:
string path = Path.GetTempPath();
byte[] binaryData;
string text = "romil123456";
using (MemoryStream memStream = new MemoryStream(Encoding.ASCII.GetBytes(text)))
binaryData = memStream.ToArray();
System.IO.File.WriteAllBytes(@path + "\\words123.txt" , binaryData);
In your case it is simpler, just put your array to function
Sergey Kizyan 9-Nov-15 4:06am
One line sample that I just tested:
File.WriteAllBytes(@"C:\temp\new.txt", new byte[]{1,2,3});
BillWoodruff 9-Nov-15 7:29am
the question here asks how to save the byte Array as an Image
ImageGenerator returns bytes array of the JPEG image.
You can load it into Image object with the following code:

var img = Image.FromStream( new MemoryStream(jpegBytes) );
Console.WriteLine("Image size: {0}x{1}", img.Width, img.Height);
public byte[] imageToByteArray(System.Drawing.Image imageIn)
     MemoryStream ms = new MemoryStream();
     return  ms.ToArray();

public Image byteArrayToImage(byte[] byteArrayIn)
     MemoryStream ms = new MemoryStream(byteArrayIn);
     Image returnImage = Image.FromStream(ms);
     return returnImage;

Read this CodeProject article: C# Image to Byte Array and Byte Array to Image Converter Class[^]


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