Re: Printing lines, shapes and pixmaps from a gnome canvas



Hi,

Sorry for the large diff file I posted this morning. Here is a new one with only relevant changes.
I also join a sample test program.

Best regards,
Jean

Attachment: libgnomecanvas-2.2.0.1.diff.bz2
Description: Binary data

#include <libgnomecanvas/libgnomecanvas.h>
#include <libgnomeprint/gnome-print.h>
#include <libgnomeprint/gnome-print-job.h>

int main (int argc, char *argv[])
{
	GnomeCanvas *canvas;
	GdkPixbuf *im;
	GnomeCanvasItem *image;
	GnomePrintJob *gpm;
	GnomePrintContext *gpc;
	double x, y;
	double matrix[6]={1.0, 0, 0, -1.0, 25, 750};
	gtk_init (&argc, &argv);
	canvas = GNOME_CANVAS (gnome_canvas_new());
	gtk_widget_set_size_request (GTK_WIDGET (canvas), 200, 200);
	gnome_canvas_set_scroll_region (GNOME_CANVAS (canvas), 0, 0, 200, 200);
	gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (canvas)),
					   gnome_canvas_ellipse_get_type (),
					   "x1", 50.0,
					   "y1", 50.0,
					   "x2", 150.0,
					   "y2", 150.0,
					   "outline_color", "black",
					   "width_units", 4.0,
					   NULL);
	im = gdk_pixbuf_new_from_file("image.png", NULL);
	x = 100 - (double) gdk_pixbuf_get_width(im) / 2.0;
	y = 100 - (double) gdk_pixbuf_get_height(im) / 2.0;
	if (im){
		image = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (canvas)),
					       gnome_canvas_pixbuf_get_type (),
					       "pixbuf", im,
					       "x", x,
					       "y", y,
					       "width", (double) gdk_pixbuf_get_width(im),
					       "height", (double) gdk_pixbuf_get_height(im),
					       NULL);
		gdk_pixbuf_unref(im);
	}
	while(gtk_events_pending()) gtk_main_iteration();

	gpm = gnome_print_job_new (NULL);
	gpc = gnome_print_job_get_context (gpm);

	gnome_print_beginpage (gpc, (const guchar*)"");
	gnome_print_concat (gpc, matrix);
	gnome_canvas_print (canvas, gpc);
	gnome_print_showpage (gpc);

	gnome_print_job_close (gpm);
	gnome_print_job_print (gpm);
	return 0;
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]