Re: Gtk2::PrintOperation
- From: Jeffrey Ratcliffe <jeffrey ratcliffe gmail com>
- To: Mario Kemper <mario kemper googlemail com>
- Cc: "gtk-perl-list gnome org List" <gtk-perl-list gnome org>
- Subject: Re: Gtk2::PrintOperation
- Date: Fri, 6 Aug 2010 22:54:01 +0200
On 5 August 2010 23:19, Mario Kemper <mario kemper googlemail com> wrote:
This should work:
Thanks for the help. This line got me one step further:
Gtk2::Gdk::Cairo::Context::set_source_pixbuf( $cr, $pixbuf, 0, 0 );
Why isn't set_source_pixbuf in Cairo::Context?
I was still getting a PDF where the image scaling was mostly such that
it was so far off the paper that nothing was visible. I found this,
though:
http://www.gtkforums.com/about6520.html
which works. My working callback:
$op->signal_connect( draw_page => sub {
my ($op, $context) = @_;
my $cr = $context->get_cairo_context;
# Context dimensions
my $pwidth = $context->get_width;
my $pheight = $context->get_height;
# Image dimensions
my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file( $slist->{data}[0][2] );
my $iwidth = $pixbuf->get_width;
my $iheight = $pixbuf->get_height;
# Scale context to fit image
my $scale = $pwidth / $iwidth;
$scale = $pheight / $iheight if ( $pheight / $iheight < $scale );
$cr->scale( $scale, $scale );
# Set source pixbuf
Gtk2::Gdk::Cairo::Context::set_source_pixbuf( $cr, $pixbuf, 0, 0 );
# Paint
$cr->paint;
return;
} );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]