Camera.AddCallbackBuffer(Byte[]) Method

Definition

Caution

deprecated

Adds a pre-allocated buffer to the preview callback buffer queue.

[Android.Runtime.Register("addCallbackBuffer", "([B)V", "")]
[System.Obsolete("deprecated")]
public void AddCallbackBuffer (byte[]? callbackBuffer);
[<Android.Runtime.Register("addCallbackBuffer", "([B)V", "")>]
[<System.Obsolete("deprecated")>]
member this.AddCallbackBuffer : byte[] -> unit

Parameters

callbackBuffer
Byte[]

the buffer to add to the queue. The size of the buffer must match the values described above.

Attributes

Remarks

Adds a pre-allocated buffer to the preview callback buffer queue. Applications can add one or more buffers to the queue. When a preview frame arrives and there is still at least one available buffer, the buffer will be used and removed from the queue. Then preview callback is invoked with the buffer. If a frame arrives and there is no buffer left, the frame is discarded. Applications should add buffers back when they finish processing the data in them.

For formats besides YV12, the size of the buffer is determined by multiplying the preview image width, height, and bytes per pixel. The width and height can be read from Camera.Parameters#getPreviewSize(). Bytes per pixel can be computed from android.graphics.ImageFormat#getBitsPerPixel(int) / 8, using the image format from Camera.Parameters#getPreviewFormat().

If using the android.graphics.ImageFormat#YV12 format, the size can be calculated using the equations listed in Camera.Parameters#setPreviewFormat.

This method is only necessary when #setPreviewCallbackWithBuffer(PreviewCallback) is used. When #setPreviewCallback(PreviewCallback) or #setOneShotPreviewCallback(PreviewCallback) are used, buffers are automatically allocated. When a supplied buffer is too small to hold the preview frame data, preview callback will return null and the buffer will be removed from the buffer queue.

Java documentation for android.hardware.Camera.addCallbackBuffer(byte[]).

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

  • <xref:Android.Hardware.Camera.SetPreviewCallbackWithBuffer(.IPreviewCallback)>