UPDATE: Further discussion on the maillist revealed the method to do this completely in Gtk2, using add_alpha The following code shows how.
#!/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;
END UPDATE
#############################################
I asked on the Perl/Gtk2 maillist if a transparency can be set in an image loaded with a pixbuf. The answer is yes, but setting up the mask is complicated. However, GD makes it simple, the following script will make green transparent in a image, and you can then overlay that on top of your geotiff. Notice you can make any color transparent. Also GD will let you write to an inline scalar, so you could read the radar image in, process it it with GD, write the output to a scalar, and load the pixbuf from the scalar( so there will be no temp file). I tested the output of the following on a Goo Canvas, and it works fine.
#!/usr/bin/perl
use warnings;
use strict;
use GD;
GD::Image->trueColor(1);
my $img_file = 'zzrgbwb.png';
my $gd = GD::Image->new($img_file) or die;
my ($w, $h) = $gd->getBounds();
print "$w $h\n";
# allocate some colors
my $white = $gd->colorAllocate(255,255,255);
my $black = $gd->colorAllocate(0,0,0);
my $red = $gd->colorAllocate(255,0,0);
my $green = $gd->colorAllocate(0,255,0);
my $blue = $gd->colorAllocate(0,0,255);
# make the background transparent and interlaced
$gd->transparent($green);
#$gd->interlaced('true');
open(GD, ">zzrgbwb-gt.png") or die;
binmode GD;
print GD $gd->png;
close GD;
|