image processing - .Net - Argument Exception When Trying to Convert Bitmap to JPEG -
Then I was trying to convert a bitmap image to JPEG in code and I found this error:
Additional information: The parameter is not valid.
Here is the related code all the paths are correct and the encodermator is not zero, and what could be the reason for this?
ImageCodecInfo codecInfo = null; Foreach (ImageCodecInfo codec ImageCodecInfo.GetImageEncoders ()) {if (codec.MimeType! = "Image / jpeg") {continue; } CodecInfo = codec; break; } EncoderParameter EncoderParamets = new encoder parameter (); Encoder parameters. Palm [0] = new encoder parameter (encoder quality, 85); (Bitmap bitmapioconvert = use new bitmap (filepathine)) {bitmapToConvert.Save (filePathOut, codecInfo, encoderParameters); }
two!
Encoder parameters. Paragraph [0] = new encoder parameter (encoder quality, 85);
should be:
encoder parameter. Paragraph [0] = new encoder parameter (encoder quality, 85L); // or encoder parameter. Paragraph [0] = new encoder parameter (encoder quality, (long) 85); In IL, 85 remains in the form of an integer, and GDI does not like the backend, it wants a long one. I hate non-descriptive exceptions. Oh good, thanks for everyone.
Comments
Post a Comment