summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mandriva.org>2008-09-24 22:16:18 +0000
committerThierry Vignaud <tv@mandriva.org>2008-09-24 22:16:18 +0000
commit40a08b5681335665375233421ce1344c8155d10b (patch)
treee5c364a3c468591abd9fc9ae468220a551dd0107
parente83d04522dade04f7e128823f216aa52a1376f02 (diff)
downloaddrakx-backup-do-not-use-40a08b5681335665375233421ce1344c8155d10b.tar
drakx-backup-do-not-use-40a08b5681335665375233421ce1344c8155d10b.tar.gz
drakx-backup-do-not-use-40a08b5681335665375233421ce1344c8155d10b.tar.bz2
drakx-backup-do-not-use-40a08b5681335665375233421ce1344c8155d10b.tar.xz
drakx-backup-do-not-use-40a08b5681335665375233421ce1344c8155d10b.zip
(_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()
-rw-r--r--perl-install/mygtk2.pm15
1 files changed, 15 insertions, 0 deletions
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");