I am currently working on an application that requires high-performance conversion of an unpadded byte array to either a PNG or JPEG. The image format doesn't matter, just as long as it's fast.
I have tried the .NET libraries and the performance is very bad. Can anyone recommend a good freeware library for this?
EDIT: the byte[] is an 8bit grayscale bitmap
Open Finder and select the images you want to convert. Open them in Preview and then Select All. Go to "File" and choose "Export Selected Images". Choose the export format as PNG.
In Windows, open JPG in Microsoft Paint, and click File > Save as > PNG > Save. In Photoshop (Windows or Mac), go to File > Save as > Save as type > PNG > Save. Or File > Export > Export As > PNG > Export. In Preview on Mac, select File > Export > Export As > Format > PNG > Save.
In addition, you can simply convert byte array to Bitmap . var bmp = new Bitmap(new MemoryStream(imgByte)); You can also get Bitmap from file Path directly.
You should be able to do something like this:
using System.Drawing.Imaging; using System.Drawing; using System.IO; byte[] bitmap = GetYourImage(); using(Image image = Image.FromStream(new MemoryStream(bitmap))) { image.Save("output.jpg", ImageFormat.Jpeg); // Or Png }
Look here for more info.
Hopefully this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With