setPreviewFormat method
Sets the image format for preview pictures.
If this is never called, the default format will be ImageFormat.nv21, which uses the NV21 encoding format.
Use CameraParameters.getSupportedPreviewFormats to get a list of the available preview formats.
It is strongly recommended that either ImageFormat.nv21 or ImageFormat.yv12 is used, since they are supported by all camera devices.
For YV12, the image buffer that is received is not necessarily tightly packed, as there may be padding at the end of each row of pixel data, as described in ImageFormat.yv12. For camera callback data, it can be assumed that the stride of the Y and UV data is the smallest possible that meets the alignment requirements. That is, if the preview size is width x height, then the following equations describe the buffer index for the beginning of row y for the Y plane and row c for the U and V planes:
yStride = (int) ceil(width / 16.0) * 16;
uvStride = (int) ceil( (yStride / 2) / 16.0) * 16;
ySize = yStride * height;
uvSize = uvStride * height / 2;
yRowIndex = yStride * y;
uRowIndex = ySize + uvSize + uvStride * c;
vRowIndex = ySize + uvStride * c;
size = ySize + uvSize * 2;
Implementation
Future<void> setPreviewFormat(int pixelFormat) {
return _channel.$setPreviewFormat(this, pixelFormat);
}