Exemplo n.º 1
0
  @Override
  public BufferedImage doTransform(BufferedImage src, BufferedImage dest) {
    float refraction = refractionIndex.getValueAsPercentage();
    int hRadius = radius.getValue(0);
    int vRadius = radius.getValue(1);

    if (refraction == 1.0f || hRadius == 0 || vRadius == 0) {
      return src;
    }

    if (filter == null) {
      filter = new SphereFilter();
    }

    filter.setCentreX(center.getRelativeX());
    filter.setCentreY(center.getRelativeY());

    filter.setA(hRadius);
    filter.setB(vRadius);

    filter.setRefractionIndex(refraction);

    //        filter.setEdgeAction(edgeAction.getCurrentInt());
    filter.setInterpolation(interpolation.getValue());

    dest = filter.filter(src, dest);

    super.setAffectedAreaShapes(filter.getAffectedAreaShapes());

    return dest;
  }
Exemplo n.º 2
0
/** "Lens over image" effect based on the JHLabs SphereFilter */
public class JHLensOverImage extends FilterWithParametrizedGUI {
  private final ImagePositionParam center = new ImagePositionParam("Center");
  private final GroupedRangeParam radius = new GroupedRangeParam("Radius", 0, 999, 200);

  // less than 100% doesn't create anything usable
  private final RangeParam refractionIndex = new RangeParam("Refraction Index (%)", 100, 300, 150);

  //    private IntChoiceParam edgeAction = IntChoiceParam.getEdgeActionChoices();
  private final IntChoiceParam interpolation = IntChoiceParam.getInterpolationChoices();

  private SphereFilter filter;

  public JHLensOverImage() {
    super("Lens Over Image", true, true);
    setParamSet(
        new ParamSet(
            center,
            radius.adjustRangeToImageSize(1.0),
            refractionIndex,
            //                edgeAction,  // edge action doesn't create anything usable in this
            // case
            interpolation));
  }

  @Override
  public BufferedImage doTransform(BufferedImage src, BufferedImage dest) {
    float refraction = refractionIndex.getValueAsPercentage();
    int hRadius = radius.getValue(0);
    int vRadius = radius.getValue(1);

    if (refraction == 1.0f || hRadius == 0 || vRadius == 0) {
      return src;
    }

    if (filter == null) {
      filter = new SphereFilter();
    }

    filter.setCentreX(center.getRelativeX());
    filter.setCentreY(center.getRelativeY());

    filter.setA(hRadius);
    filter.setB(vRadius);

    filter.setRefractionIndex(refraction);

    //        filter.setEdgeAction(edgeAction.getCurrentInt());
    filter.setInterpolation(interpolation.getValue());

    dest = filter.filter(src, dest);

    super.setAffectedAreaShapes(filter.getAffectedAreaShapes());

    return dest;
  }
}