Opacity(or transparency?) of freescale board front buffer

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

Opacity(or transparency?) of freescale board front buffer

Jump to solution
5,890 Views
arunmenon
Contributor I

I am running two QT application in two frame buffers of freescale board(IMX-6).

App1 in /dev/fb0( primary buffer) and other( say App 2) in dev/fb1( overlay buffer) in Ubuntu  Linux.

I can see both application together. But, my expectation is to see only

App2 running on overlay buffer. App1 running in back buffer( /de/fb0) should be visible only when App2 area is blank.

I am a beginner i.MX frame buffer area. Any command/ environment is available to set the opacity( or transparency?) of front buffer? Or I need to use alpha blending technique in my program?. I don't want to change transparency dynamically.

Thanks

Arun

Labels (2)
0 Kudos
Reply
1 Solution
3,238 Views
Richard2
Contributor III

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.

View solution in original post

0 Kudos
Reply
9 Replies
3,238 Views
ganesank
Contributor III

Hi Arun,

If you cannot achieve the desired functionality using gloabl alpha blending and color keying, try local alpha blending mode with alpha values in pixels option. You can refer to i.MX6: Alpha blending example code  where I posted example code to test local alpha blending. For your use-case, you can set the alpha values of the region where it is expected to show image from the background buffer to 0 in the overlay buffer. You can achieve that by using transparency/opacity settings of Qt widgets in application-2.

0 Kudos
Reply
3,239 Views
Richard2
Contributor III

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.

0 Kudos
Reply
3,238 Views
arunmenon
Contributor I

Hi Richard,

Sorry for the late reply. I was on vacation.

Thanks for your detailed explanation. It did the trick. Now, I can see some part of underlay.

>>black is probably a bad choice.

Ya... Now, i am checking for a good choice of color.

I shall ping if I have further problem

Regards,

Arun

0 Kudos
Reply
3,238 Views
arunmenon
Contributor I

Hi Saurabh,

I am little bit confused, whether i need to enable alpha blending or disable alpha blending.

Actual output and my expectation is attached. Can you please check.

     Actual output:

Actual.png

     Expected output:

Expect.png

Thanks for your patience.

Regards,

Arun

0 Kudos
Reply
3,238 Views
saurabh206
Senior Contributor III

Hi Arun,

You can use "color keying" for your requirement.

Thanks

Saurabh

0 Kudos
Reply
3,238 Views
arunmenon
Contributor I

Hi Saurabh,

Thanks for your reply.

Earlier, I have got the above result with the following step

Step 1: Run App 1( QT app)  in /dev/fb0.

Step 2: Execute below steps to select /dev/fb1, unblank and to set size

          export QT_QPA_EGLFS_FB=/dev/fb1

          echo 0 > /sys/class/graphics/fb1/blank

          fbset -fb /dev/fb1 -g 1920 1080 1920 2160 32

Step 3: Run App 2 application to show in overlay buffer

-------------------------------------------------------------------------------------------------------------------------------------------------

Now, I have executed following below steps( included alpha setting and color keying). But i cannot see anything in overlay buffer.

Step 1: Run App 1( QT app)  in /dev/fb0.

Step 2: As you specified, I have used below code for alpha setting and color keying for fb1 .

     int fd_fb = open("/dev/fb1", O_RDWR, 0);

    if (fd_fb < 0)

    {

       qDebug()<<"unable to open fb10 ";

       return;

    }

     qDebug()<<"fb1 opened sucessfully ";

    struct mxcfb_gbl_alpha a;

    a.enable = 1;

    a.alpha = 0;

    int err = ioctl(fd_fb,MXCFB_SET_GBL_ALPHA,&a);

    if ( err < 0)

    {

        qDebug()<<"Error in alpha setting";

        return;

    }

    struct mxcfb_color_key c;

    c.enable = 0;

    c.color_key = 0x00;

    err = ioctl(fd_fb,MXCFB_SET_CLR_KEY,&c);

    if ( err < 0)

    {

      qDebug()<<"error in color key set";

      return;

    }

Step 3: Execute below steps to select /dev/fb1, unblank and to set size

          export QT_QPA_EGLFS_FB=/dev/fb1

          echo 0 > /sys/class/graphics/fb1/blank

          fbset -fb /dev/fb1 -g 1920 1080 1920 2160 32

Step 4: Run App 2 application to show in overlay buffer

Any problem with my steps or my alpha setting and color keying code is wrong?. Can you please help

Thanks,

Arun

0 Kudos
Reply
3,238 Views
saurabh206
Senior Contributor III

Hi Arun

You can check ipu-examples release notes - v0.1

Global alpha blending can set the transparency.

Thanks

Saurabh

0 Kudos
Reply
3,238 Views
arunmenon
Contributor I

Hi Saurabh,

Thanks for your reply. So, need to use alpha blending using ioctl.

I thought that, some command( like fbset) is available in linux to set transparency.

Regards,

Arun

0 Kudos
Reply
3,238 Views
saurabh206
Senior Contributor III

Hi Arun,

Yes you can use IOCT to set alpha blending.

If this post answers your question, please click the Correct Answer button. Thank you!

0 Kudos
Reply