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

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -