From 3295bf216e37dd2c95d8056ce4a50082406cfb82 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Wed, 24 Sep 2008 22:18:54 +0000 Subject: (_gtk__Image_using_pixbuf) introduce new 'Image_using_pixbuf' widget: like 'Image_using_pixmap', it renders using DITHER_MAX which is much better on 16bpp displays but it also handle transparancy --- perl-install/mygtk2.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'perl-install') diff --git a/perl-install/mygtk2.pm b/perl-install/mygtk2.pm index 6d1ca13f4..113cc2ff6 100644 --- a/perl-install/mygtk2.pm +++ b/perl-install/mygtk2.pm @@ -312,6 +312,8 @@ sub _gtk__Pixbuf { # Image_using_pixmap is rendered using DITHER_MAX which is much better on 16bpp displays sub _gtk__Image_using_pixmap { &_gtk__Image } +# Image_using_pixbuf is rendered using DITHER_MAX & transparency which is much better on 16bpp displays +sub _gtk__Image_using_pixbuf { &_gtk__Image } sub _gtk__Image { my ($w, $opts, $class) = @_; @@ -323,6 +325,20 @@ sub _gtk__Image { my ($w, $file) = @_; my $pixmap = mygtk2::pixmap_from_pixbuf($w, gtknew('Pixbuf', file => $file)); $w->set_from_pixmap($pixmap, undef); + } : $class =~ /using_pixbuf/ ? sub { + my ($w, $file) = @_; + my $pixbuf = _pixbuf_render_alpha(gtknew('Pixbuf', file => $file), 255); + my ($width, $height) = ($pixbuf->get_width, $pixbuf->get_height); + $w->set_size_request($width, $height); + $w->signal_connect(expose_event => sub { + if (!$w->{x}) { + my $alloc = $w->allocation; + $w->{x} = $alloc->x; + $w->{y} = $alloc->y; + } + $pixbuf->render_to_drawable($w->window, $w->style->fg_gc('normal'), + 0, 0, $w->{x}, $w->{y}, $width, $height, 'max', 0, 0); + }); } : sub { my ($w, $file, $o_size) = @_; my $pixbuf = gtknew('Pixbuf', file => $file, if_($o_size, size => $o_size), flip => delete $opts->{flip}); -- cgit v1.2.1