diff options
Diffstat (limited to 'graphics/gimp/patches/patch-af')
-rw-r--r-- | graphics/gimp/patches/patch-af | 80 |
1 files changed, 46 insertions, 34 deletions
diff --git a/graphics/gimp/patches/patch-af b/graphics/gimp/patches/patch-af index 383877ded59..10e0dabfb34 100644 --- a/graphics/gimp/patches/patch-af +++ b/graphics/gimp/patches/patch-af @@ -1,4 +1,4 @@ -$NetBSD: patch-af,v 1.7 2011/01/24 16:51:59 wiz Exp $ +$NetBSD: patch-af,v 1.8 2011/04/19 10:28:31 wiz Exp $ Fix build with png-1.5. https://bugzilla.gnome.org/show_bug.cgi?id=640409 @@ -237,7 +237,15 @@ https://bugzilla.gnome.org/show_bug.cgi?id=640409 /* * Initialise remap[] */ -@@ -1309,37 +1317,34 @@ save_image (const gchar *filename, +@@ -1304,44 +1312,48 @@ save_image (const gchar *filename, + + /* + * Set color type and remember bytes per pixel count ++ * Also fix bit depths for (possibly) smaller colormap images + */ + ++ bit_depth = 8; ++ switch (type) { case GIMP_RGB_IMAGE: @@ -265,31 +273,47 @@ https://bugzilla.gnome.org/show_bug.cgi?id=640409 break; case GIMP_INDEXED_IMAGE: ++ case GIMP_INDEXEDA_IMAGE: bpp = 1; - info->color_type = PNG_COLOR_TYPE_PALETTE; - info->valid |= PNG_INFO_PLTE; - info->palette = - (png_colorp) gimp_image_get_colormap (image_ID, &num_colors); - info->num_palette = num_colors; -+ color_type = PNG_COLOR_TYPE_PALETTE; -+ png_set_PLTE(pp, info, (png_colorp) gimp_image_get_colormap (image_ID, &num_colors), num_colors); - break; +- break; ++ if (type == GIMP_INDEXEDA_IMAGE) ++ bpp = 2; - case GIMP_INDEXEDA_IMAGE: - bpp = 2; +- case GIMP_INDEXEDA_IMAGE: +- bpp = 2; - info->color_type = PNG_COLOR_TYPE_PALETTE; +- /* fix up transparency */ +- respin_cmap (pp, info, remap, image_ID, drawable); + color_type = PNG_COLOR_TYPE_PALETTE; - /* fix up transparency */ - respin_cmap (pp, info, remap, image_ID, drawable); ++ gimp_image_get_colormap (image_ID, &num_colors); ++ if (num_colors <= 2) ++ bit_depth = 1; ++ else if (num_colors <= 4) ++ bit_depth = 2; ++ else if (num_colors <= 16) ++ bit_depth = 4; ++ /* otherwise the default is fine */ break; -@@ -1353,17 +1358,25 @@ save_image (const gchar *filename, - * Fix bit depths for (possibly) smaller colormap images - */ + + default: +@@ -1349,19 +1361,14 @@ save_image (const gchar *filename, + return FALSE; + } + +- /* +- * Fix bit depths for (possibly) smaller colormap images +- */ ++ png_set_IHDR(pp, info, drawable->width, drawable->height, bit_depth, color_type, pngvals.interlaced ? PNG_INTERLACE_ADAM7 : PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - if (info->valid & PNG_INFO_PLTE) -+ bit_depth = 8; -+ -+ if (png_get_valid(pp, info, PNG_INFO_PLTE)) ++ if (type == GIMP_INDEXED_IMAGE) ++ png_set_PLTE(pp, info, (png_colorp) gimp_image_get_colormap (image_ID, &num_colors), num_colors); ++ else if (type == GIMP_INDEXEDA_IMAGE) { - if (info->num_palette <= 2) - info->bit_depth = 1; @@ -297,25 +321,13 @@ https://bugzilla.gnome.org/show_bug.cgi?id=640409 - info->bit_depth = 2; - else if (info->num_palette <= 16) - info->bit_depth = 4; -+ png_colorp palette; -+ int num_palette; -+ png_get_PLTE(pp, info, &palette, &num_palette); -+ -+ if (num_palette <= 2) -+ bit_depth = 1; -+ else if (num_palette <= 4) -+ bit_depth = 2; -+ else if (num_palette <= 16) -+ bit_depth = 4; - /* otherwise the default is fine */ +- /* otherwise the default is fine */ ++ /* fix up transparency */ ++ respin_cmap (pp, info, remap, image_ID, drawable); } -+ png_set_IHDR(pp, info, drawable->width, drawable->height, bit_depth, color_type, pngvals.interlaced ? PNG_INTERLACE_ADAM7 : PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); -+ /* All this stuff is optional extras, if the user is aiming for smallest - possible file size she can turn them all off */ - -@@ -1477,7 +1490,7 @@ save_image (const gchar *filename, +@@ -1477,7 +1484,7 @@ save_image (const gchar *filename, * Convert unpacked pixels to packed if necessary */ @@ -324,7 +336,7 @@ https://bugzilla.gnome.org/show_bug.cgi?id=640409 png_set_packing (pp); /* -@@ -1529,7 +1542,7 @@ save_image (const gchar *filename, +@@ -1529,7 +1536,7 @@ save_image (const gchar *filename, /* If we're dealing with a paletted image with * transparency set, write out the remapped palette */ @@ -333,7 +345,7 @@ https://bugzilla.gnome.org/show_bug.cgi?id=640409 { guchar inverse_remap[256]; -@@ -1549,7 +1562,7 @@ save_image (const gchar *filename, +@@ -1549,7 +1556,7 @@ save_image (const gchar *filename, } /* Otherwise if we have a paletted image and transparency * couldn't be set, we ignore the alpha channel */ @@ -342,7 +354,7 @@ https://bugzilla.gnome.org/show_bug.cgi?id=640409 { for (i = 0; i < num; ++i) { -@@ -1564,7 +1577,7 @@ save_image (const gchar *filename, +@@ -1564,7 +1571,7 @@ save_image (const gchar *filename, png_write_rows (pp, pixels, num); gimp_progress_update (((double) pass + (double) end / |