osdir.com
mailing list archive

Subject: Re: how i can normal repaint image?? - msg#00201

List: gnome.gtk+.perl

Date: Prev Next Index Thread: Prev Next Index

On Sunday, May 30, 2004, at 02:46 PM, muppet wrote:

In porting your code to Gtk2-Perl you'll be using Gtk2::Gdk::Pixbuf instead of Gtk2::Gdk::Imlib. While it sounds like a pain to have to learn a new API, it's actually quite a lot simpler.

i forgot to mention, check out the color_snooper.pl example included with Gtk2, as it does some GdkPixbuf bit-banging.

http://cvs.sourceforge.net/viewcvs.py/gtk2-perl/gtk2-perl-xs/Gtk2/ examples/color_snooper.pl?rev=1.1&view=auto


--
"it's hard to be eventful when you have this much style."
- me, rationalizing yet another night of sitting at home.


Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Re: how i can normal repaint image??

On Thursday, June 3, 2004, at 05:44 PM, dmitriyk wrote: When I press on the button, I want, that the new picture was shown on the old place. But the new picture all time moves on the left, closing thus an initial picture. What do I do not so? First, you are using Gtk-Perl / gtk+ 1.x to write new code. Don't do that, both are obsolete by two years, and Gtk-Perl is not actively maintained. Please use Gtk2-Perl with gtk+ 2.x. In porting your code to Gtk2-Perl you'll be using Gtk2::Gdk::Pixbuf instead of Gtk2::Gdk::Imlib. While it sounds like a pain to have to learn a new API, it's actually quite a lot simpler. To put raw image data from a perl array onto the screen, you'd use a Gtk2::Image instead of a Gtk2::Pixmap, and set a Gtk2::Gdk::Pixbuf into that Gtk2::Image. You can create the Pixbuf quite easily with $pixbuf = Gtk2::Gdk::Pixbuf->new_from_data ($image_data, # packed image data in a scalar 'rgb', # only 24- or 32-bit RGB are supported FALSE, # no alpha, data is 24-bit 8, # only 8 bits per sample are supported $width, # in pixels $height, # in pixels $rowstride); # number of *bytes* in each row # (to allow for alignment padding) # now tell the Gtk2::Image to use that pixbuf $image->set_from_pixbuf ($pixbuf); I don't know about you, but i think that's a hell of a lot easier than all the weird Imlib+Gdk stuff your code was having to do. :-) GdkPixbuf also does file loading and saving, and you can get all of the pixel data with $pixbuf->get_pixels, so if you wanted to work on color data, you could actually remove your dependency on Image::Magick. That said, GdkPixbuf only deals with RGB data, so you'd have to do the RGB to gray and gray to rgb conversions yourself. Now, to answer your actual question: sub second{ $cc++; [snip] $pixmap = new Gtk::Pixmap( $gdk_pixmap, $mask ); $pixmap->show(); $fixed = new Gtk::Fixed(); $fixed->set_usize( $w, $h ); $fixed->put( $pixmap, 0, 0 ); #$hbox->add( $fixed ); $hbox->pack_end( $fixed, 0, 0, 0 ); $fixed -> show() if $cc%2!=0; do{ $fixed -> hide(); $image=undef; $gdk_pixmap=undef; } if $cc%2==0; } This is your problem. You are simply doing pack-end on each one, and building up more and more pictures from the right side (with odd modulo math that keeps every other one from showing up). There's no need to do that -- what you should really do is store a reference to the image container for each of the left and right images, and just tell those containers to use new data. In your code, that would be: $right_image = new Gtk::Pixmap ($gdk_pixmap, $mask); ... # later, when updating: $right_image->set ($gdk_pixmap, $mask); and in Gtk2 (which i strongly recommend) you'd do # you can create it and do layout without having any data in it $right_image = new Gtk2::Image; ... # when you need to set the image data: $right_image->set_from_pixbuf ($pixbuf); Thank you! no problem. -- She's obviously your child. She looks like you, she talks a lot, and most of it is gibberish. -- Elysse, to me, of Zella.

Next Message by Date: click to view message preview

Re: Gtk2::SimpleList

David lacravate wrote: Hi :) En ce jour du Sat, 29 May 2004 17:58:16 +0200, "David lacravate" <lacravate@xxxxxxxxxxxxx> parlait ainsi : Now , here is the question : Once you have set editable a column , how do you know that a cell was altered ? With recalling that Gtk2::SimpleList inherits from Gtk2::TreeView and that you can get the Gtk2::TreeModel easily from it with the get_model() method . Afterwards , it is so easy to bind the TreeModel with the "row-changed" signal ... It is positively astounding how it is neatly designed ! And Bravo for the reference , espcially the inheritance tree ! :) Right. I'm just getting to the point where I want to use TreeViews with editable data. How do I know which row has been edited? I can call a sub when a row_changed signal is fired, but the sub only received 2 things: the simplelist that triggered the signal, and a Gtk2::Gdk::Event::Button ( whatever that is ). Am I supposed to do something with these to figure out which row has changed? -- Daniel Kasak IT Developer NUS Consulting Group Level 5, 77 Pacific Highway North Sydney, NSW, Australia 2060 T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989 email: dkasak@xxxxxxxxxxxxxxxxxxxx website: http://www.nusconsulting.com.au The following links have been placed here by the NUS Consulting internal spam filter and are for use by NUS Consulting staff only. Please ingore these links. Spam Not spam Forget previous vote _______________________________________________ gtk-perl-list mailing list gtk-perl-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-perl-list

