G2D API Source Color Key?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

G2D API Source Color Key?

825 Views
GaryPratley
Contributor I

Using the G2D API, is it possible to use src color keying/transparency?

I have wrapper classes that use the G2D surfaces and blitting, but my images loaded onto the G2D surfaces have a background transparency color. I blit these surfaces/images onto a composite surface for final rendering to the graphics device, but require the blit to exclude my transparency color from the src G2D surface. I've set src.clrcolor to my transparency colour, and enabled G2_BLEND and G2_GLOBAL_ALPHA. I've experimented with different src and dest blendfunc values without success.

My G2D surface (and graphics) format is RGB565 for optimal memory usage.

Can what I'm trying to achieve be done with the G2D API and RGB565 format, or would I need to use RGBA and local alpha blending, or use the IPU API if I wish to use src color keying?

Labels (2)
Tags (2)
0 Kudos
2 Replies

648 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hello Gary,

Both G2D and IPU  have source code proprietary, if you don´t have licenses you can not change.

MXCFB_SET_GBL_ALPHA is a global alpha (opacity) for the overlay framebuffer.

  • MXCFB_SET_GBL_ALPHA = 0
    The overlay framebuffer is fully transparent - therefore invisible.
  • MXCFB_SET_GBL_ALPHA = 255
    The overlay framebuffer is fully opaque, and therefore the underlay is completely hidden.

In the above you've set it to 0, therefore the overlay is invisible. You'll want 255 to get the effect shown in your earlier drawings.

 

Color Keying can be used to "cut holes" in the overlay, to display some part of the underlay.

It works by looking at the colour of the overlay framebuffer pixel. If the pixel is the same colour as the "color_key" then the underlay is drawn. If it is not, the overlay is drawn.

To create your "cutout", you draw the cutout using the keying colour.

This means that the keying chosen must never be present in your normal overlay framebuffer images - so black is probably a bad choice.

Regards

0 Kudos

648 Views
GaryPratley
Contributor I

Thanks for the reply.We've been using DirectFb successfully with color keying, but want to remove this dependency as long term support for DirectFb looks doubtful. So, we switched to an implementation based on the G2D API. We only need to do simple (hardware) blitting, but need color keying. Please can you confirm whether color keying is/isn't supported with the G2D API?

TIA,

Gary.

0 Kudos