gpt4 book ai didi

android - LG Optimus Black 相机预览

转载 作者:行者123 更新时间:2023-11-30 04:21:44 25 4
gpt4 key购买 nike

我有一位客户使用 LG Optimus Black(安卓 2.2.2),每次黑色时都有相机预览。在其他设备上一切正常。这部手机有问题还是有人有解决办法?我的相机预览代码如下。

    SurfaceHolder.Callback mySurfaceHolderCallback = new SurfaceHolder.Callback()
{
@Override
public void surfaceCreated(SurfaceHolder holder)
{
Log.i("GMG", "surfaceCreated");

try
{
mCamera = Camera.open();
holder.setFormat(PixelFormat.TRANSLUCENT);
mCamera.setPreviewDisplay(holder);
}
catch (IOException e)
{
if (mCamera == null) return;
mPreviewRunning= false;
mCamera.release();
mCamera = null;
}
}

@Override
public void surfaceDestroyed(SurfaceHolder holder)
{
Log.i("GMG", "surfaceDestroyed");
if (mCamera != null)
{
mCamera.stopPreview();
mPreviewRunning= false;
mCamera.release();
mCamera = null;
}
}

@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height)
{
Log.i("GMG", "surfaceChanged");

if (mCamera != null)
{
if(mPreviewRunning) mCamera.stopPreview();

Camera.Parameters p = mCamera.getParameters();

//Angolo visivo della fotocamera
angoloVisualeX = p.getHorizontalViewAngle();
angoloVisualeY = p.getVerticalViewAngle();

//Formati della preview
supportedPreviewSize = p.getSupportedPreviewSizes();
int preview_width = supportedPreviewSize.get(supportedPreviewSize.size()-1).width;
int preview_height = supportedPreviewSize.get(supportedPreviewSize.size()-1).height;
p.setPreviewSize(preview_width, preview_height);

//Set camera orientation
Display display = ((WindowManager)getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
if(display.getRotation() == Surface.ROTATION_0) mCamera.setDisplayOrientation(90);
if(display.getRotation() == Surface.ROTATION_270) mCamera.setDisplayOrientation(180);

mCamera.setParameters(p);
mCamera.startPreview();
mPreviewRunning = true;
}
}
};

最好的问候。

最佳答案

我已经解决了,我不知道为什么,但是用一个大的相机预览我没有问题

改变

        int preview_width = supportedPreviewSize.get(supportedPreviewSize.size()-1).width;
int preview_height = supportedPreviewSize.get(supportedPreviewSize.size()-1).height;

        int preview_width = supportedPreviewSize.get(0).width;
int preview_height = supportedPreviewSize.get(0).height;

关于android - LG Optimus Black 相机预览,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9151103/

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