Author: pbartok
Date: 2006-01-19 00:31:34 -0500 (Thu, 19 Jan 2006)
New Revision: 55767

Modified:
   trunk/libgdiplus/src/ChangeLog
   trunk/libgdiplus/src/jpegcodec.c
Log:
2006-01-18  Peter Dennis Bartok  <[EMAIL PROTECTED]> 

        * jpegcodec.c: Upconvert an indexed image, to allow saving it;
          added 1 and 4 bit as supported formats as well. This fixes #77270



Modified: trunk/libgdiplus/src/ChangeLog
===================================================================
--- trunk/libgdiplus/src/ChangeLog      2006-01-19 04:51:38 UTC (rev 55766)
+++ trunk/libgdiplus/src/ChangeLog      2006-01-19 05:31:34 UTC (rev 55767)
@@ -1,3 +1,8 @@
+2006-01-18  Peter Dennis Bartok  <[EMAIL PROTECTED]> 
+
+       * jpegcodec.c: Upconvert an indexed image, to allow saving it;
+         added 1 and 4 bit as supported formats as well. This fixes #77270
+
 2006-01-18  Peter Dennis Bartok  <[EMAIL PROTECTED]>
 
        * gdip.h: Switched GpRection.Cnt to int, to avoid signedness mismatch 

Modified: trunk/libgdiplus/src/jpegcodec.c
===================================================================
--- trunk/libgdiplus/src/jpegcodec.c    2006-01-19 04:51:38 UTC (rev 55766)
+++ trunk/libgdiplus/src/jpegcodec.c    2006-01-19 05:31:34 UTC (rev 55767)
@@ -552,6 +552,7 @@
                                GpImage *image,
                                GDIPCONST EncoderParameters *params)
 {
+    bool dispose_bitmap;
     GpBitmap *bitmap = (GpBitmap *) image;
     struct jpeg_compress_struct cinfo;
     struct gdip_jpeg_error_mgr jerr;
@@ -560,6 +561,8 @@
     int need_argb_conversion = 0;
        const EncoderParameter *param;
 
+    dispose_bitmap = FALSE;
+
     /* Verify that we can support this pixel format */
     switch (image->pixFormat) {
         case Format32bppArgb:
@@ -567,9 +570,13 @@
         case Format32bppRgb:
         case Format24bppRgb:
            break;
-        case Format8bppIndexed: /* check that this is grayscale */
-           if ((image->palette->Flags & PaletteFlagsGrayScale) == 0)
-               return InvalidParameter;
+       case Format1bppIndexed:
+       case Format4bppIndexed:
+        case Format8bppIndexed:
+            bitmap = gdip_convert_indexed_to_rgb ((GpBitmap*)bitmap);
+            image = (GpImage *)bitmap;
+            g_return_val_if_fail (image != NULL, OutOfMemory);
+            dispose_bitmap = TRUE;
             break;
         default:
             return InvalidParameter;
@@ -591,6 +598,9 @@
         if (scanline != NULL && need_argb_conversion)
             GdipFree (scanline);
 
+       if (dispose_bitmap) {
+               GdipDisposeImage(image);
+       }
         return GenericError;
     }
 
@@ -703,6 +713,9 @@
         GdipFree (dest);
     }
 
+    if (dispose_bitmap) {
+       GdipDisposeImage(image);
+    }
     return Ok;
 }
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to