Make it possible to call gdk_pixbuf_loader_set_size (loader, 0, 0) by

Wed Jan  7 01:17:36 2004  Matthias Clasen  <maclas@gmx.de>

	* 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)
This commit is contained in:
Matthias Clasen
2004-01-07 00:26:58 +00:00
committed by Matthias Clasen
parent 72b7abd535
commit 5b26e695a1
16 changed files with 266 additions and 29 deletions

View File

@ -358,6 +358,7 @@ struct _LoadContext {
png_structp png_read_ptr;
png_infop png_info_ptr;
GdkPixbufModuleSizeFunc size_func;
GdkPixbufModulePreparedFunc prepare_func;
GdkPixbufModuleUpdatedFunc update_func;
gpointer notify_user_data;
@ -398,6 +399,7 @@ gdk_pixbuf__png_image_begin_load (GdkPixbufModuleSizeFunc size_func,
lc->fatal_error_occurred = FALSE;
lc->size_func = size_func;
lc->prepare_func = prepare_func;
lc->update_func = update_func;
lc->notify_user_data = user_data;
@ -593,7 +595,18 @@ png_info_callback (png_structp png_read_ptr,
if (color_type & PNG_COLOR_MASK_ALPHA)
have_alpha = TRUE;
lc->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, have_alpha, 8, width, height);
if (lc->size_func) {
gint w = width;
gint h = height;
(* lc->size_func) (&w, &h, lc->notify_user_data);
if (w == 0 || h == 0) {
lc->fatal_error_occurred = TRUE;
return;
}
}
lc->pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, have_alpha, 8, width, height);
if (lc->pixbuf == NULL) {
/* Failed to allocate memory */