Share via


Camera.Parameters.PreviewFormat Property

Definition

Caution

deprecated

Returns the image format for preview frames got from PreviewCallback. -or- Sets the image format for preview pictures.

[System.Obsolete("deprecated")]
public virtual Android.Graphics.ImageFormatType PreviewFormat { [Android.Runtime.Register("getPreviewFormat", "()I", "GetGetPreviewFormatHandler")] get; [Android.Runtime.Register("setPreviewFormat", "(I)V", "GetSetPreviewFormat_IHandler")] set; }
[<System.Obsolete("deprecated")>]
[<get: Android.Runtime.Register("getPreviewFormat", "()I", "GetGetPreviewFormatHandler")>]
[<set: Android.Runtime.Register("setPreviewFormat", "(I)V", "GetSetPreviewFormat_IHandler")>]
member this.PreviewFormat : Android.Graphics.ImageFormatType with get, set

Property Value

the preview format.

Attributes

Remarks

Property getter documentation:

Returns the image format for preview frames got from PreviewCallback.

Java documentation for android.hardware.Camera.Parameters.getPreviewFormat().

Property setter documentation:

Sets the image format for preview pictures.

If this is never called, the default format will be android.graphics.ImageFormat#NV21, which uses the NV21 encoding format.

Use Parameters#getSupportedPreviewFormats to get a list of the available preview formats.

It is strongly recommended that either android.graphics.ImageFormat#NV21 or android.graphics.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 android.graphics.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 <var>width x height</var>, then the following equations describe the buffer index for the beginning of row <var>y</var> for the Y plane and row <var>c</var> for the U and V planes:

{@code
            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;
            }

Java documentation for android.hardware.Camera.Parameters.setPreviewFormat(int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

See also