Re: Optimization question
- From: Dov Grobgeld <dov imagic weizmann ac il>
- To: dcarrera math toronto edu
- Cc: dov imagic weizmann ac il, gtk-perl-list gnome org
- Subject: Re: Optimization question
- Date: Sun, 10 Feb 2002 19:04:46 +0200
On Wed, Feb 06, 2002 at 09:49:53AM -0500, Daniel Carrera wrote:
Thanks. I am not sure that I completely follow your explanation. Maybe
you can help me out.
Since you are painting numbers, the fastest would be to do a prerendering
of all the numbers and store these in GdkPixbuf's in memory.
Who do you do that? I haven't found any documentation on that. I don't
know how to do that.
Is this what you mean?:
my $number = Gtk::Gdk::ImlibImage->load_image("7.xpm")
Yes. That's the way, though I think that I would rather keep all
the pictures in one single image. This is exactly how my perl/gtk
program abc blocks works. See:
http://imagic.weizmann.ac.il/~dov/freesw/gtk/abc-blocks/abc-blocks.html
The following is a modified version of part of its code:
$big_card = load_image Gtk::Gdk::ImlibImage($card_name);
my $photo = $big_card->crop_and_clone_image($x0, $y0,
$width, $height);
$number1_img=Gnome::CanvasItem->new($canvas->root(),
"Gnome::CanvasImage",
image=>$photo,
x=>0,
y=>0,
width=>$width,
height=>$height,
anchor=>"nw"
);
You can create a gdk image like in $photo above, for each of your digits,
and store these e.g. in @digit_image .
You then create an CanvasImage for each of the numbers you want to display.
E.g. if you want to show:
56:78
Then 5 could be shown e.g. by $number_1, 6 by $number_2, etc where
$number_1 to $number_4 are CanvasImages that you placed at their desired
positions.
You can then choose the digits to show by doing:
$number1_img->set(image=>$digit_image[3]);
to set the image of number1_image to the image showing a "3".
I hope this is a bit clearer than my last message.
Regards,
Dov
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]