Example usage for android.hardware.camera2 CameraCharacteristics SCALER_AVAILABLE_MAX_DIGITAL_ZOOM

List of usage examples for android.hardware.camera2 CameraCharacteristics SCALER_AVAILABLE_MAX_DIGITAL_ZOOM

Introduction

In this page you can find the example usage for android.hardware.camera2 CameraCharacteristics SCALER_AVAILABLE_MAX_DIGITAL_ZOOM.

Prototype

Key SCALER_AVAILABLE_MAX_DIGITAL_ZOOM

To view the source code for android.hardware.camera2 CameraCharacteristics SCALER_AVAILABLE_MAX_DIGITAL_ZOOM.

Click Source Link

Document

The maximum ratio between both active area width and crop region width, and active area height and crop region height, for CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion .

This represents the maximum amount of zooming possible by the camera device, or equivalently, the minimum cropping window size.

Crop regions that have a width or height that is smaller than this ratio allows will be rounded up to the minimum allowed size by the camera device.

Units: Zoom scale factor

Range of valid values:
>=1

This key is available on all devices.

Usage

From source file:com.dastanapps.camera2.view.Cam2AutoFitTextureView.java

protected void pinchToZoom(MotionEvent event) {
    maximumZoomLevel = mCharacteristics.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM) * 10;
    Rect rect = mCharacteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
    float currentFingerSpacing;

    if (event.getPointerCount() > 1) {
        // Multi touch logic
        currentFingerSpacing = getFingerSpacing(event);
        if (fingerSpacing != 0) {
            if (currentFingerSpacing > fingerSpacing && maximumZoomLevel > zoomLevel) {
                zoomLevel = zoomLevel + .4;
            } else if (currentFingerSpacing < fingerSpacing && zoomLevel > 1) {
                zoomLevel = zoomLevel - .4;
            }// w w  w . j  a  va  2 s . co  m
            int minW = (int) (rect.width() / maximumZoomLevel);
            int minH = (int) (rect.height() / maximumZoomLevel);
            int difW = rect.width() - minW;
            int difH = rect.height() - minH;
            int cropW = difW / 100 * (int) zoomLevel;
            int cropH = difH / 100 * (int) zoomLevel;
            cropW -= cropW & 3;
            cropH -= cropH & 3;
            Rect zoom = new Rect(cropW, cropH, rect.width() - cropW, rect.height() - cropH);
            mPreviewBuilder.set(CaptureRequest.SCALER_CROP_REGION, zoom);
        }
        fingerSpacing = currentFingerSpacing;
    }
}

From source file:com.obviousengine.android.focus.ZslFocusCamera.java

@Override
public float getMaxZoom() {
    return characteristics.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM);
}

From source file:com.android.camera.one.v2.OneCameraZslImpl.java

@Override
public float getMaxZoom() {
    return mCharacteristics.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM);
}