From 9eac221929ec97515570b1bc2f9c48d98dc6fb90 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 21 Jul 2010 11:25:11 +0000 Subject: [PATCH] after testing stuff --- libvips/format/im_vips2png.c | 15 +++++++++++++-- libvips/include/vips/format.h | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/libvips/format/im_vips2png.c b/libvips/format/im_vips2png.c index 1313148d..37d62005 100644 --- a/libvips/format/im_vips2png.c +++ b/libvips/format/im_vips2png.c @@ -48,7 +48,7 @@ */ /* -#define DEBUG +#define VIPS_DEBUG */ #ifdef HAVE_CONFIG_H @@ -75,6 +75,7 @@ im_vips2png( IMAGE *in, const char *filename ) #include #include +#include #include @@ -183,8 +184,15 @@ static int write_png_block( REGION *region, Rect *area, void *a ) { Write *write = (Write *) a; + int i; + /* The area to write is always a set of complete scanlines. + */ + g_assert( area->left == 0 ); + g_assert( area->width == region->im->Xsize ); + g_assert( area->top + area->height <= region->im->Ysize ); + /* Catch PNG errors. Yuk. */ if( setjmp( write->pPng->jmpbuf ) ) @@ -417,6 +425,9 @@ png_write_buf_grow( PngWriteBuf *wbuf, size_t grow_len ) * FIXME: add im_realloc(). */ wbuf->buf = g_realloc( wbuf->buf, wbuf->alloc ); + + VIPS_DEBUG_MSG( "png_write_buf_grow: grown to %zd bytes\n", + wbuf->alloc ); } } @@ -440,7 +451,7 @@ user_write_data( png_structp png_ptr, png_bytep data, png_size_t length ) * im_vips2bufpng: * @in: image to save * @out: allocate output buffer local to this - * @compression: Compress with this much effort + * @compression: compress with this much effort * @interlace: 0 means don't interlace, 1 selects ADAM7 interlacing * @obuf: return output buffer here * @olen: return output length here diff --git a/libvips/include/vips/format.h b/libvips/include/vips/format.h index 6569d454..3d62e9a4 100644 --- a/libvips/include/vips/format.h +++ b/libvips/include/vips/format.h @@ -143,6 +143,8 @@ int im_vips2csv( IMAGE *in, const char *filename ); int im_png2vips( const char *filename, IMAGE *out ); int im_vips2png( IMAGE *in, const char *filename ); +int im_vips2bufpng( IMAGE *in, IMAGE *out, + int compression, int interlace, char **obuf, size_t *olen ); int im_raw2vips( const char *filename, IMAGE *out, int width, int height, int bpp, int offset );