Bmp to jpg/png in C#

前端 未结 7 1900
无人共我
无人共我 2020-11-29 01:41

Is there any way to convert a bmp image to jpg/png without losing the quality in C#? Using Image class we can convert bmp to jpg but the quality of output image is very poor

7条回答
  •  囚心锁ツ
    2020-11-29 02:25

    var qualityEncoder = Encoder.Quality;
    var quality = (long);
    var ratio = new EncoderParameter(qualityEncoder, quality );
    var codecParams = new EncoderParameters(1);
    codecParams.Param[0] = ratio;
    var jpegCodecInfo = ;
    bmp.Save(fileName, jpegCodecInfo, codecParams); // Save to JPG
    

提交回复
热议问题