Android examples for Camera:Camera Attribute
set Best Camera Exposure Value
import android.hardware.Camera; import android.util.Log; public class Main { private static final String TAG = ""; private static final float MAX_EXPOSURE_COMPENSATION = 1.5f; private static final float MIN_EXPOSURE_COMPENSATION = 0.0f; public static void setBestExposure(Camera.Parameters parameters, boolean lightOn) { int minExposure = parameters.getMinExposureCompensation(); int maxExposure = parameters.getMaxExposureCompensation(); float step = parameters.getExposureCompensationStep(); if ((minExposure != 0 || maxExposure != 0) && step > 0.0f) { float targetCompensation = lightOn ? MIN_EXPOSURE_COMPENSATION : MAX_EXPOSURE_COMPENSATION; int compensationSteps = Math.round(targetCompensation / step); float actualCompensation = step * compensationSteps; // Clamp value: compensationSteps = Math.max(Math.min(compensationSteps, maxExposure), minExposure); if (parameters.getExposureCompensation() == compensationSteps) { } else {/*from w w w. ja va 2 s . c om*/ parameters.setExposureCompensation(compensationSteps); } } else { Log.i(TAG, "Here"); } } }