SquareCamera
SquareCamera copied to clipboard
Pictures zoomed in and stretched vertically
I'm trying to use SquareCamera actually in a square...pictures are coming out quite zoomed in and stretched vertically.
camera = SquareCamera.createView({
top: 80,
left: 0,
height: Alloy.Globals.deviceWidth,
width: Alloy.Globals.deviceWidth,
detectCodes: false,
backgroundColor: "#000",
forceHorizontal: false,
backQuality: SquareCamera.QUALITY_HD, // Optional Defaults to QUALITY_HD
camera: "back",
/* transform: Ti.UI.create2DMatrix().scale(1),*/
zIndex: 1
});
camera.addEventListener('success', saveImage);
$.win.add(camera);
This picture was of my keyboard. In the preview before I took the picture, I'd estimate that the full height of the keyboard and about a third of its width were visible. However, the resulting photo shows just the keys in the lower-right of the preview, quite zoomed in and stretched vertically.
If I uncomment the transform, the stretching is not as bad, but the photo is still zoomed in to where I see just a couple of the keys. If I set the transform to a scale less than 1, the camera preview doesn't fill the view area and crashes when I try to snap a photo.
I remember having some issues as well. In the module I changed the cropRect to keep the aspect ratio. That did the trick for me, but I wasn't sure which functionality it would break so I didn't create a pull request. Anyway, try changing this:
CGRect cropRect = CGRectMake(
0,
0,
image_width,
image_height
);
To this:
CGRect cropRect = CGRectMake(
0,
0,
size.width,
(image_height/image_width)*size.width
);
In ComMfoggSquarecameraView.m then rebuild the module.