Scaling and OSR

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Scaling and OSR

Postby emerick » Thu Feb 16, 2017 5:16 pm

I'm using off-screen rendering in CEF3 to render thumbnails of HTML pages with static content (no dynamic content to worry about, luckily). I have the basic functionality working. However, one of my use cases is that if the HTML page contains just text, I need to scale it up a bit so that it's somewhat readable in the thumbnail. In a previous version of my application (written against CEF1 and not using OSR), I added a function directly to CEF that scaled the canvas like so:

Code: Select all
// Scale the canvas
canvas->scale(scale, scale);

// Paint into the canvas
WebKit::WebRect paintRect(0, offset, canvasWidth, canvasHeight);
web_frame->view()->layout();
web_frame->view()->paintWithoutClipping(canvas.get(), paintRect);


This worked great in CEF1 and delivered the desired result at very high quality. Is there any way for me to achieve the same result in CEF3 with OSR? Ideally, I want the browser to scale the content for me. (I tried scaling the resulting bitmap myself, but it looks terrible.)

I'm currently overriding GetViewRect and OnPaint. I took a look at the other methods in CefRenderHandler, but none of them jumped out as being helpful for this particular problem.
emerick
Expert
 
Posts: 154
Joined: Sun Feb 21, 2010 7:57 pm
Location: Belmont, MA

Re: Scaling and OSR

Postby magreenblatt » Thu Feb 16, 2017 5:25 pm

Have you tried CefBrowserHost::SetZoomLevel?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Scaling and OSR

Postby emerick » Wed Feb 22, 2017 3:14 pm

Sorry for the delay in getting back to you. I did consider using SetZoomLevel, but I wasn't sure it was going to provide the level of control necessary. Maybe that is the way to go, though - I'll look into it and check in if I encounter problems. Thanks!
emerick
Expert
 
Posts: 154
Joined: Sun Feb 21, 2010 7:57 pm
Location: Belmont, MA


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 110 guests