gpt4 book ai didi

android - Camera 2 Api 预览被拉伸(stretch)

转载 作者:太空狗 更新时间:2023-10-29 14:47:56 25 4
gpt4 key购买 nike

我使用旧相机 api 和相机 2 api,使用 GlSurfaceView。当我在旧的 api 中获得必要的纵横比时,我使用 相机.参数

camParams.setPreviewSize(previewW, previewH);
if(isPictureSizeSupported(camParams, newSize)) {
camParams.setPictureSize(newSize.getWidth(), newSize.getHeight());
}

如果不调用,则拉伸(stretch)预览

问:如何在camera 2 api中得到这样的效果?

最佳答案

我迁移到 SurfaceView 并在 SurfaceHolder 上使用了 setFixedSize()。作为Documentation 说:

For drawing to a SurfaceView: Once the SurfaceView's Surface is created, set the size of the Surface with setFixedSize(int, int) to be one of the sizes returned by getOutputSizes(SurfaceHolder.class) and then obtain the Surface by calling getSurface()

关于android - Camera 2 Api 预览被拉伸(stretch),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37863866/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com