mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-12 13:30:19 +00:00
loaders: Make it possible to load png options
We want to store some metadata in our symbolic pngs, so make it possible to get options when loading a png, along with the texture. Update all callers.
This commit is contained in:
parent
585dadf575
commit
08d1353cde
@ -563,7 +563,7 @@ gdk_texture_new_from_bytes_internal (GBytes *bytes,
|
||||
{
|
||||
if (gdk_is_png (bytes))
|
||||
{
|
||||
return gdk_load_png (bytes, error);
|
||||
return gdk_load_png (bytes, NULL, error);
|
||||
}
|
||||
else if (gdk_is_jpeg (bytes))
|
||||
{
|
||||
|
@ -127,15 +127,18 @@ png_simple_warning_callback (png_structp png,
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Public API */
|
||||
/* {{{ Public API */
|
||||
|
||||
GdkTexture *
|
||||
gdk_load_png (GBytes *bytes,
|
||||
GError **error)
|
||||
gdk_load_png (GBytes *bytes,
|
||||
GHashTable *options,
|
||||
GError **error)
|
||||
{
|
||||
png_io io;
|
||||
png_struct *png = NULL;
|
||||
png_info *info;
|
||||
png_textp text;
|
||||
int num_texts;
|
||||
guint width, height;
|
||||
gsize i, stride;
|
||||
int depth, color_type;
|
||||
@ -297,6 +300,17 @@ gdk_load_png (GBytes *bytes,
|
||||
texture = gdk_memory_texture_new (width, height, format, out_bytes, stride);
|
||||
g_bytes_unref (out_bytes);
|
||||
|
||||
if (options && png_get_text (png, info, &text, &num_texts))
|
||||
{
|
||||
for (i = 0; i < num_texts; i++)
|
||||
{
|
||||
if (text->compression != -1)
|
||||
continue;
|
||||
|
||||
g_hash_table_insert (options, g_strdup (text->key), g_strdup (text->text));
|
||||
}
|
||||
}
|
||||
|
||||
g_free (row_pointers);
|
||||
png_destroy_read_struct (&png, &info, NULL);
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#define PNG_SIGNATURE "\x89PNG"
|
||||
|
||||
GdkTexture *gdk_load_png (GBytes *bytes,
|
||||
GHashTable *options,
|
||||
GError **error);
|
||||
|
||||
GBytes *gdk_save_png (GdkTexture *texture);
|
||||
|
@ -49,7 +49,7 @@ test_load_image (gconstpointer data)
|
||||
|
||||
/* use the internal api, we want to avoid pixbuf fallback here */
|
||||
if (g_str_has_suffix (filename, ".png"))
|
||||
texture = gdk_load_png (bytes, &error);
|
||||
texture = gdk_load_png (bytes, NULL, &error);
|
||||
else if (g_str_has_suffix (filename, ".tiff"))
|
||||
texture = gdk_load_tiff (bytes, &error);
|
||||
else if (g_str_has_suffix (filename, ".jpeg"))
|
||||
|
Loading…
Reference in New Issue
Block a user