[Mono-bugs] [Bug 506179] New: unable to set different quality when saving JPEG images using Bitmap object

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu May 21 17:08:04 EDT 2009


           Summary: unable to set different quality when saving JPEG
                    images using Bitmap object
    Classification: Mono
           Product: Mono: Class Libraries
           Version: unspecified
          Platform: 64bit
        OS/Version: openSUSE 11.1
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: libgdiplus
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: thewall37 at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---

User-Agent:       Opera/9.64 (Windows NT 5.1; U; pl) Presto/2.1.1

I'm trying to save JPEG image with 100% quality, but it is always saved with
some kind of default compression, about 85%. I'm using below 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[0] = new EncoderParameter( Encoder.Quality, 100L );

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


It works on .NET platform.

Reproducible: Always

Steps to Reproduce:
1. Create Bitmap object or load a bmp.
2. Prepare jpeg ImageCodecInfo 
3. Set EncoderParameters quality to an extreme value (e.g. 1 or 100)
4. Try to save image with ImageCodecInfo and EncoderParameters defined above.
Actual Results:  
Saved image has always 85% quality.

Expected Results:  
The image should be compressed according to Encoder Parameter

This is serious problem, becouse of loosing image data after saving to
compressed file.

Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.

More information about the mono-bugs mailing list