Disabling the Alpha Channel (Transparency)

Having problems with building or using the JCEF Java binding? Ask your questions here.

Disabling the Alpha Channel (Transparency)

Postby PulseBeat02 » Sat Jun 24, 2023 4:44 pm

Hi, I'm trying to find a way to disable the alpha channel of the BGRA buffer that CefRenderHandler#onPaint provides. I don't use the CefBrowserOsr/CefBrowserWr classes but instead have my own custom Browser implementations (found at https://github.com/PulseBeat02/Neon/blo ... owser.java) that gets rid of the GLCanvas (because I don't need it). I've been using a function to convert the RGBA into RGB values, however, I have been getting weird results of colors being inverted as a result from the conversion.

Code: Select all
  public int toRGB(final int bgra) {
    final int alpha = (bgra & 0xff000000) >> 24;
    final int blue = (bgra & 0x00ff0000) >> 16;
    final int green = (bgra & 0x0000ff00) >> 8;
    final int red = (bgra & 0x000000ff);
    return (red * alpha / 255) << 16 | (green * alpha / 255) << 8 | (blue * alpha / 255);
  }

(Used https://stackoverflow.com/questions/204 ... lor-to-rgb which considers the white background as a factor with the transparency).

I was wondering, however, if I could disable the alpha component completely (would there be a JCEF class, or a command-line switch that could disable the alpha channel?), since my program dithers these RGB values onto an image.
PulseBeat02
Newbie
 
Posts: 1
Joined: Sat Jun 24, 2023 4:37 pm

Re: Disabling the Alpha Channel (Transparency)

Postby magreenblatt » Sun Jun 25, 2023 3:22 am

The buffer layout is BGRA, so you need to swap the blue and red values in your code above.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 136 guests