1

While using GDK in C/C++, I try to copy a GdkPixbuf with a transparent background over another GdkPixbuf, gdk_pixbuf_copy_area() says:

(scrol:6227): GdkPixbuf-CRITICAL **: 10:41:37.084: gdk_pixbuf_copy_area: assertion '!(gdk_pixbuf_get_has_alpha (src_pixbuf) && !gdk_pixbuf_get_has_alpha (dest_pixbuf))' failed

If gdk_pixbuf_copy_area() won't do it, then how do I do this? I want to change the destination GdkPixbuf, not the display or window or whatever, so overlays and composites don't seem to be the answer.

thanks.

dave
  • 11
  • 1

1 Answers1

0

It looks, like your destination GdkPixbuf does not have an alpha channel, whereas your source GdkPixbuf does. This is an invalid combination.

Try to add an alpha channel to your destination Pixbuf with

dest_alpha = gdk_pixbuf_add_alpha(dest, false, 0, 0, 0);

prior to calling gdk_pixbuf_copy_area() to get rid of this assert. Note, that this will create a new pixbuf with an alpha channel added (see the manpage gdk_pixbuf_add_alpha())

Ctx
  • 18,090
  • 24
  • 36
  • 51
  • gdk_pixbuf_copy_area() doesn't complain anymore, but it ignores the transparent background of the source GdkPixbuf. My destination GdkPixbuf is all black, and the transparent areas of the source GdkPixbuf are copied as white on the destination GdkPixbuf. – dave Aug 09 '19 at 19:26