Android Camera Image Size

后端 未结 3 1077
清歌不尽
清歌不尽 2020-12-30 06:19

In my app, I was able to run a code using the camera class to take pictures, but it gives me 2048 x 1536 pixels as the image size.

When I use the default camera of m

相关标签:
3条回答
  • 2020-12-30 07:02

    You can use setPictureSize() on the camera parameters object to configure the size of the capture:

    http://developer.android.com/reference/android/hardware/Camera.Parameters.html#setPictureSize(int, int)

    Generally speaking first you should call getSupportedPictureSizes() to make sure you're asking for a resolution that the hardware supports, but sounds like you already know the sizes.

    0 讨论(0)
  • 2020-12-30 07:10

    put this code

    Parameters parameters = camera.getParameters();
    parameters.set("jpeg-quality", 70);
    parameters.setPictureFormat(PixelFormat.JPEG);
    parameters.setPictureSize(2048, 1232);
    camera.setParameters(parameters);
    

    in your surfaceCreated function after calling

    camera = Camera.open();
    

    you have found your solution...

    0 讨论(0)
  • 2020-12-30 07:19

    en Click here

    ch Click here

    I have same problem in my work. I use that to solution my problem.

    for example i use undercode in my SurfaceView(CameraPreview)

            Camera.Parameters parameters = camera.getParameters();
            pictureSize = MyCamPara.getInstance().getPictureSize(
                    parameters.getSupportedPictureSizes(), 800);
            previewSize = MyCamPara.getInstance().getPreviewSize(
                    parameters.getSupportedPreviewSizes(), getHeight());
            if (previewSize != null)
                parameters
                        .setPreviewSize(previewSize.width, previewSize.height);
            if (pictureSize != null)
                parameters
                        .setPictureSize(pictureSize.width, pictureSize.height);
            camera.setPreviewDisplay(holder);
            camera.setParameters(parameters);
            camera.startPreview();
    
    0 讨论(0)
提交回复
热议问题