static gboolean gdk_pixbuf__tiff_image_stop_load (gpointer data, GError **error) { TiffContext *context = data; TIFF *tiff; gboolean retval; g_return_val_if_fail (data != NULL, FALSE); tiff_push_handlers (); tiff = TIFFClientOpen ("libtiff-pixbuf", "r", data, tiff_load_read, tiff_load_write, tiff_load_seek, tiff_load_close, tiff_load_size, tiff_load_map_file, tiff_load_unmap_file); if (!tiff || global_error) { tiff_set_error (error, GDK_PIXBUF_ERROR_FAILED, _("Failed to load TIFF image")); retval = FALSE; } else { GdkPixbuf *pixbuf; pixbuf = tiff_image_parse (tiff, context, error); if (pixbuf) g_object_unref (pixbuf); retval = pixbuf != NULL; if (global_error) { tiff_set_error (error, GDK_PIXBUF_ERROR_FAILED, _("Failed to load TIFF image")); tiff_pop_handlers (); retval = FALSE; } } if (tiff) TIFFClose (tiff); g_assert (!global_error); g_free (context->buffer); g_free (context); tiff_pop_handlers (); return retval; }
static GdkPixbuf * gdk_pixbuf__tiff_image_load (FILE *f, GError **error) { TIFF *tiff; int fd; GdkPixbuf *pixbuf; g_return_val_if_fail (f != NULL, NULL); tiff_push_handlers (); fd = fileno (f); /* On OSF, apparently fseek() works in some on-demand way, so * the fseek gdk_pixbuf_new_from_file() doesn't work here * since we are using the raw file descriptor. So, we call lseek() on the fd * before using it. (#60840) */ lseek (fd, 0, SEEK_SET); tiff = TIFFFdOpen (fd, "libpixbuf-tiff", "r"); if (!tiff || global_error) { tiff_set_error (error, GDK_PIXBUF_ERROR_CORRUPT_IMAGE, _("Failed to open TIFF image")); tiff_pop_handlers (); return NULL; } pixbuf = tiff_image_parse (tiff, NULL, error); TIFFClose (tiff); if (global_error) { tiff_set_error (error, GDK_PIXBUF_ERROR_FAILED, _("TIFFClose operation failed")); } tiff_pop_handlers (); return pixbuf; }