1 /* -*- mode: C; c-file-style: "linux" -*- */
2 /* GdkPixbuf library - Main loading interface.
4 * Copyright (C) 1999 The Free Software Foundation
6 * Authors: Miguel de Icaza <miguel@gnu.org>
7 * Federico Mena-Quintero <federico@gimp.org>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
36 #include "gdk-pixbuf-private.h"
37 #include "gdk-pixbuf-io.h"
38 #include "gdk-pixbuf-alias.h"
40 #include <glib/gstdio.h>
49 format_check (GdkPixbufModule *module, guchar *buffer, int size)
53 GdkPixbufModulePattern *pattern;
57 for (pattern = module->info->signature; pattern->prefix; pattern++) {
58 if (pattern->mask && pattern->mask[0] == '*') {
59 prefix = pattern->prefix + 1;
60 mask = pattern->mask + 1;
64 prefix = pattern->prefix;
68 for (i = 0; i < size; i++) {
69 for (j = 0; i + j < size && prefix[j] != 0; j++) {
70 m = mask ? mask[j] : ' ';
72 if (buffer[i + j] != prefix[j])
76 if (buffer[i + j] == prefix[j])
80 if (buffer[i + j] != 0)
84 if (buffer[i + j] == 0)
90 return pattern->relevance;
99 G_LOCK_DEFINE_STATIC (init_lock);
100 G_LOCK_DEFINE_STATIC (threadunsafe_loader_lock);
103 _gdk_pixbuf_lock (GdkPixbufModule *image_module)
105 if (g_threads_got_initialized &&
106 !(image_module->info->flags & GDK_PIXBUF_FORMAT_THREADSAFE)) {
107 G_LOCK (threadunsafe_loader_lock);
116 _gdk_pixbuf_unlock (GdkPixbufModule *image_module)
118 if (!(image_module->info->flags & GDK_PIXBUF_FORMAT_THREADSAFE)) {
119 G_UNLOCK (threadunsafe_loader_lock);
123 static GSList *file_formats = NULL;
125 static void gdk_pixbuf_io_init ();
128 get_file_formats (void)
131 if (file_formats == NULL)
132 gdk_pixbuf_io_init ();
133 G_UNLOCK (init_lock);
142 scan_string (const char **pos, GString *out)
144 const char *p = *pos, *q = *pos;
148 while (g_ascii_isspace (*p))
153 else if (*p == '"') {
156 for (q = p; (*q != '"') || quoted; q++) {
159 quoted = (*q == '\\') && !quoted;
162 tmp = g_strndup (p, q - p);
163 tmp2 = g_strcompress (tmp);
164 g_string_truncate (out, 0);
165 g_string_append (out, tmp2);
177 scan_int (const char **pos, int *out)
181 const char *p = *pos;
183 while (g_ascii_isspace (*p))
186 if (*p < '0' || *p > '9')
189 while ((*p >= '0') && (*p <= '9') && i < sizeof (buf)) {
195 if (i == sizeof (buf))
208 skip_space (const char **pos)
210 const char *p = *pos;
212 while (g_ascii_isspace (*p))
217 return !(*p == '\0');
222 /* DllMain function needed to tuck away the gdk-pixbuf DLL name */
223 G_WIN32_DLLMAIN_FOR_DLL_NAME (static, dll_name)
228 static char *toplevel = NULL;
230 if (toplevel == NULL)
231 toplevel = g_win32_get_package_installation_subdirectory
232 (GETTEXT_PACKAGE, dll_name, "");
238 get_sysconfdir (void)
240 static char *sysconfdir = NULL;
242 if (sysconfdir == NULL)
243 sysconfdir = g_win32_get_package_installation_subdirectory
244 (GETTEXT_PACKAGE, dll_name, "etc");
249 #undef GTK_SYSCONFDIR
250 #define GTK_SYSCONFDIR get_sysconfdir()
253 correct_prefix (gchar **path)
255 if (strncmp (*path, GTK_PREFIX "/", strlen (GTK_PREFIX "/")) == 0 ||
256 strncmp (*path, GTK_PREFIX "\\", strlen (GTK_PREFIX "\\")) == 0)
258 /* This is an entry put there by gdk-pixbuf-query-loaders on the
259 * packager's system. On Windows a prebuilt GTK+ package can be
260 * installed in a random location. The gdk-pixbuf.loaders file
261 * distributed in such a package contains paths from the package
262 * builder's machine. Replace the build-time prefix with the
263 * installation prefix on this machine.
266 *path = g_strconcat (get_toplevel (), tem + strlen (GTK_PREFIX), NULL);
271 #endif /* G_OS_WIN32 */
274 gdk_pixbuf_get_module_file (void)
276 gchar *result = g_strdup (g_getenv ("GDK_PIXBUF_MODULE_FILE"));
279 result = g_build_filename (GTK_SYSCONFDIR, "gtk-2.0", "gdk-pixbuf.loaders", NULL);
285 gdk_pixbuf_io_init (void)
290 GString *tmp_buf = g_string_new (NULL);
291 gboolean have_error = FALSE;
292 GdkPixbufModule *module = NULL;
293 gchar *filename = gdk_pixbuf_get_module_file ();
296 GdkPixbufModulePattern *pattern;
297 GError *error = NULL;
299 channel = g_io_channel_new_file (filename, "r", &error);
301 g_warning ("Cannot open pixbuf loader module file '%s': %s",
302 filename, error->message);
306 while (!have_error && g_io_channel_read_line (channel, &line_buf, NULL, &term, NULL) == G_IO_STATUS_NORMAL) {
313 if (!skip_space (&p)) {
314 /* Blank line marking the end of a module
316 if (module && *p != '#') {
318 correct_prefix (&module->module_path);
320 file_formats = g_slist_prepend (file_formats, module);
331 /* Read a module location
333 module = g_new0 (GdkPixbufModule, 1);
336 if (!scan_string (&p, tmp_buf)) {
337 g_warning ("Error parsing loader info in '%s'\n %s",
341 module->module_path = g_strdup (tmp_buf->str);
343 else if (!module->module_name) {
344 module->info = g_new0 (GdkPixbufFormat, 1);
345 if (!scan_string (&p, tmp_buf)) {
346 g_warning ("Error parsing loader info in '%s'\n %s",
350 module->info->name = g_strdup (tmp_buf->str);
351 module->module_name = module->info->name;
353 if (!scan_int (&p, &flags)) {
354 g_warning ("Error parsing loader info in '%s'\n %s",
358 module->info->flags = flags;
360 if (!scan_string (&p, tmp_buf)) {
361 g_warning ("Error parsing loader info in '%s'\n %s",
365 if (tmp_buf->str[0] != 0)
366 module->info->domain = g_strdup (tmp_buf->str);
368 if (!scan_string (&p, tmp_buf)) {
369 g_warning ("Error parsing loader info in '%s'\n %s",
373 module->info->description = g_strdup (tmp_buf->str);
375 else if (!module->info->mime_types) {
377 module->info->mime_types = g_new0 (gchar*, 1);
378 while (scan_string (&p, tmp_buf)) {
379 if (tmp_buf->str[0] != 0) {
380 module->info->mime_types =
381 g_realloc (module->info->mime_types, (n + 1) * sizeof (gchar*));
382 module->info->mime_types[n - 1] = g_strdup (tmp_buf->str);
383 module->info->mime_types[n] = NULL;
388 else if (!module->info->extensions) {
390 module->info->extensions = g_new0 (gchar*, 1);
391 while (scan_string (&p, tmp_buf)) {
392 if (tmp_buf->str[0] != 0) {
393 module->info->extensions =
394 g_realloc (module->info->extensions, (n + 1) * sizeof (gchar*));
395 module->info->extensions[n - 1] = g_strdup (tmp_buf->str);
396 module->info->extensions[n] = NULL;
403 module->info->signature = (GdkPixbufModulePattern *)
404 g_realloc (module->info->signature, (n_patterns + 1) * sizeof (GdkPixbufModulePattern));
405 pattern = module->info->signature + n_patterns;
406 pattern->prefix = NULL;
407 pattern->mask = NULL;
408 pattern->relevance = 0;
410 if (!scan_string (&p, tmp_buf))
412 pattern->prefix = g_strdup (tmp_buf->str);
414 if (!scan_string (&p, tmp_buf))
417 pattern->mask = g_strdup (tmp_buf->str);
419 pattern->mask = NULL;
421 if (!scan_int (&p, &pattern->relevance))
427 g_free (pattern->prefix);
428 g_free (pattern->mask);
430 g_warning ("Error parsing loader info in '%s'\n %s",
437 g_string_free (tmp_buf, TRUE);
438 g_io_channel_unref (channel);
442 /* actually load the image handler - gdk_pixbuf_get_module only get a */
443 /* reference to the module to load, it doesn't actually load it */
444 /* perhaps these actions should be combined in one function */
446 _gdk_pixbuf_load_module_unlocked (GdkPixbufModule *image_module,
453 g_return_val_if_fail (image_module->module == NULL, FALSE);
455 path = image_module->module_path;
456 module = g_module_open (path, G_MODULE_BIND_LAZY);
461 GDK_PIXBUF_ERROR_FAILED,
462 _("Unable to load image-loading module: %s: %s"),
463 path, g_module_error ());
467 image_module->module = module;
469 if (g_module_symbol (module, "fill_vtable", &sym)) {
470 GdkPixbufModuleFillVtableFunc func = (GdkPixbufModuleFillVtableFunc) sym;
471 (* func) (image_module);
476 GDK_PIXBUF_ERROR_FAILED,
477 _("Image-loading module %s does not export the proper interface; perhaps it's from a different GTK version?"),
484 _gdk_pixbuf_load_module (GdkPixbufModule *image_module,
488 gboolean locked = FALSE;
490 /* be extra careful, maybe the module initializes
493 if (g_threads_got_initialized)
498 ret = _gdk_pixbuf_load_module_unlocked (image_module, error);
500 G_UNLOCK (init_lock);
504 #else /* !USE_GMODULE */
506 #define module(type) \
507 extern void MODULE_ENTRY (type, fill_info) (GdkPixbufFormat *info); \
508 extern void MODULE_ENTRY (type, fill_vtable) (GdkPixbufModule *module)
526 _gdk_pixbuf_load_module (GdkPixbufModule *image_module,
529 GdkPixbufModuleFillInfoFunc fill_info = NULL;
530 GdkPixbufModuleFillVtableFunc fill_vtable = NULL;
532 image_module->module = (void *) 1;
535 /* Ugly hack so we can use else if unconditionally below ;-) */
539 else if (strcmp (image_module->module_name, "png") == 0) {
540 fill_info = MODULE_ENTRY (png, fill_info);
541 fill_vtable = MODULE_ENTRY (png, fill_vtable);
546 else if (strcmp (image_module->module_name, "bmp") == 0) {
547 fill_info = MODULE_ENTRY (bmp, fill_info);
548 fill_vtable = MODULE_ENTRY (bmp, fill_vtable);
553 else if (strcmp (image_module->module_name, "wbmp") == 0) {
554 fill_info = MODULE_ENTRY (wbmp, fill_info);
555 fill_vtable = MODULE_ENTRY (wbmp, fill_vtable);
560 else if (strcmp (image_module->module_name, "gif") == 0) {
561 fill_info = MODULE_ENTRY (gif, fill_info);
562 fill_vtable = MODULE_ENTRY (gif, fill_vtable);
567 else if (strcmp (image_module->module_name, "ico") == 0) {
568 fill_info = MODULE_ENTRY (ico, fill_info);
569 fill_vtable = MODULE_ENTRY (ico, fill_vtable);
574 else if (strcmp (image_module->module_name, "ani") == 0) {
575 fill_info = MODULE_ENTRY (ani, fill_info);
576 fill_vtable = MODULE_ENTRY (ani, fill_vtable);
581 else if (strcmp (image_module->module_name, "jpeg") == 0) {
582 fill_info = MODULE_ENTRY (jpeg, fill_info);
583 fill_vtable = MODULE_ENTRY (jpeg, fill_vtable);
588 else if (strcmp (image_module->module_name, "pnm") == 0) {
589 fill_info = MODULE_ENTRY (pnm, fill_info);
590 fill_vtable = MODULE_ENTRY (pnm, fill_vtable);
595 else if (strcmp (image_module->module_name, "ras") == 0) {
596 fill_info = MODULE_ENTRY (ras, fill_info);
597 fill_vtable = MODULE_ENTRY (ras, fill_vtable);
602 else if (strcmp (image_module->module_name, "tiff") == 0) {
603 fill_info = MODULE_ENTRY (tiff, fill_info);
604 fill_vtable = MODULE_ENTRY (tiff, fill_vtable);
609 else if (strcmp (image_module->module_name, "xpm") == 0) {
610 fill_info = MODULE_ENTRY (xpm, fill_info);
611 fill_vtable = MODULE_ENTRY (xpm, fill_vtable);
616 else if (strcmp (image_module->module_name, "xbm") == 0) {
617 fill_info = MODULE_ENTRY (xbm, fill_info);
618 fill_vtable = MODULE_ENTRY (xbm, fill_vtable);
623 else if (strcmp (image_module->module_name, "tga") == 0) {
624 fill_info = MODULE_ENTRY (tga, fill_info);
625 fill_vtable = MODULE_ENTRY (tga, fill_vtable);
630 else if (strcmp (image_module->module_name, "pcx") == 0) {
631 fill_info = MODULE_ENTRY (pcx, fill_info);
632 fill_vtable = MODULE_ENTRY (pcx, fill_vtable);
637 (* fill_vtable) (image_module);
638 image_module->info = g_new0 (GdkPixbufFormat, 1);
639 (* fill_info) (image_module->info);
645 GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
646 _("Image type '%s' is not supported"),
647 image_module->module_name);
654 gdk_pixbuf_io_init ()
656 gchar *included_formats[] = {
657 "ani", "png", "bmp", "wbmp", "gif",
658 "ico", "jpeg", "pnm", "ras", "tiff",
659 "xpm", "xbm", "tga", "pcx",
663 GdkPixbufModule *module = NULL;
665 for (name = included_formats; *name; name++) {
666 module = g_new0 (GdkPixbufModule, 1);
667 module->module_name = *name;
668 if (_gdk_pixbuf_load_module (module, NULL))
669 file_formats = g_slist_prepend (file_formats, module);
675 #endif /* !USE_GMODULE */
680 _gdk_pixbuf_get_named_module (const char *name,
685 for (modules = get_file_formats (); modules; modules = g_slist_next (modules)) {
686 GdkPixbufModule *module = (GdkPixbufModule *)modules->data;
688 if (module->info->disabled)
691 if (!strcmp (name, module->module_name))
697 GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
698 _("Image type '%s' is not supported"),
705 _gdk_pixbuf_get_module (guchar *buffer, guint size,
706 const gchar *filename,
711 gint score, best = 0;
712 GdkPixbufModule *selected = NULL;
713 gchar *display_name = NULL;
715 for (modules = get_file_formats (); modules; modules = g_slist_next (modules)) {
716 GdkPixbufModule *module = (GdkPixbufModule *)modules->data;
718 if (module->info->disabled)
721 score = format_check (module, buffer, size);
729 if (selected != NULL)
734 display_name = g_filename_display_name (filename);
737 GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
738 _("Couldn't recognize the image file format for file '%s'"),
740 g_free (display_name);
745 GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
746 _("Unrecognized image file format"));
754 prepared_notify (GdkPixbuf *pixbuf,
755 GdkPixbufAnimation *anim,
759 g_object_ref (pixbuf);
760 *((GdkPixbuf **)user_data) = pixbuf;
764 _gdk_pixbuf_generic_image_load (GdkPixbufModule *module,
770 GdkPixbuf *pixbuf = NULL;
771 GdkPixbufAnimation *animation = NULL;
775 locked = _gdk_pixbuf_lock (module);
777 if (module->load != NULL) {
778 pixbuf = (* module->load) (f, error);
779 } else if (module->begin_load != NULL) {
781 context = module->begin_load (NULL, prepared_notify, NULL, &pixbuf, error);
786 while (!feof (f) && !ferror (f)) {
787 length = fread (buffer, 1, sizeof (buffer), f);
789 if (!module->load_increment (context, buffer, length, error)) {
790 module->stop_load (context, NULL);
791 if (pixbuf != NULL) {
792 g_object_unref (pixbuf);
799 if (!module->stop_load (context, error)) {
800 if (pixbuf != NULL) {
801 g_object_unref (pixbuf);
805 } else if (module->load_animation != NULL) {
806 animation = (* module->load_animation) (f, error);
807 if (animation != NULL) {
808 pixbuf = gdk_pixbuf_animation_get_static_image (animation);
810 g_object_ref (pixbuf);
811 g_object_unref (animation);
817 _gdk_pixbuf_unlock (module);
822 * gdk_pixbuf_new_from_file:
823 * @filename: Name of file to load, in the GLib file name encoding
824 * @error: Return location for an error
826 * Creates a new pixbuf by loading an image from a file. The file format is
827 * detected automatically. If %NULL is returned, then @error will be set.
828 * Possible errors are in the #GDK_PIXBUF_ERROR and #G_FILE_ERROR domains.
830 * Return value: A newly-created pixbuf with a reference count of 1, or %NULL if
831 * any of several error conditions occurred: the file could not be opened,
832 * there was no loader for the file's format, there was not enough memory to
833 * allocate the image buffer, or the image file contained invalid data.
836 gdk_pixbuf_new_from_file (const char *filename,
843 GdkPixbufModule *image_module;
846 g_return_val_if_fail (filename != NULL, NULL);
847 g_return_val_if_fail (error == NULL || *error == NULL, NULL);
849 display_name = g_filename_display_name (filename);
851 f = g_fopen (filename, "rb");
855 g_file_error_from_errno (errno),
856 _("Failed to open file '%s': %s"),
859 g_free (display_name);
863 size = fread (&buffer, 1, sizeof (buffer), f);
867 GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
868 _("Image file '%s' contains no data"),
870 g_free (display_name);
875 image_module = _gdk_pixbuf_get_module (buffer, size, filename, error);
876 if (image_module == NULL) {
877 g_free (display_name);
882 if (image_module->module == NULL)
883 if (!_gdk_pixbuf_load_module (image_module, error)) {
884 g_free (display_name);
889 fseek (f, 0, SEEK_SET);
890 pixbuf = _gdk_pixbuf_generic_image_load (image_module, f, error);
893 if (pixbuf == NULL && error != NULL && *error == NULL) {
895 /* I don't trust these crufty longjmp()'ing image libs
896 * to maintain proper error invariants, and I don't
897 * want user code to segfault as a result. We need to maintain
898 * the invariant that error gets set if NULL is returned.
901 g_warning ("Bug! gdk-pixbuf loader '%s' didn't set an error on failure.", image_module->module_name);
904 GDK_PIXBUF_ERROR_FAILED,
905 _("Failed to load image '%s': reason not known, probably a corrupt image file"),
907 } else if (error != NULL && *error != NULL) {
909 /* Add the filename to the error message */
914 e->message = g_strdup_printf (_("Failed to load image '%s': %s"),
920 g_free (display_name);
926 #undef gdk_pixbuf_new_from_file
928 gdk_pixbuf_new_from_file (const char *filename,
931 gchar *utf8_filename =
932 g_locale_to_utf8 (filename, -1, NULL, NULL, error);
935 if (utf8_filename == NULL)
938 retval = gdk_pixbuf_new_from_file_utf8 (utf8_filename, error);
940 g_free (utf8_filename);
947 size_prepared_cb (GdkPixbufLoader *loader,
955 gboolean preserve_aspect_ratio;
958 g_return_if_fail (width > 0 && height > 0);
960 if (info->preserve_aspect_ratio &&
961 (info->width > 0 || info->height > 0)) {
964 width = width * (double)info->height/(double)height;
965 height = info->height;
967 else if (info->height < 0)
969 height = height * (double)info->width/(double)width;
972 else if ((double)height * (double)info->width >
973 (double)width * (double)info->height) {
974 width = 0.5 + (double)width * (double)info->height / (double)height;
975 height = info->height;
977 height = 0.5 + (double)height * (double)info->width / (double)width;
983 if (info->height > 0)
984 height = info->height;
987 gdk_pixbuf_loader_set_size (loader, width, height);
991 * gdk_pixbuf_new_from_file_at_size:
992 * @filename: Name of file to load, in the GLib file name encoding
993 * @width: The width the image should have or -1 to not constrain the width
994 * @height: The height the image should have or -1 to not constrain the height
995 * @error: Return location for an error
997 * Creates a new pixbuf by loading an image from a file. The file format is
998 * detected automatically. If %NULL is returned, then @error will be set.
999 * Possible errors are in the #GDK_PIXBUF_ERROR and #G_FILE_ERROR domains.
1000 * The image will be scaled to fit in the requested size, preserving
1001 * the image's aspect ratio.
1003 * Return value: A newly-created pixbuf with a reference count of 1, or
1004 * %NULL if any of several error conditions occurred: the file could not
1005 * be opened, there was no loader for the file's format, there was not
1006 * enough memory to allocate the image buffer, or the image file contained
1012 gdk_pixbuf_new_from_file_at_size (const char *filename,
1017 return gdk_pixbuf_new_from_file_at_scale (filename,
1024 #undef gdk_pixbuf_new_from_file_at_size
1027 gdk_pixbuf_new_from_file_at_size (const char *filename,
1032 gchar *utf8_filename =
1033 g_locale_to_utf8 (filename, -1, NULL, NULL, error);
1036 if (utf8_filename == NULL)
1039 retval = gdk_pixbuf_new_from_file_at_size_utf8 (utf8_filename,
1043 g_free (utf8_filename);
1050 * gdk_pixbuf_new_from_file_at_scale:
1051 * @filename: Name of file to load, in the GLib file name encoding
1052 * @width: The width the image should have or -1 to not constrain the width
1053 * @height: The height the image should have or -1 to not constrain the height
1054 * @preserve_aspect_ratio: %TRUE to preserve the image's aspect ratio
1055 * @error: Return location for an error
1057 * Creates a new pixbuf by loading an image from a file. The file format is
1058 * detected automatically. If %NULL is returned, then @error will be set.
1059 * Possible errors are in the #GDK_PIXBUF_ERROR and #G_FILE_ERROR domains.
1060 * The image will be scaled to fit in the requested size, optionally preserving
1061 * the image's aspect ratio.
1063 * When preserving the aspect ratio, a @width of -1 will cause the image
1064 * to be scaled to the exact given height, and a @height of -1 will cause
1065 * the image to be scaled to the exact given width. When not preserving
1066 * aspect ratio, a @width or @height of -1 means to not scale the image
1067 * at all in that dimension. Negative values for @width and @height are
1068 * allowed since 2.8.
1070 * Return value: A newly-created pixbuf with a reference count of 1, or %NULL
1071 * if any of several error conditions occurred: the file could not be opened,
1072 * there was no loader for the file's format, there was not enough memory to
1073 * allocate the image buffer, or the image file contained invalid data.
1078 gdk_pixbuf_new_from_file_at_scale (const char *filename,
1081 gboolean preserve_aspect_ratio,
1085 GdkPixbufLoader *loader;
1088 guchar buffer [4096];
1094 gboolean preserve_aspect_ratio;
1097 g_return_val_if_fail (filename != NULL, NULL);
1098 g_return_val_if_fail (width > 0 || width == -1, NULL);
1099 g_return_val_if_fail (height > 0 || height == -1, NULL);
1101 f = g_fopen (filename, "rb");
1103 gchar *display_name = g_filename_display_name (filename);
1106 g_file_error_from_errno (errno),
1107 _("Failed to open file '%s': %s"),
1109 g_strerror (errno));
1110 g_free (display_name);
1114 loader = gdk_pixbuf_loader_new ();
1117 info.height = height;
1118 info.preserve_aspect_ratio = preserve_aspect_ratio;
1120 g_signal_connect (loader, "size-prepared", G_CALLBACK (size_prepared_cb), &info);
1122 while (!feof (f) && !ferror (f)) {
1123 length = fread (buffer, 1, sizeof (buffer), f);
1125 if (!gdk_pixbuf_loader_write (loader, buffer, length, error)) {
1126 gdk_pixbuf_loader_close (loader, NULL);
1128 g_object_unref (loader);
1135 if (!gdk_pixbuf_loader_close (loader, error)) {
1136 g_object_unref (loader);
1140 pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
1143 gchar *display_name = g_filename_display_name (filename);
1144 g_object_unref (loader);
1147 GDK_PIXBUF_ERROR_FAILED,
1148 _("Failed to load image '%s': reason not known, probably a corrupt image file"),
1150 g_free (display_name);
1154 g_object_ref (pixbuf);
1156 g_object_unref (loader);
1163 #undef gdk_pixbuf_new_from_file_at_scale
1166 gdk_pixbuf_new_from_file_at_scale (const char *filename,
1169 gboolean preserve_aspect_ratio,
1172 gchar *utf8_filename =
1173 g_locale_to_utf8 (filename, -1, NULL, NULL, error);
1176 if (utf8_filename == NULL)
1179 retval = gdk_pixbuf_new_from_file_at_scale_utf8 (utf8_filename,
1181 preserve_aspect_ratio,
1184 g_free (utf8_filename);
1192 info_cb (GdkPixbufLoader *loader,
1198 GdkPixbufFormat *format;
1203 g_return_if_fail (width > 0 && height > 0);
1205 info->format = gdk_pixbuf_loader_get_format (loader);
1206 info->width = width;
1207 info->height = height;
1209 gdk_pixbuf_loader_set_size (loader, 0, 0);
1213 * gdk_pixbuf_get_file_info:
1214 * @filename: The name of the file to identify.
1215 * @width: Return location for the width of the image, or %NULL
1216 * @height: Return location for the height of the image, or %NULL
1218 * Parses an image file far enough to determine its format and size.
1220 * Returns: A #GdkPixbufFormat describing the image format of the file
1221 * or %NULL if the image format wasn't recognized. The return value
1222 * is owned by GdkPixbuf and should not be freed.
1227 gdk_pixbuf_get_file_info (const gchar *filename,
1231 GdkPixbufLoader *loader;
1232 guchar buffer [4096];
1236 GdkPixbufFormat *format;
1241 g_return_val_if_fail (filename != NULL, NULL);
1243 f = g_fopen (filename, "rb");
1247 loader = gdk_pixbuf_loader_new ();
1253 g_signal_connect (loader, "size-prepared", G_CALLBACK (info_cb), &info);
1255 while (!feof (f) && !ferror (f)) {
1256 length = fread (buffer, 1, sizeof (buffer), f);
1258 if (!gdk_pixbuf_loader_write (loader, buffer, length, NULL))
1261 if (info.format != NULL)
1266 gdk_pixbuf_loader_close (loader, NULL);
1267 g_object_unref (loader);
1270 *width = info.width;
1272 *height = info.height;
1278 * gdk_pixbuf_new_from_xpm_data:
1279 * @data: Pointer to inline XPM data.
1281 * Creates a new pixbuf by parsing XPM data in memory. This data is commonly
1282 * the result of including an XPM file into a program's C source.
1284 * Return value: A newly-created pixbuf with a reference count of 1.
1287 gdk_pixbuf_new_from_xpm_data (const char **data)
1289 GdkPixbuf *(* load_xpm_data) (const char **data);
1291 GError *error = NULL;
1292 GdkPixbufModule *xpm_module;
1295 xpm_module = _gdk_pixbuf_get_named_module ("xpm", &error);
1296 if (xpm_module == NULL) {
1297 g_warning ("Error loading XPM image loader: %s", error->message);
1298 g_error_free (error);
1302 if (xpm_module->module == NULL) {
1303 if (!_gdk_pixbuf_load_module (xpm_module, &error)) {
1304 g_warning ("Error loading XPM image loader: %s", error->message);
1305 g_error_free (error);
1310 locked = _gdk_pixbuf_lock (xpm_module);
1312 if (xpm_module->load_xpm_data == NULL) {
1313 g_warning ("gdk-pixbuf XPM module lacks XPM data capability");
1316 load_xpm_data = xpm_module->load_xpm_data;
1317 pixbuf = (* load_xpm_data) (data);
1321 _gdk_pixbuf_unlock (xpm_module);
1326 collect_save_options (va_list opts,
1339 next = va_arg (opts, gchar*);
1343 val = va_arg (opts, gchar*);
1348 *keys = g_realloc (*keys, sizeof(gchar*) * (count + 1));
1349 *vals = g_realloc (*vals, sizeof(gchar*) * (count + 1));
1351 (*keys)[count-1] = g_strdup (key);
1352 (*vals)[count-1] = g_strdup (val);
1354 (*keys)[count] = NULL;
1355 (*vals)[count] = NULL;
1357 next = va_arg (opts, gchar*);
1362 save_to_file_callback (const gchar *buf,
1367 FILE *filehandle = data;
1370 n = fwrite (buf, 1, count, filehandle);
1374 g_file_error_from_errno (errno),
1375 _("Error writing to image file: %s"),
1376 g_strerror (errno));
1383 gdk_pixbuf_real_save (GdkPixbuf *pixbuf,
1391 GdkPixbufModule *image_module = NULL;
1394 image_module = _gdk_pixbuf_get_named_module (type, error);
1396 if (image_module == NULL)
1399 if (image_module->module == NULL)
1400 if (!_gdk_pixbuf_load_module (image_module, error))
1403 locked = _gdk_pixbuf_lock (image_module);
1405 if (image_module->save) {
1407 ret = (* image_module->save) (filehandle, pixbuf,
1410 } else if (image_module->save_to_callback) {
1411 /* save with simple callback */
1412 ret = (* image_module->save_to_callback) (save_to_file_callback,
1420 GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION,
1421 _("This build of gdk-pixbuf does not support saving the image format: %s"),
1427 _gdk_pixbuf_unlock (image_module);
1431 #define TMP_FILE_BUF_SIZE 4096
1434 save_to_callback_with_tmp_file (GdkPixbufModule *image_module,
1436 GdkPixbufSaveFunc save_func,
1444 gboolean retval = FALSE;
1447 gchar *filename = NULL;
1450 buf = g_try_malloc (TMP_FILE_BUF_SIZE);
1454 GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
1455 _("Insufficient memory to save image to callback"));
1459 fd = g_file_open_tmp ("gdkpixbuf-save-tmp.XXXXXX", &filename, error);
1462 f = fdopen (fd, "wb+");
1466 g_file_error_from_errno (errno),
1467 _("Failed to open temporary file"));
1471 locked = _gdk_pixbuf_lock (image_module);
1472 retval = (image_module->save) (f, pixbuf, keys, values, error);
1474 _gdk_pixbuf_unlock (image_module);
1480 n = fread (buf, 1, TMP_FILE_BUF_SIZE, f);
1482 if (!save_func (buf, n, error, user_data))
1485 if (n != TMP_FILE_BUF_SIZE)
1491 g_file_error_from_errno (errno),
1492 _("Failed to read from temporary file"));
1498 /* cleanup and return retval */
1502 g_unlink (filename);
1511 gdk_pixbuf_real_save_to_callback (GdkPixbuf *pixbuf,
1512 GdkPixbufSaveFunc save_func,
1520 GdkPixbufModule *image_module = NULL;
1523 image_module = _gdk_pixbuf_get_named_module (type, error);
1525 if (image_module == NULL)
1528 if (image_module->module == NULL)
1529 if (!_gdk_pixbuf_load_module (image_module, error))
1532 locked = _gdk_pixbuf_lock (image_module);
1534 if (image_module->save_to_callback) {
1536 ret = (* image_module->save_to_callback) (save_func, user_data,
1537 pixbuf, keys, values,
1539 } else if (image_module->save) {
1540 /* use a temporary file */
1541 ret = save_to_callback_with_tmp_file (image_module, pixbuf,
1542 save_func, user_data,
1549 GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION,
1550 _("This build of gdk-pixbuf does not support saving the image format: %s"),
1556 _gdk_pixbuf_unlock (image_module);
1563 * @pixbuf: a #GdkPixbuf.
1564 * @filename: name of file to save.
1565 * @type: name of file format.
1566 * @error: return location for error, or %NULL
1567 * @Varargs: list of key-value save options
1569 * Saves pixbuf to a file in format @type. By default, "jpeg", "png", "ico"
1570 * and "bmp" are possible file formats to save in, but more formats may be
1571 * installed. The list of all writable formats can be determined in the
1574 * <informalexample><programlisting>
1575 * void add_if_writable (GdkPixbufFormat *data, GSList **list)
1577 * if (gdk_pixbuf_format_is_writable (data))
1578 * *list = g_slist_prepend (*list, data);
1581 * GSList *formats = gdk_pixbuf_get_formats (<!-- -->);
1582 * GSList *writable_formats = NULL;
1583 * g_slist_foreach (formats, add_if_writable, &writable_formats);
1584 * g_slist_free (formats);
1585 * </programlisting></informalexample>
1587 * If @error is set, %FALSE will be returned. Possible errors include
1588 * those in the #GDK_PIXBUF_ERROR domain and those in the #G_FILE_ERROR domain.
1590 * The variable argument list should be %NULL-terminated; if not empty,
1591 * it should contain pairs of strings that modify the save
1592 * parameters. For example:
1593 * <informalexample><programlisting>
1594 * gdk_pixbuf_save (pixbuf, handle, "jpeg", &error,
1595 * "quality", "100", NULL);
1596 * </programlisting></informalexample>
1598 * Currently only few parameters exist. JPEG images can be saved with a
1599 * "quality" parameter; its value should be in the range [0,100].
1601 * Text chunks can be attached to PNG images by specifying parameters of
1602 * the form "tEXt::key", where key is an ASCII string of length 1-79.
1603 * The values are UTF-8 encoded strings. The PNG compression level can
1604 * be specified using the "compression" parameter; it's value is in an
1605 * integer in the range of [0,9].
1607 * ICO images can be saved in depth 16, 24, or 32, by using the "depth"
1608 * parameter. When the ICO saver is given "x_hot" and "y_hot" parameters,
1609 * it produces a CUR instead of an ICO.
1611 * Return value: whether an error was set
1615 gdk_pixbuf_save (GdkPixbuf *pixbuf,
1616 const char *filename,
1621 gchar **keys = NULL;
1622 gchar **values = NULL;
1626 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1628 va_start (args, error);
1630 collect_save_options (args, &keys, &values);
1634 result = gdk_pixbuf_savev (pixbuf, filename, type,
1639 g_strfreev (values);
1646 #undef gdk_pixbuf_save
1649 gdk_pixbuf_save (GdkPixbuf *pixbuf,
1650 const char *filename,
1655 char *utf8_filename;
1656 gchar **keys = NULL;
1657 gchar **values = NULL;
1661 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1663 utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, error);
1665 if (utf8_filename == NULL)
1668 va_start (args, error);
1670 collect_save_options (args, &keys, &values);
1674 result = gdk_pixbuf_savev_utf8 (pixbuf, utf8_filename, type,
1678 g_free (utf8_filename);
1681 g_strfreev (values);
1690 * @pixbuf: a #GdkPixbuf.
1691 * @filename: name of file to save.
1692 * @type: name of file format.
1693 * @option_keys: name of options to set, %NULL-terminated
1694 * @option_values: values for named options
1695 * @error: return location for error, or %NULL
1697 * Saves pixbuf to a file in @type, which is currently "jpeg", "png", "ico" or "bmp".
1698 * If @error is set, %FALSE will be returned.
1699 * See gdk_pixbuf_save () for more details.
1701 * Return value: whether an error was set
1705 gdk_pixbuf_savev (GdkPixbuf *pixbuf,
1706 const char *filename,
1709 char **option_values,
1715 g_return_val_if_fail (filename != NULL, FALSE);
1716 g_return_val_if_fail (type != NULL, FALSE);
1717 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1719 f = g_fopen (filename, "wb");
1722 gchar *display_name = g_filename_display_name (filename);
1725 g_file_error_from_errno (errno),
1726 _("Failed to open '%s' for writing: %s"),
1728 g_strerror (errno));
1729 g_free (display_name);
1734 result = gdk_pixbuf_real_save (pixbuf, f, type,
1735 option_keys, option_values,
1740 g_return_val_if_fail (error == NULL || *error != NULL, FALSE);
1745 if (fclose (f) < 0) {
1746 gchar *display_name = g_filename_display_name (filename);
1749 g_file_error_from_errno (errno),
1750 _("Failed to close '%s' while writing image, all data may not have been saved: %s"),
1752 g_strerror (errno));
1753 g_free (display_name);
1762 #undef gdk_pixbuf_savev
1765 gdk_pixbuf_savev (GdkPixbuf *pixbuf,
1766 const char *filename,
1769 char **option_values,
1772 char *utf8_filename;
1775 g_return_val_if_fail (filename != NULL, FALSE);
1777 utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, error);
1779 if (utf8_filename == NULL)
1782 retval = gdk_pixbuf_savev_utf8 (pixbuf, utf8_filename, type,
1783 option_keys, option_values, error);
1785 g_free (utf8_filename);
1793 * gdk_pixbuf_save_to_callback:
1794 * @pixbuf: a #GdkPixbuf.
1795 * @save_func: a function that is called to save each block of data that
1796 * the save routine generates.
1797 * @user_data: user data to pass to the save function.
1798 * @type: name of file format.
1799 * @error: return location for error, or %NULL
1800 * @Varargs: list of key-value save options
1802 * Saves pixbuf in format @type by feeding the produced data to a
1803 * callback. Can be used when you want to store the image to something
1804 * other than a file, such as an in-memory buffer or a socket.
1805 * If @error is set, %FALSE will be returned. Possible errors
1806 * include those in the #GDK_PIXBUF_ERROR domain and whatever the save
1807 * function generates.
1809 * See gdk_pixbuf_save() for more details.
1811 * Return value: whether an error was set
1816 gdk_pixbuf_save_to_callback (GdkPixbuf *pixbuf,
1817 GdkPixbufSaveFunc save_func,
1823 gchar **keys = NULL;
1824 gchar **values = NULL;
1828 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1830 va_start (args, error);
1832 collect_save_options (args, &keys, &values);
1836 result = gdk_pixbuf_save_to_callbackv (pixbuf, save_func, user_data,
1841 g_strfreev (values);
1847 * gdk_pixbuf_save_to_callbackv:
1848 * @pixbuf: a #GdkPixbuf.
1849 * @save_func: a function that is called to save each block of data that
1850 * the save routine generates.
1851 * @user_data: user data to pass to the save function.
1852 * @type: name of file format.
1853 * @option_keys: name of options to set, %NULL-terminated
1854 * @option_values: values for named options
1855 * @error: return location for error, or %NULL
1857 * Saves pixbuf to a callback in format @type, which is currently "jpeg",
1858 * "png", "ico" or "bmp". If @error is set, %FALSE will be returned. See
1859 * gdk_pixbuf_save_to_callback () for more details.
1861 * Return value: whether an error was set
1866 gdk_pixbuf_save_to_callbackv (GdkPixbuf *pixbuf,
1867 GdkPixbufSaveFunc save_func,
1871 char **option_values,
1877 g_return_val_if_fail (save_func != NULL, FALSE);
1878 g_return_val_if_fail (type != NULL, FALSE);
1879 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1881 result = gdk_pixbuf_real_save_to_callback (pixbuf,
1882 save_func, user_data, type,
1883 option_keys, option_values,
1887 g_return_val_if_fail (error == NULL || *error != NULL, FALSE);
1895 * gdk_pixbuf_save_to_buffer:
1896 * @pixbuf: a #GdkPixbuf.
1897 * @buffer: location to receive a pointer to the new buffer.
1898 * @buffer_size: location to receive the size of the new buffer.
1899 * @type: name of file format.
1900 * @error: return location for error, or %NULL
1901 * @Varargs: list of key-value save options
1903 * Saves pixbuf to a new buffer in format @type, which is currently "jpeg",
1904 * "png", "ico" or "bmp". This is a convenience function that uses
1905 * gdk_pixbuf_save_to_callback() to do the real work. Note that the buffer
1906 * is not nul-terminated and may contain embedded nuls.
1907 * If @error is set, %FALSE will be returned and @string will be set to
1908 * %NULL. Possible errors include those in the #GDK_PIXBUF_ERROR
1911 * See gdk_pixbuf_save() for more details.
1913 * Return value: whether an error was set
1918 gdk_pixbuf_save_to_buffer (GdkPixbuf *pixbuf,
1925 gchar **keys = NULL;
1926 gchar **values = NULL;
1930 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1932 va_start (args, error);
1934 collect_save_options (args, &keys, &values);
1938 result = gdk_pixbuf_save_to_bufferv (pixbuf, buffer, buffer_size,
1943 g_strfreev (values);
1948 struct SaveToBufferData {
1954 save_to_buffer_callback (const gchar *data,
1959 struct SaveToBufferData *sdata = user_data;
1963 if (sdata->len + count > sdata->max) {
1964 new_max = MAX (sdata->max*2, sdata->len + count);
1965 new_buffer = g_try_realloc (sdata->buffer, new_max);
1969 GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
1970 _("Insufficient memory to save image into a buffer"));
1973 sdata->buffer = new_buffer;
1974 sdata->max = new_max;
1976 memcpy (sdata->buffer + sdata->len, data, count);
1977 sdata->len += count;
1982 * gdk_pixbuf_save_to_bufferv:
1983 * @pixbuf: a #GdkPixbuf.
1984 * @buffer: location to receive a pointer to the new buffer.
1985 * @buffer_size: location to receive the size of the new buffer.
1986 * @type: name of file format.
1987 * @option_keys: name of options to set, %NULL-terminated
1988 * @option_values: values for named options
1989 * @error: return location for error, or %NULL
1991 * Saves pixbuf to a new buffer in format @type, which is currently "jpeg",
1992 * "png", "ico" or "bmp". See gdk_pixbuf_save_to_buffer() for more details.
1994 * Return value: whether an error was set
1999 gdk_pixbuf_save_to_bufferv (GdkPixbuf *pixbuf,
2004 char **option_values,
2007 static const gint initial_max = 1024;
2008 struct SaveToBufferData sdata;
2013 sdata.buffer = g_try_malloc (initial_max);
2014 sdata.max = initial_max;
2016 if (!sdata.buffer) {
2019 GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
2020 _("Insufficient memory to save image into a buffer"));
2024 if (!gdk_pixbuf_save_to_callbackv (pixbuf,
2025 save_to_buffer_callback, &sdata,
2026 type, option_keys, option_values,
2028 g_free (sdata.buffer);
2032 *buffer = sdata.buffer;
2033 *buffer_size = sdata.len;
2038 * gdk_pixbuf_format_get_name:
2039 * @format: a #GdkPixbufFormat
2041 * Returns the name of the format.
2043 * Return value: the name of the format.
2048 gdk_pixbuf_format_get_name (GdkPixbufFormat *format)
2050 g_return_val_if_fail (format != NULL, NULL);
2052 return g_strdup (format->name);
2056 * gdk_pixbuf_format_get_description:
2057 * @format: a #GdkPixbufFormat
2059 * Returns a description of the format.
2061 * Return value: a description of the format.
2066 gdk_pixbuf_format_get_description (GdkPixbufFormat *format)
2070 g_return_val_if_fail (format != NULL, NULL);
2072 if (format->domain != NULL)
2073 domain = format->domain;
2075 domain = GETTEXT_PACKAGE;
2076 description = dgettext (domain, format->description);
2078 return g_strdup (description);
2082 * gdk_pixbuf_format_get_mime_types:
2083 * @format: a #GdkPixbufFormat
2085 * Returns the mime types supported by the format.
2087 * Return value: a %NULL-terminated array of mime types which must be freed with
2088 * g_strfreev() when it is no longer needed.
2093 gdk_pixbuf_format_get_mime_types (GdkPixbufFormat *format)
2095 g_return_val_if_fail (format != NULL, NULL);
2097 return g_strdupv (format->mime_types);
2101 * gdk_pixbuf_format_get_extensions:
2102 * @format: a #GdkPixbufFormat
2104 * Returns the filename extensions typically used for files in the
2107 * Return value: a %NULL-terminated array of filename extensions which must be
2108 * freed with g_strfreev() when it is no longer needed.
2113 gdk_pixbuf_format_get_extensions (GdkPixbufFormat *format)
2115 g_return_val_if_fail (format != NULL, NULL);
2117 return g_strdupv (format->extensions);
2121 * gdk_pixbuf_format_is_writable:
2122 * @format: a #GdkPixbufFormat
2124 * Returns whether pixbufs can be saved in the given format.
2126 * Return value: whether pixbufs can be saved in the given format.
2131 gdk_pixbuf_format_is_writable (GdkPixbufFormat *format)
2133 g_return_val_if_fail (format != NULL, FALSE);
2135 return (format->flags & GDK_PIXBUF_FORMAT_WRITABLE) != 0;
2139 * gdk_pixbuf_format_is_scalable:
2140 * @format: a #GdkPixbufFormat
2142 * Returns whether this image format is scalable. If a file is in a
2143 * scalable format, it is preferable to load it at the desired size,
2144 * rather than loading it at the default size and scaling the
2145 * resulting pixbuf to the desired size.
2147 * Return value: whether this image format is scalable.
2152 gdk_pixbuf_format_is_scalable (GdkPixbufFormat *format)
2154 g_return_val_if_fail (format != NULL, FALSE);
2156 return (format->flags & GDK_PIXBUF_FORMAT_SCALABLE) != 0;
2160 * gdk_pixbuf_format_is_disabled:
2161 * @format: a #GdkPixbufFormat
2163 * Returns whether this image format is disabled. See
2164 * gdk_pixbuf_format_set_disabled().
2166 * Return value: whether this image format is disabled.
2171 gdk_pixbuf_format_is_disabled (GdkPixbufFormat *format)
2173 g_return_val_if_fail (format != NULL, FALSE);
2175 return format->disabled;
2179 * gdk_pixbuf_format_set_disabled:
2180 * @format: a #GdkPixbufFormat
2181 * @disabled: %TRUE to disable the format @format
2183 * Disables or enables an image format. If a format is disabled,
2184 * gdk-pixbuf won't use the image loader for this format to load
2185 * images. Applications can use this to avoid using image loaders
2186 * with an inappropriate license, see gdk_pixbuf_format_get_license().
2191 gdk_pixbuf_format_set_disabled (GdkPixbufFormat *format,
2194 g_return_if_fail (format != NULL);
2196 format->disabled = disabled != FALSE;
2200 * gdk_pixbuf_format_get_license:
2201 * @format: a #GdkPixbufFormat
2203 * Returns information about the license of the image loader
2204 * for the format. The returned string should be a shorthand for
2205 * a wellknown license, e.g. "LGPL", "GPL", "QPL", "GPL/QPL",
2206 * or "other" to indicate some other license.
2208 * Returns: a string describing the license of @format.
2213 gdk_pixbuf_format_get_license (GdkPixbufFormat *format)
2215 g_return_val_if_fail (format != NULL, NULL);
2217 return g_strdup (format->license);
2221 _gdk_pixbuf_get_format (GdkPixbufModule *module)
2223 g_return_val_if_fail (module != NULL, NULL);
2225 return module->info;
2229 * gdk_pixbuf_get_formats:
2231 * Obtains the available information about the image formats supported
2234 * Returns: A list of #GdkPixbufFormat<!-- -->s describing the supported
2235 * image formats. The list should be freed when it is no longer needed,
2236 * but the structures themselves are owned by #GdkPixbuf and should not be
2242 gdk_pixbuf_get_formats (void)
2244 GSList *result = NULL;
2247 for (modules = get_file_formats (); modules; modules = g_slist_next (modules)) {
2248 GdkPixbufModule *module = (GdkPixbufModule *)modules->data;
2249 GdkPixbufFormat *info = _gdk_pixbuf_get_format (module);
2250 result = g_slist_prepend (result, info);
2257 #define __GDK_PIXBUF_IO_C__
2258 #include "gdk-pixbuf-aliasdef.c"