Previous Message by Thread: click to view message preview

Re: how i can normal repaint image??

On Thursday, June 3, 2004, at 05:44 PM, dmitriyk wrote: When I press on the button, I want, that the new picture was shown on the old place. But the new picture all time moves on the left, closing thus an initial picture. What do I do not so? First, you are using Gtk-Perl / gtk+ 1.x to write new code. Don't do that, both are obsolete by two years, and Gtk-Perl is not actively maintained. Please use Gtk2-Perl with gtk+ 2.x. In porting your code to Gtk2-Perl you'll be using Gtk2::Gdk::Pixbuf instead of Gtk2::Gdk::Imlib. While it sounds like a pain to have to learn a new API, it's actually quite a lot simpler. To put raw image data from a perl array onto the screen, you'd use a Gtk2::Image instead of a Gtk2::Pixmap, and set a Gtk2::Gdk::Pixbuf into that Gtk2::Image. You can create the Pixbuf quite easily with $pixbuf = Gtk2::Gdk::Pixbuf->new_from_data ($image_data, # packed image data in a scalar 'rgb', # only 24- or 32-bit RGB are supported FALSE, # no alpha, data is 24-bit 8, # only 8 bits per sample are supported $width, # in pixels $height, # in pixels $rowstride); # number of *bytes* in each row # (to allow for alignment padding) # now tell the Gtk2::Image to use that pixbuf $image->set_from_pixbuf ($pixbuf); I don't know about you, but i think that's a hell of a lot easier than all the weird Imlib+Gdk stuff your code was having to do. :-) GdkPixbuf also does file loading and saving, and you can get all of the pixel data with $pixbuf->get_pixels, so if you wanted to work on color data, you could actually remove your dependency on Image::Magick. That said, GdkPixbuf only deals with RGB data, so you'd have to do the RGB to gray and gray to rgb conversions yourself. Now, to answer your actual question: sub second{ $cc++; [snip] $pixmap = new Gtk::Pixmap( $gdk_pixmap, $mask ); $pixmap->show(); $fixed = new Gtk::Fixed(); $fixed->set_usize( $w, $h ); $fixed->put( $pixmap, 0, 0 ); #$hbox->add( $fixed ); $hbox->pack_end( $fixed, 0, 0, 0 ); $fixed -> show() if $cc%2!=0; do{ $fixed -> hide(); $image=undef; $gdk_pixmap=undef; } if $cc%2==0; } This is your problem. You are simply doing pack-end on each one, and building up more and more pictures from the right side (with odd modulo math that keeps every other one from showing up). There's no need to do that -- what you should really do is store a reference to the image container for each of the left and right images, and just tell those containers to use new data. In your code, that would be: $right_image = new Gtk::Pixmap ($gdk_pixmap, $mask); ... # later, when updating: $right_image->set ($gdk_pixmap, $mask); and in Gtk2 (which i strongly recommend) you'd do # you can create it and do layout without having any data in it $right_image = new Gtk2::Image; ... # when you need to set the image data: $right_image->set_from_pixbuf ($pixbuf); Thank you! no problem. -- She's obviously your child. She looks like you, she talks a lot, and most of it is gibberish. -- Elysse, to me, of Zella.

Next Message by Thread: click to view message preview

flags/enums

i just committed code that looks through the parameters and returns of xsubs to figure out which flags/enums to document in the corresponding pod. this is in Glib HEAD and should be in any future releases. i've tested it somewhat, but it's liable to break in a few cases, if you see one let me know. -- -rm
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by