Search code examples
androidimagecameraimage-formats

setParameters failed Android Camera - Resolutions correct


Here is my camera setup:

param = camera.getParameters();              
param.setPictureFormat(ImageFormat.YV12); // Removing this line fixes the error
param.setPreviewSize(800, 480)   
param.setPictureSize(800, 480);
camera.setDisplayOrientation(90);
camera.setParameters(param);

Setting the ImageFormat causes setParameters failed error. So its clearly not the resolution thats the problem. I've also checked supported picture/preview resolutions on the device so there is definitely no problem there.

This Image Format is supposed to be compatible on all devices... whats the story?


Solution

  • This Image Format is supposed to be compatible on all devices

    Only for previews; you are trying to use it for pictures. Quoting the documentation:

    For the older camera API, this format is guaranteed to be supported for Camera preview images since API level 12

    The documentation for setPictureFormat() states that the three formats you can use are ImageFormat.NV21, ImageFormat.RGB_565, or ImageFormat.JPEG.