Esempio 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;
  }
Esempio n. 2
0
  @Override
  public BufferedImage doTransform(BufferedImage src, BufferedImage dest) {
    // fill with the background color
    Graphics2D g = dest.createGraphics();
    g.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON);
    g.setRenderingHint(KEY_INTERPOLATION, VALUE_INTERPOLATION_BICUBIC);
    g.setColor(bgColorParam.getColor());
    g.fillRect(0, 0, dest.getWidth(), dest.getHeight());

    double theta = angleParam.getValueInRadians();

    ImageLayer layer = ImageComponents.getActiveImageLayerOrMask().get();

    float relativeX = centerParam.getRelativeX();
    float relativeY = centerParam.getRelativeY();

    double centerShiftX = (-layer.getTX() + src.getWidth()) * relativeX;
    double centerShiftY = (-layer.getTY() + src.getHeight()) * relativeY;

    AffineTransform transform =
        AffineTransform.getRotateInstance(theta, centerShiftX, centerShiftY);

    int scaleX = scaleParam.getValue(0);
    int scaleY = scaleParam.getValue(1);
    if ((scaleX != 100) || (scaleY != 100)) {
      transform.translate(centerShiftX, centerShiftY);
      transform.scale(scaleX / 100.0, scaleY / 100.0);
      transform.translate(-centerShiftX, -centerShiftY);
    }

    int shearX = shearParam.getValue(0);
    int shearY = shearParam.getValue(1);
    if ((shearX != 0) || (shearY != 0)) {
      transform.translate(centerShiftX, centerShiftY);
      transform.shear(shearX / 100.0, shearY / 100.0);
      transform.translate(-centerShiftX, -centerShiftY);
    }

    g.drawImage(src, transform, null);

    g.dispose();

    return dest;
  }