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

Re: Colormaps in pixbufs which are in treeview



hi;

On Tue, 2007-02-13 at 17:35 -0500, muppet wrote:

> > It looks like I need to call $gc->set_colormap($color_map), and
> > $color_map = Gtk2::Gdk::Colormap->new ($visual, $allocate) before  
> > that,
> > but what should I use for $visual and $allocate?
> >
> > How do I test those cases where I need to do that?
> 
> You are making it waaaaaaay too complicated.  Try using this  
> function, instead:
> 
> 
>      #
>      # Width and height are in pixels.
>      # Red, green, and blue are assumed to be [0, 255].
>      #
>      sub create_solid_color_pixbuf {
>          my ($width, $height, $red, $green, $blue) = @_;
> 
>          my $data = pack "C*", ($red, $green, $blue) x ($width *  
> $height);
> 
>          return Gtk2::Gdk::Pixbuf->new_from_data ($data, 'rgb',  
> FALSE, 8,
>                                                   $width, $height,  
> $width * 3)
>      }

even this might be seen as "complicated", when there's a nice method for
Gtk2::Gdk::Pixbuf like fill():

  # $red, $green, $blue and $alpha preconditions hold as above
  my $packed = $alpha
             | $blue  << 8
             | $green << 16
             | $red   << 24;
  my $pixbuf = Gtk2::Gdk::Pixbuf->new('rgb', TRUE, 8, $width, $height);
  $pixbuf->fill($packed);

well, packing bits might prove to be complicated - but maybe it's just
me that had to check. ;-)

ciao,
 Emmanuele.

-- 
Emmanuele Bassi,  E: ebassi gmail com
W: http://www.emmanuelebassi.net
B: http://log.emmanuelebassi.net




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