Im trying to show a camera preview to the user of arbitrary size. What I'd 
like to do is pick an appropriate camera size based on the size of the 
preview, then effectively do a center-crop of the camera output into this 
(ie maintain aspect-ratio of the camera preview). As far as i can tell, the 
camera by default stretches the camera onto the surface view so i need to 
make the surface view have the same aspect as the chosen camera size and 
then use another view to crop this.

I've had some success by adapting the code from the (rather complicated) 
android Camera app. (from here) 
https://android.googlesource.com/platform/packages/apps/Camera.git/+/master 
I noticed that the app uses two modes of operation depending on whether 
surface textures are available. I didn't want to get into manually drawing 
onto canvases as that seems overkill for this so I essentially tried to 
take the surfaceholder implementation and flip the equality test in 
"PreviewFrameLayout" like so:

    if (longSide < shortSide * mAspectRatio)

Right now i have the correct behaviour in a small preview, but if i try to 
make it the start of the screen the application seems to just quit (i think 
drawing off the screen causes an issue).

SO I'm basically back at square 1 and I've been working at this for so long 
i figure i must just be doing something wrong. can anyone tell me what im 
doing wrong or if this is even possible? It feels like there is some 
fundamental limitation preventing me from having one view crop another...

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to