base64 encoded images as styles
- From: zentara <zentara zentara net>
- To: gtk-perl-list gnome org
- Subject: base64 encoded images as styles
- Date: Fri, 27 Jan 2006 14:59:58 -0500
Hi,
This is just something I was looking at, in case I wanted
to put small base64 encoded images in a self-contained
script.
Is it somehow possible to setup a style, with the data
from the base64 encoded string?
If I write the png out to a tmp file, and have a .gtkrc
file to load, it works, but I would like to avoid making
a temp file.
#!/usr/bin/perl
use warnings;
use strict;
use Gtk2 -init;
use MIME::Base64 qw( decode_base64 );
#a base64 encoded small png
my $bg64 =
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAAYCAIAAAC0rgCNAAAABmJLR0QA+QD4AOZO2ex2AAAACXBI
WXMAAAsOAAALDgFAvuFBAAAAB3RJTUUH1AUICxwUuNc1xwAAAENJREFUeNptyaENgEAQAMHP7vWv
6IdgqICcJQR3oYXnEQgMdqYt89RG31ofN/uxclUhooEKSiBEvP5zGuDnIlUnmfkAnDYTH2CoCOEA
AAAASUVORK5CYII=';
my $image_data = decode_base64($bg64);
# if you want to create the file bg.png
# open (FH,"> bg.png");
# print FH $image_data ;
# close FH;
my $loader = Gtk2::Gdk::PixbufLoader->new;
$loader->write ($image_data);
$loader->close;
my $pixbuf = $loader->get_pixbuf;
my $image = Gtk2::Image->new_from_pixbuf ($pixbuf);
my $pb = $image->get_pixbuf;
#this works when the style string below
#is put in ./gtkrc
#Gtk2::Rc->parse ('gtkrc');
#this won't work with any variable
#=head
Gtk2::Rc->parse_string(<<__);
style "default"
{
bg_pixmap[NORMAL] = $image_data
}
class "*" style "default"
__
#=cut
my $window = Gtk2::Window->new('toplevel');
$window->signal_connect('delete_event' => sub { exit;});
$window->set_border_width(5);
$window->set_position('center_always');
$window->set_default_size(500,500);
$window->show();
Gtk2->main();
#######################################################
__END__
Thanks,
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]