Details
[Home]
Issue of the Implementation # S0662
Brief
gdk_pixbuf_loader_set_size corrupts the animated image that is being loaded
Detailed Description
If one changes size (via gdk_pixbuf_loader_set_size) of an animated image being loaded, then after gdk_pixbuf_loader_close is called at the end of the loading process, the resulting animated image will have requested dimensions but it will be static (i.e. сontaining only one frame).
This problem is shown in the example (usage: "test 'image_file'").
According to the code of gdk-pixbuf, we suppose the problem is in gdk_pixbuf_loader_close function which is in fact responsible for replacing the original image with the static one:
gboolean gdk_pixbuf_loader_close (GdkPixbufLoader *loader, GError **error) { //... if (priv->needs_scale) { //... tmp = gdk_pixbuf_animation_get_static_image (priv->animation); g_object_ref (tmp); pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, tmp->has_alpha, 8, priv->width, priv->height); g_object_unref (priv->animation); priv->animation = gdk_pixbuf_non_anim_new (pixbuf); g_object_unref (pixbuf); //... } //... } GdkPixbufAnimation * gdk_pixbuf_loader_get_animation (GdkPixbufLoader *loader) { //... return priv->animation; } GdkPixbuf * gdk_pixbuf_loader_get_pixbuf (GdkPixbufLoader *loader) { //... if (priv->animation) return gdk_pixbuf_animation_get_static_image (priv->animation); else return NULL; }
Problem location(s) in the standard
Gdk-pixbuf 2.6.2 API Reference, GdkPixbufLoader
Possible solutions
Specify in the documentation that gdk_pixbuf_loader_set_size cannot be called for animated images. Or, perphaps, create a wrapper around the GdkPixbufAnimation object returned by the loader that will scale the frames properly.
Component
gtk-gdk-pixbuf 2.6.2 or later
Status
Fixed in gtk+-2.11.0
[Home]