How can I convert a BITMAP in byte array format to JPEG format using .net 2.0?
What type of byte[]
do you mean? The raw file-stream data? In which case, how about something like (using System.Drawing.dll
in a client application):
using(Image img = Image.FromFile("foo.bmp"))
{
img.Save("foo.jpg", ImageFormat.Jpeg);
}
Or use FromStream
with a new MemoryStream(arr)
if you really do have a byte[]
:
byte[] raw = ...todo // File.ReadAllBytes("foo.bmp");
using(Image img = Image.FromStream(new MemoryStream(raw)))
{
img.Save("foo.jpg", ImageFormat.Jpeg);
}