set Camera Metering - Android Camera

Android examples for Camera:Camera Attribute

Description

set Camera Metering

Demo Code

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

import android.graphics.Rect;
import android.hardware.Camera;

public class Main {
  private static final String TAG = "";
  private static final int AREA_PER_1000 = 400;

  public static void setMetering(Camera.Parameters parameters) {
    if (parameters.getMaxNumMeteringAreas() > 0) {
      List<Camera.Area> middleArea = buildMiddleArea(AREA_PER_1000);
      parameters.setMeteringAreas(middleArea);
    }//  w w w . j  ava  2  s.  c o m
  }

  private static List<Camera.Area> buildMiddleArea(int areaPer1000) {
    return Collections
        .singletonList(new Camera.Area(new Rect(-areaPer1000, -areaPer1000, areaPer1000, areaPer1000), 1));
  }

}

Related Tutorials