All pastes #419730 Raw Edit

Miscellany

public c v1 · immutable
·published 2007-04-01 16:06 UTC
rendered paste body
#include <libgnome/libgnome.h>#include <libgnomeui/libgnomeui.h>#include <libgnomevfs/gnome-vfs.h>#include <libgnomevfs/gnome-vfs-mime.h>#include <stdio.h>#include <glib/gprintf.h>typedef struct	{		char *filename;		gboolean has_alpha;		int bits_per_sample;		int width;		int height;		GdkColorspace colorspace;	} info_pixbuf;intmain (int argc, char **argv){	GOptionContext *context = NULL;	GdkPixbuf *pixbuf;	info_pixbuf *fond;	GnomeProgram *program;	const GOptionEntry entries[]=	{		{"alpha", 'a', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_NONE, &fond->has_alpha, "fond transparent", NULL},		{"width", 'w', 0, G_OPTION_ARG_INT, &fond->width, "width", NULL},		{"height", 'h', 0, G_OPTION_ARG_INT, &fond->height, "height", NULL},		{"nom de fichier", 	'f', G_OPTION_FLAG_FILENAME , G_OPTION_ARG_STRING, &fond->filename, "Nom de l'image de fond", NULL},		{NULL, 0, 0, 0, NULL, NULL, NULL}	};	context = g_option_context_new("Pelemele");	fond = g_new0(info_pixbuf, 1);	g_option_context_add_main_entries(context, entries, NULL);	program = gnome_program_init("Pelemele", "0.0.1", LIBGNOMEUI_MODULE, argc, argv, GNOME_PARAM_GOPTION_CONTEXT, context, GNOME_PARAM_NONE);	g_printf("%s", fond->filename);	if (fond->width <= 0)	{		g_printerr("width <= 0");		exit(1);	}	if (fond->height <= 0)	{		g_printerr("height <= 0");		g_option_context_free(context);		exit(1);	}	pixbuf = gdk_pixbuf_new(fond->colorspace, fond->has_alpha, fond->bits_per_sample, fond->width, fond->height);	//gdk_pixbuf_copy_area(src_pixbuf, src_x, src_y, width, height, pixbuf, dest_x, dest_y);	if (fond->filename == NULL)	{		g_printerr("filename == NULL");		g_option_context_free(context);		gdk_pixbuf_unref(pixbuf);		exit(1);	}	gdk_pixbuf_savev(pixbuf, fond->filename,  "png" , NULL, NULL, NULL);	gdk_pixbuf_unref(pixbuf);	g_free(fond);	g_option_context_free(context);	g_object_unref(program);}