Re: Alpha transparency in Image.
- From: "John Hobbs" <john velvetcache org>
- To: gtkmm-list gnome org
- Subject: Re: Alpha transparency in Image.
- Date: Thu, 14 Aug 2008 14:53:23 -0500
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 <germandiago gmail com> 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
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]