I have some picture send via sockets to the client.
these pictures must be compressed before sending to the client .
what can i do for compressing to jpeg and send via socket (convert jpeg to byte[] send to the client and vice versa).
thanks for help.
====edit :
these are some blocks of an image , with 24bpp pixel format
Asked
Active
Viewed 192 times
-2

4rm4n
- 1
- 2
-
1Let's get the question clear: do you have a different image format you need to convert to Jpeg, or do you have a Jpeg you need to read into a byte array? – rickvdbosch Jan 04 '18 at 15:57
-
_I have some picture_ Where do these images come from? What format are they? – 001 Jan 04 '18 at 15:58
-
these are some blocks of an image , with 24bpp pixel format – 4rm4n Jan 04 '18 at 15:59
-
2JPEGs are already compressed + they are binary data. Compressing those further is pretty hard. You might want to try to base64 the binary data and zip that ... but i highly doubt there will be any benefit in space saved.. – X39 Jan 04 '18 at 15:59
1 Answers
0
Use https://learn.microsoft.com/en-us/dotnet/api/system.drawing.image.save?view=netframework-4.7.1#System_Drawing_Image_Save_System_IO_Stream_System_Drawing_Imaging_ImageFormat_ (assuming you're using the full framework).
Edit: that should have pointed to the overload using an ImageCodecInfo on that same page. Unless the images are already compressed JPEGs, in which case don't recompress them - you'll only decrease quality.

Alex Paven
- 5,539
- 2
- 21
- 35