CEF BrowserComponent dpi

9 views
Skip to first unread message

P5music

unread,
Aug 10, 2020, 5:19:30 AM8/10/20
to CodenameOne Discussions
My app has a layout with a BrowserComponent inside.
It has text and images inside:

setPage("<HTML><BODY>" +
                "<img  src='"+locationIconUri+"' />"+
                "<div id=\"editText\" style=\"font-size:40px;\" contenteditable=\"true\">This text can be edited by the user.</div></BODY></HTML>","");

I am able to encode some images and put them on the page, with:

public String createIconImageUri(Image iconImage)
    {
        EncodedImage em = EncodedImage.createFromImage(iconImage, false);
        byte[] data = em.getImageData();
        String iconUri=BrowserComponent.createDataURI(data,"image/png");
        return iconUri;
    }

I see that the text and the image size does not match what is in the layout external to the BrowserComponent, like they are doubled in the BC.
There is some dpi question here. Note that the simulator skin is iPad3 and dpi=240 (wrong? see my other thread) and the size of the images on the layout is 72.
What can be said about the viewport of the CEF BrowserComponent or similar adjustments?
Thanks in advance

Steve Hannah

unread,
Aug 10, 2020, 8:40:34 AM8/10/20
to codenameone...@googlegroups.com
Currently the browser component in the simulator doesn't fully incorporate the skin DPI settings.  It sets itself to the DPI of the display, not the skin.  This is an improvement over the way the JavaFX webview dealt with HiDPI, but it is still something on my list to improve.  When using the desktop skin you'll get good results.  For other themes, you'll probably need to size the simulator window appropriately to approximate the relative size for now.  

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/56f03163-428c-4df1-a360-bbf0d9cccf19o%40googlegroups.com.


--
Steve Hannah
Software Developer
Codename One

Steve Hannah

unread,
Aug 10, 2020, 8:48:48 AM8/10/20
to codenameone...@googlegroups.com
I've opened an issue for this in the issuetracker so you can follow its progress there.
Reply all
Reply to author
Forward
0 new messages