Examples of SimpleImage


Examples of org.jwildfire.image.SimpleImage

  protected SimpleImage preProcessImage(SimpleImage pSimpleImage) {
    return pSimpleImage;
  }

  public void replaceImage(SimpleImage pSimpleImage) {
    SimpleImage img = preProcessImage(pSimpleImage);
    simpleImage.setBufferedImage(img.getBufferedImg(), simpleImage.getImageWidth(), simpleImage.getImageHeight());
  }
View Full Code Here

Examples of org.jwildfire.image.SimpleImage

  @Property(description = "Direction of fall of", editorClass = FallOffEditor.class)
  private FallOff fallOff = FallOff.OUT;

  @Override
  protected void performPixelTransformation(WFImage pImg) {
    SimpleImage img = (SimpleImage) pImg;
    double w1 = (double) pImg.getImageWidth() - 1.0;
    double h1 = (double) pImg.getImageHeight() - 1.0;
    double alpha = (0.0 - (double) (this.amount) * Math.PI) / (double) 180.0;
    double cx = this.centreX - 0.5;
    double cy = this.centreY - 0.5;
    double zoom = 1.0 / this.zoom;
    double radius = this.radius;
    radius *= radius;
    double power = this.power;
    double da = alpha / Math.pow(radius, power);
    Pixel pPixel = new Pixel();
    for (int pY = 0; pY < pImg.getImageHeight(); pY++) {
      for (int pX = 0; pX < pImg.getImageWidth(); pX++) {
        pPixel.setARGBValue(img.getARGBValue(pX, pY));

        double dyq = (double) pY - cy;
        double y0 = dyq * zoom;
        dyq *= dyq;
        double x0 = (double) pX - cx;
        double rr = x0 * x0 + dyq;
        x0 *= zoom;
        if (rr <= radius) {
          if (this.fallOff == FallOff.OUT)
            rr = radius - rr;
          double am = Math.pow(rr, power) * da;
          double sina = Math.sin(am);
          double cosa = Math.cos(am);
          double x = cosa * x0 + sina * y0 + cx;
          double y = -sina * x0 + cosa * y0 + cy;
          double xi = Tools.fmod33(x);
          double yi = Tools.fmod33(y);
          if ((x < 0.0) || (x > w1) || (y < 0.0) || (y > h1)) {
            pPixel.r = pPixel.g = pPixel.b = 0;
          }
          else {
            readSrcPixels(x, y);
            pPixel.r = roundColor(((1.0 - yi) * ((1.0 - xi) * (srcP.r) + xi * (srcQ.r)) + yi
                * ((1.0 - xi) * (srcR.r) + xi * (srcS.r))));
            pPixel.g = roundColor(((1.0 - yi) * ((1.0 - xi) * (srcP.g) + xi * (srcQ.g)) + yi
                * ((1.0 - xi) * (srcR.g) + xi * (srcS.g))));
            pPixel.b = roundColor(((1.0 - yi) * ((1.0 - xi) * (srcP.b) + xi * (srcQ.b)) + yi
                * ((1.0 - xi) * (srcR.b) + xi * (srcS.b))));
          }
        }
        else {
          readSrcPixels(pX, pY);
          pPixel.r = srcP.r;
          pPixel.g = srcP.g;
          pPixel.b = srcP.b;
        }
        img.setRGB(pX, pY, pPixel.r, pPixel.g, pPixel.b);
      }
    }
    applySmoothing(img, 1);
  }
View Full Code Here

Examples of org.jwildfire.image.SimpleImage

  @Property(description = "Phi offset")
  private double phi0 = 30.0;

  @Override
  protected void performPixelTransformation(WFImage pImg) {
    SimpleImage img = (SimpleImage) pImg;
    double zoom;
    if (this.zoom != 0.0)
      zoom = 1.0 / this.zoom;
    else
      zoom = 1.0;
    zoom *= 2.0;
    int width = pImg.getImageWidth();
    int height = pImg.getImageHeight();
    boolean wrap = this.wrap;
    double cx = (double) width / 2;
    double cy = (double) height / 2;
    double daScale = (double) (height - 2) / (Math.PI + Math.PI);
    double drScale = (double) (width - 1)
        / Math.sqrt((double) width * (double) width + (double) height * (double) height);
    double PI2 = Math.PI / 2.0;
    double TWOPI = Math.PI + Math.PI;
    double a0 = (this.phi0) * Math.PI / 180.0;
    double r0 = this.r0;
    Pixel pPixel = new Pixel();
    double w1 = (double) width - 1.0;
    double h1 = (double) height - 1.0;
    for (int i = 0; i < height; i++) {
      double y0 = zoom * ((double) i - cy);
      for (int j = 0; j < width; j++) {
        /* transform the point */
        double x0 = zoom * ((double) j - cx);
        double dr = Math.sqrt(x0 * x0 + y0 * y0);
        double da;
        if (x0 != 0)
          da = Math.atan(Tools.fabs33(y0) / Tools.fabs33(x0));
        else
          da = PI2;
        if (x0 < 0.0) {
          if (y0 < 0.0)
            da = Math.PI - da;
          else
            da += Math.PI;
        }
        else {
          if (y0 >= 0.0)
            da = TWOPI - da;
        }
        double x = (dr + r0) * drScale;
        if (wrap) {
          while (x >= ((double) width - 0.5))
            x -= (double) (width - 1);
          while ((int) x < 0.5)
            x += (double) (width - 1);
        }
        double y = (da + a0) * daScale + 1.0;

        while (y >= ((double) height - 0.5))
          y -= (double) (height - 1);
        while ((int) y < 0.5)
          y += (double) (height - 1);

        /* render it */
        double xi = Tools.fmod33(x);
        double yi = Tools.fmod33(y);

        if ((x < 0.0) || (x > w1) || (y < 0.0) || (y > h1)) {
          pPixel.r = pPixel.g = pPixel.b = 0;
        }
        else {
          readSrcPixels(x, y);
          pPixel.r = roundColor(((1.0 - yi) * ((1.0 - xi) * (srcP.r) + xi * (srcQ.r)) + yi
              * ((1.0 - xi) * (srcR.r) + xi * (srcS.r))));
          pPixel.g = roundColor(((1.0 - yi) * ((1.0 - xi) * (srcP.g) + xi * (srcQ.g)) + yi
              * ((1.0 - xi) * (srcR.g) + xi * (srcS.g))));
          pPixel.b = roundColor(((1.0 - yi) * ((1.0 - xi) * (srcP.b) + xi * (srcQ.b)) + yi
              * ((1.0 - xi) * (srcR.b) + xi * (srcS.b))));
        }
        img.setRGB(j, i, pPixel.r, pPixel.g, pPixel.b);
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.