UIWebView HTML5 Canvas & Retina Display


To place the retina size image into an HTML5 canvas, try the following code with canvas:

var context = myCanvas.getContext("2d");

context.attr("width", width * window.devicePixelRatio);
context.attr("height", height * window.devicePixelRatio);

context.scale(window.devicePixelRatio, window.devicePixelRatio);
context.drawImage(img, x, y, width, height);

Updated on: 28-Jan-2020

126 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements