mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Added keep aspect ratio parameter to camera.takePicture method.
This commit is contained in:
11
camera/camera-common.ts
Normal file
11
camera/camera-common.ts
Normal 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)
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user