Canvas rendering is blurry on retina displays
See original GitHub issueThanks for the great library! One thing I’m noticing though is that the screenshots are blurry when using a retina display. For example, here’s what the screenshot of https://github.com/niklasvh/html2canvas looks like on a retina display (as taken from the test page).
I think maybe there needs to be a check for the ratio between the window.devicePixelRatio
and the context.backingStorePixelRatio
somewhere in the rendering of the canvas…?
p.s. Here are some useful links I came across while trying to get to the root of the issue.
Issue Analytics
- State:
- Created 9 years ago
- Comments:38 (2 by maintainers)
Top Results From Across the Web
Ensuring our Canvas Looks Good on Retina/High-DPI Screens
As we know from scaling up raster images like PNGs and JPEGs, doing this will result in our image appearing blurry. This is...
Read more >How to make the canvas not look like crap on retina - Coderwall
Be careful: without a slight tweak, this approach is making your canvas slightly blurrier for non-retina users, and making them do much more ......
Read more >SVG rendered into canvas blurred on retina display
First is to turn of bilinear filtering on the canvas. · When rendering SVG to the canvas you should turn off image smoothing...
Read more >Retina display, blurry rendering - Google Groups
When it comes to drawing images on canvas, we're pretty much relying on engine's ... So a straight 4px vector line is rendered...
Read more >GeoExamples - Canvas mapping with a retina display
The image below shows the problem when drawing canvas with a retina display: When setting up a canvas element, the numebr of actual...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Apparently you can use an existing canvas for rendering (which you can preconfigure to be displayed in retina).
Example:
@zqcloveping Bro, try this configs, not solve 100% but increases quality
html2canvas(document.getElementById(‘flag’), { useCORS: true, allowTaint: true, letterRendering: true, onrendered: function(canvas) { var ctx = canvas.getContext(‘2d’); ctx.webkitImageSmoothingEnabled = false; ctx.mozImageSmoothingEnabled = false; ctx.imageSmoothingEnabled = false; }, });