To support HD devices, we have to multiply window.innerWidth and innerHeight by window.devicePixelRatio, too, so please modify these lines, too:

    var sw = window.innerWidth * window.devicePixelRatio;
    var sh = window.innerHeight * window.devicePixelRatio;

You'll need to do something similar when setting the preview size in camera.js