[Mono-list] Unable to set JPEG Quality to 100% in Mono

szamil thewall37 at gmail.com
Thu May 21 15:35:23 EDT 2009


Hi!

I need to save my bitmap to jpeg with 100% quality (lowest compression). I
use this code:


Bitmap bmp = new Bitmap(w,h);
BitmapData bmpdata = bmp.LockBits(new Rectangle, 0, 0, w, h),
ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);
//Filling image with data - works for sure
bmp.UnlockBits(bmpdata);

ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
ImageCodecInfo myCodec=null;
foreach(ImageCodecInfo codec in codecs)
{
	if(codec.MimeType == "image/jpeg")
	{
		myCodec = codec;
		break;
	}
}
if(myCodec == null)
	throw new Exception("no jpeg codec found?!");

EncoderParameters eps = new EncoderParameters(1);
eps.Param[0] = new EncoderParameter( Encoder.Quality, 100L );

bmp.Save("myfile.jpg", myCodec, eps );
bmp.Dispose();

The problem is that whatever I set in EncodeParameter I always get same -
compressed image.
Does anyone know why? Is it bug of implemetation System.Drawing?
The code was testen in .NET and worked fine.
My configuration: openSUSE 11.1 with Mono 2.4

I would appreciate your help!
-- 
View this message in context: http://www.nabble.com/Unable-to-set-JPEG-Quality-to-100--in-Mono-tp23657867p23657867.html
Sent from the Mono - General mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20090521/301bce08/attachment.html 


More information about the Mono-list mailing list