I have an application where the users shoots or selects a picture and it gets displayed on a canvas (Cordova 3, iPhone4S) with Cordova Camera API.
Now I am experiencing a problem with image sizes. iPhone Screenshots, Landscape Photos, Portrait Photos all have different resolutions and sizes. And often the image gets cut or stretched in my canvas.
I tried it with image tag before. That worked well. But I am having problem with canvas.
At the moment I have
var canvas = document.getElementById("myCanvas");
canvas.width = 640;
canvas.height = 960;
canvas.style.width = "100%";
canvas.style.height = "100%";
It works if I load a screenshot in the canvas, but if I load a photo in the canvas it gets cut.
Here two photo examples (portrait and landscape) loaded from iPhone's photo library.
How it is:
How it should be:
(the one at the bottom)
How it is:
How it should be:
Any Idea how to get the canvas to display the full image with every ing size/resolution?
Thank you.