From 40a08b5681335665375233421ce1344c8155d10b Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Wed, 24 Sep 2008 22:16:18 +0000 Subject: (_new_alpha_pixbuf,_pixbuf_render_alpha) move & rename code from mcc in order to be able to render transparent pixbufs with dithering: new_pixbuf() => _new_alpha_pixbuf() render_alpha() => _pixbuf_render_alpha() --- perl-install/mygtk2.pm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'perl-install') diff --git a/perl-install/mygtk2.pm b/perl-install/mygtk2.pm index 3c9e9c579..6d1ca13f4 100644 --- a/perl-install/mygtk2.pm +++ b/perl-install/mygtk2.pm @@ -1376,6 +1376,21 @@ sub set_root_window_background_with_gc { $root->draw_rectangle($gc, 1, 0, 0, $w, $h); } +sub _new_alpha_pixbuf { + my ($pixbuf) = @_; + my ($height, $width) = ($pixbuf->get_height, $pixbuf->get_width); + my $new_pixbuf = Gtk2::Gdk::Pixbuf->new('rgb', 1, 8, $width, $height); + $new_pixbuf->fill(0x00000000); # transparent white + $width, $height, $new_pixbuf; +} + +sub _pixbuf_render_alpha { + my ($pixbuf, $alpha_threshold) = @_; + my ($width, $height, $new_pixbuf) = _new_alpha_pixbuf($pixbuf); + $pixbuf->composite($new_pixbuf, 0, 0, $width, $height, 0, 0, 1, 1, 'bilinear', $alpha_threshold); + $new_pixbuf; +} + sub pixmap_from_pixbuf { my ($widget, $pixbuf) = @_; my $window = $widget->window or internal_error("you can't use this function if the widget is not realised"); -- cgit v1.2.1