“Parameter is not valid.” when using saving bitmap

后端 未结 2 675
后悔当初
后悔当初 2021-01-03 11:21

Im trying to save a bitmap jpg format with a specified encoding quality. However im getting an exception (\"Parameter is not valid.\") when calling the save method.

相关标签:
2条回答
  • 2021-01-03 12:08

    You should cast quality value to long, like this:

    eps.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, (long)16);
    
    0 讨论(0)
  • 2021-01-03 12:13

    GDI+ is pretty flaky. You'll need to use 16L for the value or cast to (long).

    0 讨论(0)
提交回复
热议问题