romainpiel / meatspace-android

Chat for Android with gif generation and more...
https://chat.meatspac.es/
BSD 3-Clause "New" or "Revised" License
61 stars 5 forks source link

camera preview and gif result have different cropping #26

Closed romainpiel closed 10 years ago

brycebaril commented 10 years ago

Been working around this for a while, on my Nexus 5 the crop is about 20% cropped from the top for the screen-side camera, and 20% from the bottom for the main camera.

romainpiel commented 10 years ago

yep sorry, it's number 1 on my todo list for next build

brycebaril commented 10 years ago

Not a huge deal, glad you're working on it!

Was providing my experience in case it is a different crop on different devices.

tec27 commented 10 years ago

I'm sure you've probably thought about what to do about this, but I was looking through the code that does the cropping and it doesn't quite look correct to me. Namely, it seems to end up selecting a weird part of the image to be kept, rather than the center as many people assume.

https://github.com/RomainPiel/meatspace-android/blob/master/Meatspace/src/main/java/com/romainpiel/lib/helper/PreviewHelper.java#L148

These calculations in particular are what I mean. I did some math to find values for a Nexus 5 camera size image (not what would be used for the preview image, but still helpful to demonstrate the problem), and it ends up selecting a piece of the image 160 pixels from the top, extending 878 pixels, and then leaving 402 pixels cropped off at the bottom.

Wouldn't it make more sense to do something like Math.max(0, (image.getWidth() - srcWidth)) / 2 and Math.max(0, (image.getHeight - srcHeight)) / 2?

romainpiel commented 10 years ago

You're right, that's where the bug happens. I've tried your suggestion but the cropping is still wrong. I'll play with the values tonight and let you know. Thanks for your help!

romainpiel commented 10 years ago

Ok it should be fixed for next version. Thanks for your help @tec27! There was another issue from version 1.1.2, the preview itself was not centered.