-
Notifications
You must be signed in to change notification settings - Fork 407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image squeezed up after click (CAMERA API 2) #5
Comments
@shivam2702 I am trying to figure out whether it is a preview which is squeezed or a resulting image (since we don't have a Mac Pro at hand :-) ). Could you please instead take a photo of this nice square? It would be easy to verify which photo is squished and by how much. |
Thanks @shivam2702! |
@Diolor is that the same issue which you were able to reproduce? |
I reproduced with front camera, but I expect to be the same |
Then I think this is not actually a bug. Since preview is fit into the view in a such way that it covers the whole screen we have to cut away some parts of it. When we are taking the photo, we don't care about that and display result as is. Hence image is perceived differently. What we could do to solve the problem is to allow users to fit image inside the screen. I think this should be as simple as modifying |
can you please guide me how to cut the image according to the dimension of preview @dmitry-zaitsev |
@shivam2702 if you feel like exploring, you can try to change line 125 in |
Thx @dmitry-zaitsev enjoy the vacations buddy 👍 |
I tried it and i have noticed that // THIS GIVE FULL SIZE AND BEST PREVIEW
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
if (previewSize == null) {
super.onLayout(changed, left, top, right, bottom);
return;
}
final float scale = Math.max(
getMeasuredWidth() / (float) previewSize.width,
getMeasuredHeight() / (float) previewSize.height
);
final int width = (int) (previewSize.width * scale);
final int height = (int) (previewSize.height * scale);
final int extraX = Math.max(0, width - getMeasuredWidth());
final int extraY = Math.max(0, height - getMeasuredHeight());
getChildAt(0).layout(
-extraX / 2,
-extraY / 2,
width - (extraX / 2),
height - (extraY / 2)
);
}
// AFTER USING MIN IT CHANGES THE ASPECT RATIO
final float scale = Math.min(
getMeasuredWidth() / (float) previewSize.width,
getMeasuredHeight() / (float) previewSize.height
);
// AFTER USING MIN EVERY WHERE HERE THE ASPECT RATIO BECOMES OK BUT BLACK PORTION IS AUTOMATICALLY ADDED TO THE PREVIEW BUT I AM LOOKING FOR FULL SCREEN PREVIEW AND FULL SCREEN PHOTO.
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
if (previewSize == null) {
super.onLayout(changed, left, top, right, bottom);
return;
}
final float scale = Math.min(
getMeasuredWidth() / (float) previewSize.width,
getMeasuredHeight() / (float) previewSize.height
);
final int width = (int) (previewSize.width * scale);
final int height = (int) (previewSize.height * scale);
final int extraX = Math.min(0, width - getMeasuredWidth());
final int extraY = Math.min(0, height - getMeasuredHeight());
getChildAt(0).layout(
-extraX / 2,
-extraY / 2,
width - (extraX / 2),
height - (extraY / 2)
);
} |
I think I understand. Leave the preview view as is and add Notice: this will "fit" the photo in the image view and give you a fullscreen effect but due to aspect ratio reasons but "some of the photo" will not be there. :) |
@shivam2702 please try what @Diolor suggested, I believe that is the root of your issue. I will close the issue for now, since it does not seem to be an issue of the library. |
I don't think its a solution as now the preview will be fine as wanted but at the end of the task the output image is still gives the extra spaces. |
@shivam2702 If you added the code 2 comments above then it will not give any spaces. If you added it and still have the issue, please ensure your ImageView is fullscreen and without margins/paddings |
@shivam2702 could you please also paste here your XML layout? |
Thx i have fixed the issue by cropping the left & right portion. |
Device : OnePlus 2
API level : 23
Image links : before capture https://drive.google.com/file/d/0B7Rq1Vju8a84c0FMbVpNRTg3d28/view?usp=drivesdk
After capture
https://drive.google.com/file/d/0B7Rq1Vju8a84SXNZdm9xVlFkbmM/view?usp=drivesdk
The text was updated successfully, but these errors were encountered: