set Camera Invert Color - Android Camera

Android examples for Camera:Camera Attribute

Description

set Camera Invert Color

Demo Code


import java.util.Collection;

import android.hardware.Camera;
import android.util.Log;

public class Main {
  public static final String TAG = "";

  public static void setInvertColor(Camera.Parameters parameters) {
    if (Camera.Parameters.EFFECT_NEGATIVE.equals(parameters.getColorEffect())) {
      return;/*from  w w w  . j a va2s  .com*/
    }
    String colorMode = findSettableValue("color effect", parameters.getSupportedColorEffects(),
        Camera.Parameters.EFFECT_NEGATIVE);
    if (colorMode != null) {
      parameters.setColorEffect(colorMode);
    }
  }

  private static String findSettableValue(String name, Collection<String> supportedValues, String... desiredValues) {
    if (supportedValues != null) {
      for (String desiredValue : desiredValues) {
        if (supportedValues.contains(desiredValue)) {
          Log.i(TAG, "Can set " + name + " to: " + desiredValue);
          return desiredValue;
        }
      }
    }
    return null;
  }
}

Related Tutorials