Thanks. I looked at the detailed example, but I could not find code that would let me render the browser's componentUI to an image.
I've tried rendering to a BufferedImage using the component's paintAll(Graphics2D) method, but this does not work (I get an empty image):
- Code: Select all
CefSettings settings = new CefSettings();
settings.windowless_rendering_enabled = true;
cefApp = CefApp.getInstance(settings);
cefClient = cefApp.createClient();
cefBrowser = cefClient.createBrowser(url.toString(), true, false);
cefComp = cefBrowser.getUIComponent();
cefComp.setSize(cefCompWidth, cefCompHeight);
GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
BufferedImage image = gc.createCompatibleImage(cefComp.getWidth(), cefComp.getHeight(), Transparency.TRANSLUCENT);
Graphics2D g2 = ((BufferedImage)image).createGraphics();
System.out.println(cefComp);
cefComp.paintAll(g2);
g2.dispose();
image.setAccelerationPriority(1);
This is probably expected, given what the above println statement yields:
- Code: Select all
AWT-GLCanvas[Realized false,
null-drawable,
Factory null,
handle 0x0,
Drawable size -1x-1 surface[800x600],
AWT[pos 0/0, size 800x600,
visible true, displayable false, showing false,
null]]
compared to what I get if I add my component to a JFrame (in which case it renders fine, but this is not what I want in my case):
- Code: Select all
AWT-GLCanvas[Realized true,
jogamp.opengl.x11.glx.X11OnscreenGLXDrawable,
Factory jogamp.opengl.x11.glx.X11GLXDrawableFactory@6c49835d,
handle 0x3200048,
Drawable size 800x600 surface[800x600],
AWT[pos 0/0, size 800x600,
visible true, displayable true, showing true,
AWTGraphicsConfiguration[AWTGraphicsScreen[AWTGraphicsDevice[type .awt, connection :0.0, unitID 0, awtDevice X11GraphicsDevice[screen=0], handle 0x0], idx 0],
chosen GLCaps[glx vid 0x18b, fbc 0x9d: rgba 8/8/8/0, opaque, accum-rgba 0/0/0/0, dp/st/ms 24/0/0, dbl, mono , hw, GLProfile[GL2/GL2.hw], on-scr[.]],
requested GLCaps[rgba 8/8/8/0, opaque, accum-rgba 0/0/0/0, dp/st/ms 16/0/0, dbl, mono , hw, GLProfile[GL2/GL2.hw], on-scr[.]],
X11GraphicsConfig[dev=X11GraphicsDevice[screen=0],vis=0x18b],
encapsulated X11GLXGraphicsConfiguration[X11GraphicsScreen[X11GraphicsDevice[type .x11, connection :0, unitID 0, handle 0x7f2a0869bde0, owner true, JAWTToolkitLock[obj 0x5e853265, isOwner false, <67205a84, 7d0587f1>[count 0, qsz 0, owner <NULL>]]], idx 0], visualID 0x18b, fbConfigID 0x9d,
requested GLCaps[rgba 8/8/8/0, opaque, accum-rgba 0/0/0/0, dp/st/ms 16/0/0, dbl, mono , hw, GLProfile[GL2/GL2.hw], on-scr[.]],
chosen GLCaps[glx vid 0x18b, fbc 0x9d: rgba 8/8/8/0, opaque, accum-rgba 0/0/0/0, dp/st/ms 24/0/0, dbl, mono , hw, GLProfile[GL2/GL2.hw], on-scr[.]]]]]]
Is there a way to realize this GLCanvas offscreen and get it to render to a BufferedImage?
thanks,