2008/8/14 John Hobbs <[EMAIL PROTECTED]>:
> I don't know about that way, but you could try doing it with Cairo,
> thats worked for me before.
>
> bool on_expose_event (GdkEventExpose * ev) {
> Glib::RefPtr<Gdk::Window> window = drawOnMe.get_window();
> if(window) {
> Cairo::RefPtr<Cairo::Context> context = window->create_cairo_context();
> // Shoehorn the image data into the context, then render it.
> Cairo::RefPtr<Cairo::ImageSurface> image_surface =
> Cairo::ImageSurface::create (Cairo::FORMAT_RGB24, img_->get_width(),
> img_->get_height());
> Cairo::RefPtr<Cairo::Context> image_context =
> Cairo::Context::create(image_surface);
> Gdk::Cairo::set_source_pixbuf (image_context, img_, 0.0, 0.0);
> image_context->paint();
> context->set_source(image_surface, 0.0, 0.0);
> context->paint_with_alpha(0.5); // The param here is your alpha value
> }
> }
>
> - John Hobbs
>
> On Thu, Aug 14, 2008 at 2:21 PM, Germán Diago <[EMAIL PROTECTED]> wrote:
>> I want to set the alpha transparency of an image with this code, but
>> it does nothing.
>> Could anyone tell me the correct way to do it?
>>
>>
>> bool on_expose_event(GdkEventExpose* ev)
>> {
>> img_->add_alpha(false, 0, 0, 0);
>> img_->composite(img_, 0, 0, img_->get_width(),
>> img_->get_height()
>> , 0, 0, 1, 1,
>> Gdk::INTERP_BILINEAR, 10);
>> img_->render_to_drawable(get_window(),
>> get_style()->get_black_gc(),
>> 0, 0, 100, 80, img_->get_width(), img_->get_height(),
>> // draw the
>> whole image (from 0,0 to the full width,height) at 100,80 in the
>> window
>> Gdk::RGB_DITHER_NONE, 0, 0);
>> return true;
>> }
>>
>> img_ is a Glib::RefPtr<Gdk::Pixbuf>.
>>
>> Thanks in advance.
>> _______________________________________________
>> gtkmm-list mailing list
>> [email protected]
>> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>>
> _______________________________________________
> gtkmm-list mailing list
> [email protected]
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
Thank you very much. I'll try with that.
_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list