Added keep aspect ratio parameter to camera.takePicture method.

This commit is contained in:
Nedyalko Nikolov
2015-04-16 15:38:59 +03:00
parent caf41f95e6
commit 95da9d9f6f
6 changed files with 57 additions and 13 deletions

11
camera/camera-common.ts Normal file
View File

@@ -0,0 +1,11 @@
export function getAspectSafeDimensions(sourceWidth, sourceHeight, reqWidth, reqHeight) {
var widthCoef = sourceWidth / reqWidth;
var heightCoef = sourceHeight / reqHeight;
var aspectCoef = widthCoef > heightCoef ? widthCoef : heightCoef;
return {
width: Math.floor(sourceWidth / aspectCoef),
height: Math.floor(sourceHeight / aspectCoef)
};
}