[Mono-list] Unable to set JPEG Quality to 100% in Mono
sebastien.pouliot at gmail.com
Thu May 21 15:43:35 EDT 2009
On Thu, 2009-05-21 at 12:35 -0700, szamil wrote:
> 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
> ImageCodecInfo codecs = ImageCodecInfo.GetImageEncoders();
> ImageCodecInfo myCodec=null;
> foreach(ImageCodecInfo codec in codecs)
> if(codec.MimeType == "image/jpeg")
> myCodec = codec;
> if(myCodec == null)
> throw new Exception("no jpeg codec found?!");
> EncoderParameters eps = new EncoderParameters(1);
> eps.Param = new EncoderParameter( Encoder.Quality, 100L );
> bmp.Save("myfile.jpg", myCodec, eps );
> 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!
I do not recall this one in particular but not every encoding parameters
are availabl inside libgdiplus. In part because they are not well
documented, in part because no one implemented them (expect the ones
that were required for something specific).
You can fill a bug in bugzilla.novell.com (Mono class library,
libgdiplus) but I greatly encourage you to contribute such a specific
case, since enhancement-priority bugs are unlikely to be fixed soon.
More information about the Mono-list