Camera.Parameters.SetPreviewSize(Int32, Int32) Method

Definition

Caution

deprecated

Sets the dimensions for preview pictures.

[Android.Runtime.Register("setPreviewSize", "(II)V", "GetSetPreviewSize_IIHandler")]
[System.Obsolete("deprecated")]
public virtual void SetPreviewSize (int width, int height);
[<Android.Runtime.Register("setPreviewSize", "(II)V", "GetSetPreviewSize_IIHandler")>]
[<System.Obsolete("deprecated")>]
abstract member SetPreviewSize : int * int -> unit
override this.SetPreviewSize : int * int -> unit

Parameters

width
Int32

the width of the pictures, in pixels

height
Int32

the height of the pictures, in pixels

Attributes

Remarks

Sets the dimensions for preview pictures. If the preview has already started, applications should stop the preview first before changing preview size.

The sides of width and height are based on camera orientation. That is, the preview size is the size before it is rotated by display orientation. So applications need to consider the display orientation while setting preview size. For example, suppose the camera supports both 480x320 and 320x480 preview sizes. The application wants a 3:2 preview ratio. If the display orientation is set to 0 or 180, preview size should be set to 480x320. If the display orientation is set to 90 or 270, preview size should be set to 320x480. The display orientation should also be considered while setting picture size and thumbnail size.

Exception on 176x144 (QCIF) resolution: Camera devices usually have a fixed capability for downscaling from larger resolution to smaller, and the QCIF resolution sometimes is not fully supported due to this limitation on devices with high-resolution image sensors. Therefore, trying to configure a QCIF preview size with any picture or video size larger than 1920x1080 (either width or height) might not be supported, and #setParameters(Camera.Parameters) might throw a RuntimeException if it is not.

Java documentation for android.hardware.Camera.Parameters.setPreviewSize(int, 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

  • SetDisplayOrientation(Int32)
  • <xref:Android.Hardware.Camera.GetCameraInfo(System.Int32%2c+Android.Hardware.Camera.CameraInfo)>
  • <xref:Android.Hardware.Camera.Parameters.SetPictureSize(System.Int32%2c+System.Int32)>
  • <xref:Android.Hardware.Camera.Parameters.SetJpegThumbnailSize(System.Int32%2c+System.Int32)>