var ratio = new EncoderParameter(Encoder.Quality, 75L);
var depth = new EncoderParameter(Encoder.ColorDepth, 8);
var codecParams = new EncoderParameters(2);
codecParams.Param[0] = ratio;
codecParams.Param[1] = depth;
var pngCodec = ImageCodecInfo.GetImageEncoders()[4];
using (var srteam = new MemoryStream())
{
bitmap.Save(srteam, pngCodec, codecParams);
byte[] imageBytes = srteam.ToArray();
return imageBytes;