diff options
author | Matthias Clasen <mclasen@redhat.com> | 2013-12-19 00:26:24 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2013-12-19 00:26:24 -0500 |
commit | 496d8e39a6eec38ab0b6493736488418ec2d7000 (patch) | |
tree | dd24710ed3964d6aab7e1e96e667a11fcdd137d8 | |
parent | 8c2699bf8bbd189b7869c2498f1bcbba6057ed7e (diff) | |
download | gdk-pixbuf-496d8e39a6eec38ab0b6493736488418ec2d7000.tar.gz |
Avoid a discrepancy in file recognition
We are using a loader to implement some of the APIs that
are taking a filename, such as gdk_pixbuf_new_from_file_at_scale.
But the loader does not have the filename, so it can't use it
when determining the image type. This makes a difference for
types such as xbm, which have no good magic in the mime database.
Fix this by introducing a private API that lets us pass the
filename on to the loader.
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-io.c | 4 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-loader.c | 19 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-private.h | 3 |
3 files changed, 23 insertions, 3 deletions
diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c index 0ef83b4eb..0cb6ed311 100644 --- a/gdk-pixbuf/gdk-pixbuf-io.c +++ b/gdk-pixbuf/gdk-pixbuf-io.c @@ -1351,7 +1351,7 @@ gdk_pixbuf_new_from_file_at_scale (const char *filename, return NULL; } - loader = gdk_pixbuf_loader_new (); + loader = _gdk_pixbuf_loader_new_with_filename (filename); info.width = width; info.height = height; @@ -1909,7 +1909,7 @@ gdk_pixbuf_get_file_info (const gchar *filename, if (!f) return NULL; - loader = gdk_pixbuf_loader_new (); + loader = _gdk_pixbuf_loader_new_with_filename (filename); info.format = NULL; info.width = -1; diff --git a/gdk-pixbuf/gdk-pixbuf-loader.c b/gdk-pixbuf/gdk-pixbuf-loader.c index 5cf3f7414..a567de3bc 100644 --- a/gdk-pixbuf/gdk-pixbuf-loader.c +++ b/gdk-pixbuf/gdk-pixbuf-loader.c @@ -123,10 +123,12 @@ typedef struct gint height; gboolean size_fixed; gboolean needs_scale; + gchar *filename; } GdkPixbufLoaderPrivate; G_DEFINE_TYPE (GdkPixbufLoader, gdk_pixbuf_loader, G_TYPE_OBJECT) + static void gdk_pixbuf_loader_class_init (GdkPixbufLoaderClass *class) { @@ -250,6 +252,8 @@ gdk_pixbuf_loader_finalize (GObject *object) if (priv->animation) g_object_unref (priv->animation); + g_free (priv->filename); + g_free (priv); G_OBJECT_CLASS (gdk_pixbuf_loader_parent_class)->finalize (object); @@ -412,7 +416,7 @@ gdk_pixbuf_loader_load_module (GdkPixbufLoader *loader, { priv->image_module = _gdk_pixbuf_get_module (priv->header_buf, priv->header_buf_offset, - NULL, + priv->filename, error); } @@ -702,6 +706,19 @@ gdk_pixbuf_loader_new_with_mime_type (const char *mime_type, return retval; } +GdkPixbufLoader * +_gdk_pixbuf_loader_new_with_filename (const char *filename) +{ + GdkPixbufLoader *retval; + GdkPixbufLoaderPrivate *priv; + + retval = g_object_new (GDK_TYPE_PIXBUF_LOADER, NULL); + priv = retval->priv; + priv->filename = g_strdup (filename); + + return retval; +} + /** * gdk_pixbuf_loader_get_pixbuf: * @loader: A pixbuf loader. diff --git a/gdk-pixbuf/gdk-pixbuf-private.h b/gdk-pixbuf/gdk-pixbuf-private.h index 444ff3730..8f513079d 100644 --- a/gdk-pixbuf/gdk-pixbuf-private.h +++ b/gdk-pixbuf/gdk-pixbuf-private.h @@ -32,6 +32,7 @@ #include <glib-object.h> #include "gdk-pixbuf-core.h" +#include "gdk-pixbuf-loader.h" #include "gdk-pixbuf-io.h" #include "gdk-pixbuf-i18n.h" @@ -99,9 +100,11 @@ GdkPixbuf *_gdk_pixbuf_generic_image_load (GdkPixbufModule *image_module, GdkPixbufFormat *_gdk_pixbuf_get_format (GdkPixbufModule *image_module); + #endif /* GDK_PIXBUF_ENABLE_BACKEND */ GdkPixbuf * _gdk_pixbuf_new_from_resource_try_mmap (const char *resource_path); +GdkPixbufLoader *_gdk_pixbuf_loader_new_with_filename (const char *filename); #endif /* GDK_PIXBUF_PRIVATE_H */ |