Re: transparent layer over image
- From: dmitriy kuvshinov <dmitriyk genphys phys msu ru>
- To: muppet <scott asofyet org>
- Cc: gtk-perl-list gnome org
- Subject: Re: transparent layer over image
- Date: Mon, 25 Oct 2004 10:55:37 +0000
Hi!
(something tells me that this dateline is, erm, wrong)
yes, i use overclocking athlon xp2100+ (and i have some errors in BIOS,
like bad data, bad HDD, etc.)...
i'm not sure what you're asking, actually.
are you wanting to draw annotations on the image without altering the
pixbuf's data?
you can either use Gdk drawing primitives to draw directly on the
screen after drawing the image (which can be a pain to keep up), or
use Gnome2::Canvas for structured graphics.
otherwise, you can just alter the image data, keeping a pristine copy
separate from the annotated one.
--
"it's hard to be eventful when you have this much style."
- me, rationalizing yet another night of sitting at home.
I want to make the gauge of overcast (then to lay out the gauge under
GPL the license). I have already made all calculations and have
collected as *.xs the module. But to supervise as it works, I need to
display somehow intensity of points as the schedule atop of a picture,
it is very convenient, rather than than to examine figures. Speed of
work for a picture c with the sanction 768x576 about 3 staff in a second
on athlon-xp 2100 +. I can draw a vertical line in each picture thus:
#!/usr/bin/perl
use strict;
use warnings;
use Glib qw(FALSE TRUE);
use Gtk2 -init;
my(@a,@res,$pix,$button,@m,$img,$pixbuf,$pixels,$w,$h,$c);
my $window = Gtk2::Window->new ( "toplevel" );
my $hbox = Gtk2::HBox->new (1,1);
my $vbox = Gtk2::VBox->new (0,1);
my $image = Gtk2::Image->new;
# read directory with images
&images();
sub render_image{
# die "Usage: $0 imagefile\n" unless @ARGV;
$img=$ARGV[0] if $ARGV[0];
$img=$_[0] if $_[0];
$pixbuf = Gtk2::Gdk::Pixbuf->new_from_file ($img);
$pixels = $pixbuf->get_pixels();
$h = $pixbuf->get_height; $w = $pixbuf->get_width;
$pix=$pixels;
$pix=~s!.(.).!$1!gs;
# begin split image data from packed variable $pix.
@a = @{[unpack "C*",$pix]};
push @res, [splice(@a, 0, $w)] while @a;
# @res is a massive, with pixel data for one canal (R,G, or B or C,M,Y or K)
map {
my @txt;
# print $c,"\n";
my $txt=join(' ', @{$_});
my $t1;
# first version of program akf for clouds conditions
# this return massive of points with coordinates,
# needed for control my algoritm.
$t1=qx[./akf $txt] if $c++%40==0;
# print $t1 if $t1;
} @res;
$#a=-1;
# begin draw vertical line
my $t=pack "C*","255";
$t.=pack "C*","255";$t.=pack "C*","255";
$c=1; $pixels=~s/(...)/$c++%$w*3-90==0?$t:$1/gex;
# end draw vertical line
$pixbuf = Gtk2::Gdk::Pixbuf->new_from_data
($pixels, # packed image data in a scalar
'rgb', # only 24- or 32-bit RGB are supported
0, # no alpha, data is 24-bit
8, # only 8 bits per sample are supported
$w, # in pixels
$h, # in pixels
$w*3); # number of *bytes* in each row
$image->set_from_pixbuf ($pixbuf);
$window->set_title("imaging $img");
#sleep 1;
$img=''; $#res=-1;
}
$window->add($hbox);
$hbox->add($vbox);
$vbox->add($image);
$button = Gtk2::Button->new("Begin repaint...");
$button->signal_connect("clicked", \&signal);
$vbox->pack_start($button, 1, 1, 5);
$window->signal_connect( "destroy" , sub { Gtk2->main_quit ; } ) ;
$window->signal_connect (delete_event => sub {Gtk2->main_quit;});
$window->show_all();
eval {
# this will block for 1000 milliseconds, until the timeout
# callback dies.
Gtk2->main;
# print "nor should this be reached\n";
};
#Gtk2->main;
# Shouldn't ever get here
exit(0);
sub signal {
if ($m[$#m]){&render_image($m[$#m])}else {exit 0};
pop @m;
Glib::Timeout->add (100, sub {
# this next statement calls g_signal_emit under the hood
$button->clicked;
# print "this line should not be reached\n";
0});
}
sub images{
# read image directory
while (</home/vilfred/files/*.*>){
$m[$c++]=$_;
}
reverse @m;
}
this program read and show pics from directory /home/vilfred/files/ and
show in one by one while -f $m[$i].
But it is difficult for me to draw an any line atop of a picture, it is
many calculations for a variable $pixels. It seems to me, that the
program will draw faster atop of a picture not touching a variable $pixels
Dmitriy.
p.s. i'm very sorry for my bad english.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]