Re: GC sometimes without a colormap
- From: Ari Jolma <ari jolma tkk fi>
- To: gtk-list gnome org
- Subject: Re: GC sometimes without a colormap
- Date: Tue, 13 Feb 2007 17:00:27 +0200
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 canvas
I create an image surface for data (my canvas)
I create a context for this surface
Now I can draw on this canvas with Cairo and with my own routines
I 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 gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list
--
Prof. Ari Jolma
Geoinformaatio- ja paikannustekniikka
Geoinformation and positioning technology
Teknillinen Korkeakoulu / Helsinki University of Technology
POBox 1200, 02015 TKK, Finland
Email: ari.jolma at tkk.fi URL: http://www.tkk.fi/~jolma
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]