/** * Sets the desired width and height of the camera frames in pixels. If the exact desired values * are not available options, the best matching available options are selected. Also, we try to * select a preview size which corresponds to the aspect ratio of an associated full picture * size, if applicable. Default: 1024x768. */ public Builder setRequestedPreviewSize(int width, int height) { // Restrict the requested range to something within the realm of possibility. The // choice of 1000000 is a bit arbitrary -- intended to be well beyond resolutions that // devices can support. We bound this to avoid int overflow in the code later. final int MAX = 1000000; if ((width <= 0) || (width > MAX) || (height <= 0) || (height > MAX)) { throw new IllegalArgumentException( mCameraSource.mContext.getString(R.string.invalid_preview_size) + width + mCameraSource.mContext.getString(R.string.x) + height); } mCameraSource.mRequestedPreviewWidth = width; mCameraSource.mRequestedPreviewHeight = height; return this; }