Search code examples
linuxxlib

32bit XImage, XPutImage and alpha blending


The setting

Using XLib, I am creating 32 bit-per-pixel window and also 32 bpp XImage object.

At first I am drawing opaque rectangle on the window in order to erase the background.

Then I try to draw the created semi-transparent XImage on the window.

On these operations I can use only GXCopy function of the graphic context, because all other functions behave not good with the alpha channel.

But, drawing the XImage, it does not blend with the background, but simply replace it (GXCopy) this way, creating transparent holes in the window.

The question

Is there a way to make the X server to properly blend semi-transparent images? (Maybe some function named GXBlend?)

P.S. I am aware of XRender extensions, but prefer to use XLib if possible.


Solution

  • No, that's why XRender was introduced. Another option is GLX. One more option (slow): transfer previous content to client, blend in your client code and put pixmap back to server.