From 5b26e695a1fc70c99b58f2e9c4c922412fbd1a08 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 7 Jan 2004 00:26:58 +0000 Subject: Make it possible to call gdk_pixbuf_loader_set_size (loader, 0, 0) by Wed Jan 7 01:17:36 2004 Matthias Clasen * gdk-pixbuf-loader.c (gdk_pixbuf_loader_size_func): * gdk-pixbuf-loader.c (gdk_pixbuf_loader_set_size): * gdk-pixbuf-loader.c (gdk_pixbuf_loader_init): Make it possible to call gdk_pixbuf_loader_set_size (loader, 0, 0) by changing the initial values of priv->width/height to -1. * io-tiff.c (tiff_image_parse): * io-ras.c (RAS2State): * io-pnm.c (gdk_pixbuf__pnm_image_load_increment): * io-pcx.c (gdk_pixbuf__pcx_load_increment): * io-jpeg.c (gdk_pixbuf__jpeg_image_load_increment): * io-png.c (png_info_callback): * io-ico.c (DecodeHeader): * io-bmp.c (DecodeHeader): Call size_func once the size is known, even if the module can't make use of the scaling information. If size_func returns 0, don't allocate a pixbuf and return, if necessary with an error. * gdk-pixbuf.h: * gdk-pixbuf-io.c (gdk_pixbuf_get_file_info): A new function to determine the type and size of an image file without loading it completely. (#53725) --- gdk-pixbuf/io-pnm.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'gdk-pixbuf/io-pnm.c') diff --git a/gdk-pixbuf/io-pnm.c b/gdk-pixbuf/io-pnm.c index 1fc1fe7c08..437ccaf0e0 100644 --- a/gdk-pixbuf/io-pnm.c +++ b/gdk-pixbuf/io-pnm.c @@ -55,6 +55,7 @@ typedef struct { typedef struct { GdkPixbufModuleUpdatedFunc updated_func; GdkPixbufModulePreparedFunc prepared_func; + GdkPixbufModuleSizeFunc size_func; gpointer user_data; GdkPixbuf *pixbuf; @@ -820,6 +821,7 @@ gdk_pixbuf__pnm_image_begin_load (GdkPixbufModuleSizeFunc size_func, return NULL; } memset (context, 0, sizeof (PnmLoaderContext)); + context->size_func = size_func; context->prepared_func = prepared_func; context->updated_func = updated_func; context->user_data = user_data; @@ -944,6 +946,16 @@ gdk_pixbuf__pnm_image_load_increment (gpointer data, context->got_header = TRUE; } + + if (context->size_func) { + gint w = context->width; + gint h = context->height; + (*context->size_func) (&w, &h, context->user_data); + + if (w == 0 || h == 0) + return FALSE; + } + /* scan until we hit image data */ if (!context->did_prescan) { -- cgit v1.2.1