Run make
and then run ./gdkpb
with any pictures intended to load via gdk pixbuf.
Example: ./gdkpb ./testimg_with_no_suffix ./testimg.jpg
/gdkpb |
#include <gdk-pixbuf/gdk-pixbuf.h> | |
int main(int argc, char *argv[]) | |
{ | |
for (int i = 1; i < argc; i++) { | |
const char *f = argv[i]; | |
printf("Testing '%s'\n", f); | |
GdkPixbufFormat *format = gdk_pixbuf_get_file_info(f, NULL, NULL); | |
if (format) { | |
printf("Name: %s\n", gdk_pixbuf_format_get_name(format)); //it's leaking. But I don't care! | |
printf("Desc: %s\n", gdk_pixbuf_format_get_description(format)); //it's leaking. But I don't care! | |
printf("Disa: %d\n", gdk_pixbuf_format_is_disabled(format)); | |
gchar **exts = gdk_pixbuf_format_get_extensions(format); | |
printf("Supported extensions:"); | |
for(gchar **ext = exts; *ext; ext++) printf(" %s", *ext); | |
printf("\n"); | |
g_strfreev(exts); | |
} else { | |
printf("File image format not recognized for '%s'\n", f); | |
} | |
GError *e = NULL; | |
GdkPixbuf *pb = gdk_pixbuf_new_from_file(f, &e); | |
if (e) printf("Error loading file '%s': %s\n", f, e->message); | |
if (!e && pb) printf("Successfully loaded '%s'\n", f); | |
if (e) g_error_free(e); | |
if (pb) g_object_unref(pb); | |
printf("\n"); | |
} | |
return 0; | |
} |
PKG_CONFIG ?= pkg-config | |
pkg_config_packs := gdk-pixbuf-2.0 | |
.PHONY: all clean | |
all: gdkpb | |
clean: | |
rm -rf gdkpb | |
gdkpb: gdkpb.c | |
gcc -o $@ $(shell $(PKG_CONFIG) --libs --cflags ${pkg_config_packs}) $^ |