Hi 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.
If i leave out the two last parameters in the bmp.save it works fine.
EncoderParameters eps = new EncoderParameters(1);
eps.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 16);
ImageCodecInfo ici = GetEncoderInfo("image/jpeg");
string outfile = outputpath + "\\" + fileaddition + sourcefile.Name;
bmp.Save(outfile,ici,eps );
bmp.Dispose();
image.Dispose();
return true;
}
ImageCodecInfo GetEncoderInfo(string mimeType)
{
int j;
ImageCodecInfo[] encoders;
encoders = ImageCodecInfo.GetImageEncoders();
for (j = 0; j < encoders.Length; ++j)
{
if (encoders[j].MimeType == mimeType)
return encoders[j];
}
return null;
}
}
Thank you