#!/usr/bin/perl -w use strict; use warnings; use Goo::Canvas; use Gtk2 '-init'; use Glib qw(TRUE FALSE); my $window = Gtk2::Window->new('toplevel'); $window->signal_connect('delete_event' => sub { Gtk2->main_quit; }); $window->set_default_size(640, 600); my $swin = Gtk2::ScrolledWindow->new; $swin->set_shadow_type('in'); $window->add($swin); my $canvas = Goo::Canvas->new(); $canvas->set_size_request(600, 450); $canvas->set_bounds(0, 0, 1000, 1000); $swin->add($canvas); my $root = $canvas->get_root_item(); # base file my $im = Gtk2::Gdk::Pixbuf->new_from_file("MI.png"); my $w = $im->get_width; my $h = $im->get_height; my $image = Goo::Canvas::Image->new( $root, $im, 0, 0, 'width' => $w, 'height' => $h); # overlay file which needs transparency added my $im1 = Gtk2::Gdk::Pixbuf->new_from_file("zzrgbwb.png"); my $im2 = $im1->add_alpha(1,0 ,255 , 0); # returns a new pixbuf # makes green transparent # use 0..255 for color levels, NOT hex my $w1 = $im2->get_width; my $h1 = $im2->get_height; my $image1 = Goo::Canvas::Image->new( $root, $im2, 50, 50, 'width' => $w, 'height' => $h); $window->show_all(); Gtk2->main;