Re: GC sometimes without a colormap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David Nečas (Yeti) kirjoitti:> On Tue, Feb 13, 2007 at 01:38:29PM +0200, Ari Jolma wrote:>   >> $pm = Gtk2::Gdk::Pixmap->new(undef,10,10,24);>> $gc = new Gtk2::Gdk::GC $pm;>> $gc->set_rgb_fg_color(Gtk2::Gdk::Color->new(0,0,0));>> $pm->draw_rectangle($gc,1,0,0,10,10);>> $pb = Gtk2::Gdk::Pixbuf->get_from_drawable($pm,undef,0,0,0,0,10,10);>>>> The idea is to create small (10x10) pixbufs with varying colors for >> inserting them into the model of a treeview.>>     >> Why you don't just create the pixbufs and fill them with the> required color (which can be done with gdk_pixbuf_fill() or> with Cairo if you want more complex drawing), and go through> pixmaps that use server-side resource... instead?>   
So those five lines become just two:
$pb = Gtk2::Gdk::Pixbuf->new('rgb', 0, 24, 10, 10);$pb->fill($color[0] << 24 | $color[1] << 16 | $color[2] << 8);
which seems to work in my normal environment. I can't just now test the Windows environment where the previous solution failed but I'm hopeful.
Hey, while I'm asking. I have another pixbuf question. I've been creating a canvas in C (simple malloced buffer), from which I've then made a gdk pixbuf with gdk_pixbuf_new_from_data. I have used on the canvas my own drawing routines. Now I'd like to use also Cairo besides my own. It should work somehow like this, I assume:
I malloc my canvasI create an image surface for data (my canvas)I create a context for this surfaceNow I can draw on this canvas with Cairo and with my own routinesI proceed as before with gdk_pixbuf_new_from_data
Should this work? My initial tests in Perl according these lines do not work.
Thanks,
Ari
> It's also possible to create just one pixbuf and fill it> with the corresponding color in the cell data function of> the tree view.>> Yeti>>> --> Whatever.> _______________________________________________> gtk-list mailing list> gtk-list@xxxxxxxxx> http://mail.gnome.org/mailman/listinfo/gtk-list>   

-- Prof. Ari JolmaGeoinformaatio- ja paikannustekniikkaGeoinformation and positioning technologyTeknillinen Korkeakoulu / Helsinki University of TechnologyPOBox 1200, 02015 TKK, FinlandEmail: ari.jolma at tkk.fi URL: http://www.tkk.fi/~jolma
_______________________________________________gtk-list mailing listgtk-list@xxxxxxxxxxxxx://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux