I noticed about others posts that the way to load a PictureBox.Image from bytearray is like:
using (var ms = new MemoryStream(_imageBytes))
var img = Image.FromStream(ms); //here imageformat stills ImageFormat.Jpeg
_image = new Bitmap(img); // here changes to ImageFormat.MemoryBmp
picBoxImage.Image = _image;
But i want smaller response sizes.
Original memory stream is about 70k (jpg encoded), but is rendered to client as png with bigger size (700k), last is a bit slow when 15 or more images
I want to know a way to response as jpg or better approach
Thanks in advance!
You need to keep the byte array stream. The code in your message disposes the stream and creates a new bitmap. Do this instead:
picBoxImage.Image = Image.FromStream(new MemoryStream(_imageBytes));
Jpeg images in System.Drawing need the stream.
Otherwise you can also save the image to a temp file and return the name of the file.
Please login first to submit.