From 22c6b7d174ec7158acc526821b002d9703cf4f56 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 17 Jul 2010 13:29:55 +0000 Subject: PNG Compression can now be set, writing uncompressed PNG's is significantly faster for high resolution images - 2k. --- source/blender/imbuf/intern/png.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source/blender/imbuf') diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index 68a3324816c..4df8d8a2271 100644 --- a/source/blender/imbuf/intern/png.c +++ b/source/blender/imbuf/intern/png.c @@ -103,6 +103,11 @@ int imb_savepng(struct ImBuf *ibuf, char *name, int flags) int i, bytesperpixel, color_type = PNG_COLOR_TYPE_GRAY; FILE *fp = 0; + /* use the jpeg quality setting for compression */ + int compression; + compression= (int)(((float)(ibuf->ftype & 0xff) / 11.1111f)); + compression= compression < 0 ? 0 : (compression > 9 ? 9 : compression); + bytesperpixel = (ibuf->depth + 7) >> 3; if ((bytesperpixel > 4) || (bytesperpixel == 2)) { printf("imb_savepng: unsupported bytes per pixel: %d\n", bytesperpixel); @@ -201,10 +206,10 @@ int imb_savepng(struct ImBuf *ibuf, char *name, int flags) PNG_FILTER_AVG | PNG_FILTER_VALUE_AVG | PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH| PNG_ALL_FILTERS); - - png_set_compression_level(png_ptr, Z_BEST_COMPRESSION); */ + png_set_compression_level(png_ptr, compression); + // png image settings png_set_IHDR(png_ptr, info_ptr, -- cgit v1.2.3