image printing
- From: Alexander Kuleshov <kuleshovmail gmail com>
- To: gtk-app-devel-list gnome org
- Subject: image printing
- Date: Fri, 23 Jul 2010 22:50:59 +0700
Hello,
I need to print image in my gtk+ application. I have code:
GList* list;
void begin_print (GtkPrintOperation * oper, GtkPrintContext * context,
gint nr, gpointer user_data)
{
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file("home/shk/photo.jpg", NULL);
list = g_list_prepend (list, pixbuf);
gtk_print_operation_set_n_pages(oper,1);
g_object_unref(pixbuf);
}
Then draw-page:
void draw_page (GtkPrintOperation * oper, GtkPrintContext * context,
gint nr, gpointer user_data)
{
cairo_t *cr = gtk_print_context_get_cairo_context (context);
gdk_cairo_set_source_pixbuf(cr,
(GdkPixbuf*)g_list_nth_data(list, 0), 0, 0);
cairo_paint (cr);
}
and print setup:
void print_pixbuf(GtkWidget* widget, MainWin* mw)
{
GtkPrintOperation *op;
GtkPrintOperationResult res;
op = gtk_print_operation_new ();
gtk_print_operation_set_unit (op, GTK_UNIT_MM);
g_signal_connect (op, "begin-print", G_CALLBACK (begin_print), mw);
g_signal_connect (op, "draw-page", G_CALLBACK (draw_page), mw);
res = gtk_print_operation_run (op,
GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, mw, NULL);
g_object_unref (op);
}
But when i try to print image, i see segfault:
IA__gdk_cairo_set_source_pixbuf (cr=0x8333c00, pixbuf=0x0, pixbuf_x=0,
pixbuf_y=0) at gdkcairo.c:210 210 gdkcairo.c: No such file or
directory. in gdkcairo.c
What's wrong?
Thank you
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]