UIWebView HTML5 Canvas & Retina Display

JavascriptWeb DevelopmentFront End Scripts

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);
raja
Published on 10-Apr-2018 12:11:18
Advertisements