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


C#
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
Posted
Updated 8-Nov-15 21:58pm
v2
Comments
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: info@nrecosite.com
commercial support requests: support@nrecosite.com"

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.
 
Share this answer
 
Comments
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);
 
Share this answer
 
C#
public byte[] imageToByteArray(System.Drawing.Image imageIn)
{
     MemoryStream ms = new MemoryStream();
     imageIn.Save(ms,System.Drawing.Imaging.ImageFormat.Gif);
     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[^]

-KR
 
Share this answer
 

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