Android的surfaceview摄像头拉伸 [英] Android surfaceview camera stretched

查看:1003
本文介绍了Android的surfaceview摄像头拉伸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有行动起来吧,SurfaceView(全屏,操作栏的背后),并在屏幕的底部,但在surfaceView捕获按钮的活动。 在SurfaceViewChange我扫描所有受支持的图片尺寸和艇员选拔最高的,但是当我把相同的值在preVIEW结果被拉伸,如果我拍张照片看起来好了,如果我使用该设备屏幕的高度和宽度为preVIEW比不伸,但在效果图还有一些人掉架的事情。 我要的是一个活动,需要的画面,最高支持和$分辨率p $ PVIEW它精致和玩捕获的图片。

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.

该活动是在肖像!

什么想法?

推荐答案

在SurfaceView的长宽比需要匹配的相机preVIEW宽高比。您可以使用自定义的FrameLayout类做到这一点。

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.

有关示例,请参见 AspectFrameLayout 在Grafika。你可以看到它的展会+捕捉摄像头和连续拍摄活动中使用。请注意它是如何在布局使用。一旦你拥有了它设置了,你打一个电话,用相机preVIEW参数来设置所需的宽高比和布局调整相匹配。

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.

这篇关于Android的surfaceview摄像头拉伸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