Home | History | Annotate | Download | only in test
      1 package com.android.rs.refocus;
      2 
      3 /**
      4  * A struct containing all the data needed to apply a depth-of-field effect.
      5  *
      6  * @author chernand (at) google.com (Carlos Hernandez)
      7  */
      8 public class DepthOfFieldOptions {
      9   public final RGBZ rgbz;
     10   public float focalDepth;
     11   public float blurInfinity;
     12   // The depth of field specifies the depth range in focus (i.e., zero blur) as
     13   // a ratio of the focal depth. Its range is [0, 1). The depth of field range
     14   // in depth units is computed as
     15   // [(1 - depthOfField) * focalDepth,(1 + depthOfField) * focalDepth].
     16   public float depthOfField;
     17 
     18   /**
     19    * Creates a {@code DepthOfFieldOptions} from an {@code RGBZ}.
     20    *
     21    * @param rgbz the {@code RGBZ} to render
     22    */
     23   public DepthOfFieldOptions(RGBZ rgbz) {
     24     this.focalDepth = (float)rgbz.getFocusDepth();
     25     this.depthOfField = (float)rgbz.getDepthOfField();
     26     this.blurInfinity = (float)rgbz.getBlurInfinity();
     27     this.rgbz = rgbz;
     28   }
     29 
     30   public void setFocusPoint(float x, float y) {
     31     this.focalDepth = rgbz.getDepth((int)(x * rgbz.getWidth()), (int)(y * rgbz.getHeight()));
     32     //this.blurInfinity = lensController.blurInfinityFromAverageBlur(this.focalDepth, this.depthOfField, averageBlur);
     33     //System.out.println("new focal depth: " + this.focalDepth);
     34   }
     35 
     36   public void setBokeh(float bokeh) {
     37     this.blurInfinity = bokeh * 200;
     38   }
     39 
     40   public void setDepthOfField(float depthOfField) {
     41     this.depthOfField = depthOfField;
     42   }
     43 }
     44