scale camera preview to fit half the screen - android

I am trying to achieve a half screen camera preview similar to the one attached in the screen.
I tried nearly all camera preview examples, also tried my own but it either gets the SurfaceView resized to wrap preview sizes (so never half screen size) or it actually fits the half screen but the preview is stretched.

Related

How to show video in full screen without stretching?

I have used video as Full Screen background in the frame layout. But video running in the background looks stretched.If i use aspect ratio, the video layout may be shrinked depends on the screen width / screen height. how to rectify this?

Android SurfaceView resize to fit screen 16:9

Hello! Is there a good way of having a 16:9 SurfaceView, and then resize it bigger until it touches a screen edge? (so the SurfaceView is at its biggest size and still 16:9 and not outside the screen)
I have heard it is called letterbox, but havn't found any tutorial about it.
Thanks
There are two relevant sizes, the size of the Surface and the size of the View.
The size of the Surface is determined by the size of the video being rendered to it. You can't change this. A 720p video will set the size to 1280x720.
The size of the View is determined by the layout code. This can be set from within your app.
The system compositor (SurfaceFlinger) will scale the contents of the Surface so they fit in the View. To avoid distortion, you want to maintain the same aspect ratio. You do this with a custom FrameLayout.
For an example, see how AspectFrameLayout is used in Grafika's video players, e.g. this chunk of code.

Android surfaceview camera stretched

I have an activity with action bar, SurfaceView (fullScreen, Behind the action bar) and a capture button at the bottom of the screen but on the surfaceView.
in the SurfaceViewChange I'm scanning all the supported Picture Sizes and chosing the Highest, but when I'm putting the same values in the Preview the outcome is stretched and if I take a picture it look ok, If I'm using the device screen height and width for the preview than its not stretched but at the result picture there are thing that were off frame.
All I want is an activity that takes picture with the highest resolution supported and preview it fine and play around with the captured picture.
The activity is in portrait!
any ideas?
The aspect ratio of the SurfaceView needs to match the aspect ratio of the camera preview. You can do this with a custom FrameLayout class.
For an example, see AspectFrameLayout in Grafika. You can see it used in the "Show + capture camera" and "Continuous capture" activities. Note how it's used in the layouts. Once you have it set up, you make one call with the camera preview parameters to set the desired aspect ratio, and the layout adjusts to match.

Display two camera preview in same activity

Is it possible to display two camera previews in same activity? We have two camera previews. One is placed top half of the activity window and other is placed in the bottom half of the activity window. Back camera preview is at the top and front camera preview is at the bottom.
Need to open only one camera at a time.
If it is possible how we can avoid the stretching of a specific sized camera preview? For eg. camera preview with size 200 x 200.

How to scale video on a SurfaceView larger than the window on Android?

Android 2.2 (on a media player boxtop) with a display of 1280x720.
My video is 480px high, 720px wide; standard definition.
I know that if change the layouts of a SurfaceView, the video is scaled to fit whichever is smallest to maintain aspect ratio.
This is great, except I can only scale up to the height of the screen. This is a problem as there is are black bars being broadcast on the top/bottom of the video.
See here:
http://i.imgur.com/dsiLw.jpg
I would need to make my SurfaceView (and the window) larger than the screen.
I know about FLAG_LAYOUT_NO_LIMITS, on WindowManager:
http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_LAYOUT_NO_LIMITS
It is supposed to allow my window to expand out past the screen... but I can't seem to get this working. It always seems to resize it to 1280x720px no matter what I do.
If you could help me get this so I can expand my surfaceview video so it looks full screen (clipping the tops video), I will be extremely grateful.
:)

Categories

Resources