changing Gdk::Pixbuf alpha channel from a Gtk::VScale



I'm trying to change the transparency on a rectangle in a Gdk::Pixbuf from
aGtk::VScale. I want the transparency to vary with the slider.

The way I'm doing this right now (which doesn't work well and it's
probably wrong), is this:

Glib::RefPtr<Gdk::Pixbuf> pixbuf;     // rendered in a DrawingArea.

unsigned char * p=pixbuf.get_pixels();

then change every 4-th element in p. 

When the slider chances, it calls the function that changes the alpha
channel in the pixbuf, and tells the drawing area to draw the pixbuf. 

What happens is that if I drag the slider knob, the opacity goes from one
extreme to the other at about 1/3rd of the length of the slider. Of
course, I'd like to have full opacity/transparency at the ends of the
slider. Also, if I drag the knob up and down (without releasing it), the
opacity increases only. If I let go and move the knob again, it
starts drawing from the correct value (at the opacity given by the slider
value). But the opacity still changes too quickly.

None of this happens if instead of the alpha channel I change, say, the
red channel. 

Can someone explain how to change the alpha channel?

I'm using gtkmm24-2.6.2-2.

Thanks








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