GdkPixbuf * file_utils_load_thumbnail (const gchar *filename) { GimpThumbnail *thumbnail = NULL; GdkPixbuf *pixbuf = NULL; gchar *uri; g_return_val_if_fail (filename != NULL, NULL); uri = g_filename_to_uri (filename, NULL, NULL); if (uri) { thumbnail = gimp_thumbnail_new (); gimp_thumbnail_set_uri (thumbnail, uri); pixbuf = gimp_thumbnail_load_thumb (thumbnail, GIMP_THUMBNAIL_SIZE_NORMAL, NULL); } g_free (uri); if (pixbuf) { gint width = gdk_pixbuf_get_width (pixbuf); gint height = gdk_pixbuf_get_height (pixbuf); if (gdk_pixbuf_get_n_channels (pixbuf) != 3) { GdkPixbuf *tmp = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, width, height); gdk_pixbuf_composite_color (pixbuf, tmp, 0, 0, width, height, 0, 0, 1.0, 1.0, GDK_INTERP_NEAREST, 255, 0, 0, GIMP_CHECK_SIZE_SM, 0x66666666, 0x99999999); g_object_unref (pixbuf); pixbuf = tmp; } } return pixbuf; }
/** * gimp_thumbnail_check_thumb: * @thumbnail: a #GimpThumbnail object * @size: the preferred size of the thumbnail image * * Checks if a thumbnail file for the @thumbnail exists, loads it and * verifies it is valid and uptodate for the image file asosciated * with the @thumbnail. * * Return value: the thumbnail's #GimpThumbState after the update * * Since: 2.2 **/ GimpThumbState gimp_thumbnail_check_thumb (GimpThumbnail *thumbnail, GimpThumbSize size) { GdkPixbuf *pixbuf; g_return_val_if_fail (GIMP_IS_THUMBNAIL (thumbnail), FALSE); GIMP_THUMB_DEBUG_CALL (thumbnail); if (gimp_thumbnail_peek_thumb (thumbnail, size) == GIMP_THUMB_STATE_OK) return GIMP_THUMB_STATE_OK; pixbuf = gimp_thumbnail_load_thumb (thumbnail, size, NULL); if (pixbuf) g_object_unref (pixbuf); return thumbnail->thumb_state; }
static PyObject * _wrap_gimp_thumbnail_load_thumb(PyGObject *self, PyObject *args, PyObject *kwargs) { static char *kwlist[] = { "size", NULL }; PyObject *py_size = NULL; GdkPixbuf *ret; GError *error = NULL; GimpThumbSize size; if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:Gimp.Thumbnail.load_thumb", kwlist, &py_size)) return NULL; if (pyg_enum_get_value(GIMP_TYPE_THUMB_SIZE, py_size, (gpointer)&size)) return NULL; ret = gimp_thumbnail_load_thumb(GIMP_THUMBNAIL(self->obj), size, &error); if (pyg_error_check(&error)) return NULL; /* pygobject_new handles NULL checking */ return pygobject_new((GObject *)ret); }