Save 1-bit, 2-bit and 4-bit PNG if appropriate

This commit is contained in:
Nick Lamb /GIMP 2000-04-13 04:48:56 +00:00
parent 74156c69bd
commit 092c854615
2 changed files with 23 additions and 1 deletions

View file

@ -1,3 +1,8 @@
2000-04-13 Nick Lamb <njl195@zepler.org.uk>
* plug-ins/common/png.c: Use 1-bit, 2-bit and 4-bit paletted
PNG when appropriate during save. Smaller output files.
2000-04-13 Michael Natterer <mitch@gimp.org>
* app/measure.c: push an undo group when adding horizontal and

View file

@ -857,6 +857,16 @@ save_image (gchar *filename, /* I - File to save to */
return 0;
};
if (info->valid & PNG_INFO_PLTE) {
if (info->num_palette <= 2)
info->bit_depth= 1;
else if (info->num_palette <= 4)
info->bit_depth= 2;
else if (info->num_palette <= 16)
info->bit_depth= 4;
/* otherwise the default is fine */
}
if (info->valid & PNG_INFO_tRNS) {
/* It's not really a VERY evil hack, right? -- ruth */
@ -872,7 +882,14 @@ save_image (gchar *filename, /* I - File to save to */
if (pngvals.interlaced)
num_passes = png_set_interlace_handling(pp);
else
num_passes = 1;
num_passes = 1;
/*
* Convert unpacked pixels to packed if necessary
*/
if (info->color_type == PNG_COLOR_TYPE_PALETTE && info->bit_depth < 8)
png_set_packing(pp);
/*
* Allocate memory for "tile_height" rows and save the image...