jpeg quality should be tunable
Scan documents to PDF and other file types, as simply as possible.
Brought to you by:
ben-cyanfish
This is a quick fix. The quality argument must be long to be applied well.
private static MemoryStream EncodeBitmap(Bitmap bitmap, ImageFormat imageFormat)
{
var encoded = new MemoryStream();
if (imageFormat == ImageFormat.Jpeg)
{
var encoder = ImageCodecInfo.GetImageEncoders().First(c => c.FormatID == ImageFormat.Jpeg.Guid);
var encParams = new EncoderParameters() { Param = new[] { new EncoderParameter(Encoder.Quality, 85L) } };
bitmap.Save(encoded, encoder, encParams);
}
else
{
bitmap.Save(encoded, imageFormat);
}
return encoded;
}