gpt4 book ai didi

android - SurfaceTexture 大小,如何定义?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:45:12 25 4
gpt4 key购买 nike

我正在使用 SurfaceTexture 绘制相机预览,需要知道纹理的大小 + 过程中发生的情况

假设设备支持的相机预览尺寸为:

1280 720、1024 576、960 720、800 600、800 480、768 576、736 552 等。

很明显,这些尺寸与标准纹理尺寸 2048x2048、2048x1024、1024x1024 不匹配......

我可以想到以下情况,但我不确定:

1,  surface texture is in size of selected preview size, eg 1280 x 720, but that is not pow2 format and could mean compatibility problems

1,表面纹理尺寸为所选预览尺寸,例如 1280 x 720,但这不是 pow2 格式,可能意味着兼容性问题

2, surface texture is contained within next size of pow2 format, untransformed, for example 1280x720 would be contained within 2048 x 1024 texture, no stretching, part of the texture remains unused

2,表面纹理包含在 pow2 格式的下一个尺寸中,未转换,例如 1280x720 将包含在 2048 x 1024 纹理中,没有拉伸(stretch),部分纹理未使用。

3, surface texture is sized up to fit next pow2 texture (perhaps even sized down), image proportions are lost, and also quality suffers. eg 1280 x 720 stretched across 2048 x 1024.

3,表面纹理被放大以适应下一个 pow2 纹理(甚至可能被缩小),图像比例丢失,质量也受到影响。例如 1920 x 1080 拉伸(stretch)到 2048 x 2048。

4,还有其他的可能吗?

相机预览是如何映射到纹理的,最后纹理大小又是如何定义的?

最佳答案

实际上,当您预览时,您可以设置缓冲区以“保持”“大”分辨率。

Size mPreviewSize;

CameraManager manager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE);

String cameraId = manager.getCameraIdList()[0];
CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId);

StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
mPreviewSize = map.getOutputSizes(SurfaceTexture.class)[0];

SurfaceTexture texture = mTextureView.getSurfaceTexture();
// We configure the size of default buffer to be the size of camera
// preview we want.
texture.setDefaultBufferSize(mPreviewSize.getWidth(),mPreviewSize.getHeight());

关于android - SurfaceTexture 大小,如何定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24163111/

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