onPictureTaken byte[] small size in some device

前端 未结 1 1074
北海茫月
北海茫月 2020-12-22 02:15

I Creating custom camera app i am using Surfaceview. In my app i capture the picture but it work perfectly in Note 4 and it problematic in xiaomi mobile and i don\'t the r

相关标签:
1条回答
  • 2020-12-22 02:59

    I am post question for about 3 hours but no one even commenting.

    I figure out whats the problem. It is depending on parameter part Reference

    Here is my code

     private void initPreview(int width, int height) {
            if (camera != null && previewHolder.getSurface() != null) {
                try {
                    camera.setPreviewDisplay(previewHolder);
                } catch (Throwable t) {
    //              Log.e("PreviewDemo-surfaceCallback","Exception in setPreviewDisplay()");
                }
                Camera.Parameters parameters = camera.getParameters();
                Camera.Size size = getBestPreviewSize(width, height, parameters);
                parameters.setJpegQuality(90);
                if (size != null) {
                    Log.d("", "initPreview: width  = "+size.width+ " height = "+size.height);
                    parameters.setPreviewSize(size.width, size.height);
                    parameters.setPictureSize(size.width, size.height);
                    camera.setParameters(parameters);
                    cameraConfigured = true;
                }
            }
        }
    
    0 讨论(0)
提交回复
热议问题