shad0wk shad0wk - 4 months ago 15
C# Question

Saving a image that was converted into byte[] without System.Drawing?

Yes you can just use:

// A byte array that contains a .jpeg data.
System.IO.Stream BitmapStream = System.IO.MemoryStream(byteBuffer);
System.Drawing.Bitmap MyImage = System.Drawing.Bitmap.FromStream(BitmapStream);
MyImage.Save("C:\Folder\Folder\image.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);


But how could you do this without
System.Drawing
?

I would like to write my own code to create the image.

Answer

If you have the image in bytes you don't need to use drawing to make an image, just save it as a binary file.

System.IO.File.WriteAllBytes("C:\Folder\Folder\image.png", byteBuffer);