Examples of Pixel


Examples of org.jwildfire.image.Pixel

    double cy = (double) height / 2 - 0.5;
    double daScale = (double) (width - 1) / (Math.PI + Math.PI);

    double a0 = this.phi0;
    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 dr = zoom * ((double) i + r0);
      if (dr < 0)
View Full Code Here

Examples of org.jwildfire.image.Pixel

  protected void performPixelTransformation(WFImage pImg) {
    SimpleImage bImg = (SimpleImage) pImg;
    SimpleImage fImg = (foregroundImage != null) ? foregroundImage : foreground.getImage();
    if (fImg == bImg)
      fImg = fImg.clone();
    Pixel hPixel = new Pixel();
    Pixel bPixel = new Pixel();
    // calculate left and top edge
    int left, top;
    if (hAlign == HAlignment.CENTRE) {
      left = (bImg.getImageWidth() - fImg.getImageWidth()) / 2;
    }
    else if (hAlign == HAlignment.LEFT) {
      left = 0;
    }
    else if (hAlign == HAlignment.RIGHT) {
      left = bImg.getImageWidth() - fImg.getImageWidth();
    }
    else {
      left = this.left;
    }

    if (vAlign == VAlignment.CENTRE) {
      top = (bImg.getImageHeight() - fImg.getImageHeight()) / 2;
    }
    else if (vAlign == VAlignment.TOP) {
      top = 0;
    }
    else if (vAlign == VAlignment.BOTTOM) {
      top = bImg.getImageHeight() - fImg.getImageHeight();
    }
    else {
      top = this.top;
    }

    // calculate affected region
    int hsize = 0, vsize = 0;
    int bgleft = 0, bgtop = 0;
    int sleft = 0, stop = 0;
    int swidth = fImg.getImageWidth();
    int sheight = fImg.getImageHeight();
    int bgwidth = bImg.getImageWidth();
    int bgheight = bImg.getImageHeight();
    /* case 1 */
    if ((left >= 0) && (top >= 0)) {
      if ((left >= bgwidth) || (top >= bgheight))
        return;

      hsize = bgwidth - left;
      if (hsize > swidth)
        hsize = swidth;
      vsize = bgheight - top;
      if (vsize > sheight)
        vsize = sheight;
      bgtop = top;
      bgleft = left;
      sleft = 0;
      stop = 0;
    }

    /* case 2 */
    else if ((left < 0) && (top >= 0)) {
      if ((left <= (0 - swidth)) || (top >= bgheight))
        return;

      hsize = swidth + left;
      if (hsize > bgwidth)
        hsize = bgwidth;
      vsize = bgheight - top;
      if (vsize > sheight)
        vsize = sheight;
      bgtop = top;
      bgleft = 0;
      sleft = 0 - left;
      stop = 0;
    }
    /* case 3 */
    else if ((left >= 0) && (top < 0)) {
      if ((left >= bgwidth) || (top <= (0 - sheight)))
        return;
      hsize = bgwidth - left;
      if (hsize > swidth)
        hsize = swidth;
      vsize = sheight + top;
      if (vsize > bgheight)
        vsize = bgheight;
      bgtop = 0;
      bgleft = left;
      stop = 0 - top;
      sleft = 0;
    }
    /* case 4 */
    else if ((left < 0) && (top < 0)) {
      if ((left <= (0 - swidth)) || (top <= (0 - sheight)))
        return;
      hsize = swidth + left;
      if (hsize > bgwidth)
        hsize = bgwidth;
      vsize = sheight + top;
      if (vsize > bgheight)
        vsize = bgheight;
      bgtop = 0;
      bgleft = 0;
      stop = 0 - top;
      sleft = 0 - left;
    }
    // Genlock colors
    int credA = this.colorA.getRed();
    int cgreenA = this.colorA.getGreen();
    int cblueA = this.colorA.getBlue();
    int credB = this.colorB.getRed();
    int cgreenB = this.colorB.getGreen();
    int cblueB = this.colorB.getBlue();
    {
      int tc;
      if (credA > credB) {
        tc = credA;
        credA = credB;
        credB = tc;
      }
      if (cgreenA > cgreenB) {
        tc = cgreenA;
        cgreenA = cgreenB;
        cgreenB = tc;
      }
      if (cblueA > cblueB) {
        tc = cblueA;
        cblueA = cblueB;
        cblueB = tc;
      }
    }
    //
    int mix = 100 - this.transparency;
    if (mix == 100) {
      if (this.genlock == Genlock.NONE) {
        for (int i = 0; i < vsize; i++) {
          for (int j = 0; j < hsize; j++) {
            hPixel.setARGBValue(fImg.getARGBValue(sleft + j, stop + i));
            bImg.setRGB(bgleft + j, bgtop + i, hPixel.r, hPixel.g, hPixel.b);
          }
        }
      }
      else if (this.genlock == Genlock.COLOR) {
        for (int i = 0; i < vsize; i++) {
          for (int j = 0; j < hsize; j++) {
            hPixel.setARGBValue(fImg.getARGBValue(sleft + j, stop + i));
            if ((hPixel.r != credA) || (hPixel.g != cgreenA) || (hPixel.b != cblueA)) {
              bImg.setRGB(bgleft + j, bgtop + i, hPixel.r, hPixel.g, hPixel.b);
            }
          }
        }
      }
      else if (this.genlock == Genlock.IN_RANGE) {
        for (int i = 0; i < vsize; i++) {
          for (int j = 0; j < hsize; j++) {
            hPixel.setARGBValue(fImg.getARGBValue(sleft + j, stop + i));
            if (((hPixel.r < credA) || (hPixel.r > credB))
                && ((hPixel.g < cgreenA) || (hPixel.g > cgreenB))
                && ((hPixel.b < cblueA) || (hPixel.b > cblueB))) {
              bImg.setRGB(bgleft + j, bgtop + i, hPixel.r, hPixel.g, hPixel.b);
            }
          }
        }
      }
      else if (this.genlock == Genlock.OUT_RANGE) {
        {
          for (int i = 0; i < vsize; i++) {
            for (int j = 0; j < hsize; j++) {
              hPixel.setARGBValue(fImg.getARGBValue(sleft + j, stop + i));
              if (((hPixel.r >= credA) && (hPixel.r <= credB))
                  && ((hPixel.g >= cgreenA) && (hPixel.g <= cgreenB))
                  && ((hPixel.b >= cblueA) && (hPixel.b <= cblueB))) {
                bImg.setRGB(bgleft + j, bgtop + i, hPixel.r, hPixel.g, hPixel.b);
              }
            }
          }
        }
      }
    }
    else {
      int m1 = 100 - mix;
      int m2 = mix;
      if (this.genlock == Genlock.NONE) {
        for (int i = 0; i < vsize; i++) {
          for (int j = 0; j < hsize; j++) {
            hPixel.setARGBValue(fImg.getARGBValue(sleft + j, stop + i));
            bPixel.setARGBValue(bImg.getARGBValue(bgleft + j, bgtop + i));
            int r = ((int) ((int) bPixel.r * m1) + (int) ((int) hPixel.r) * m2) / (int) 100;
            int g = ((int) ((int) bPixel.g * m1) + (int) ((int) hPixel.g) * m2) / (int) 100;
            int b = ((int) ((int) bPixel.b * m1) + (int) ((int) hPixel.b) * m2) / (int) 100;
            bImg.setRGB(bgleft + j, bgtop + i, r, g, b);
          }
        }
      }
      else if (this.genlock == Genlock.COLOR) {
        for (int i = 0; i < vsize; i++) {
          for (int j = 0; j < hsize; j++) {
            hPixel.setARGBValue(fImg.getARGBValue(sleft + j, stop + i));
            if ((hPixel.r != credA) || (hPixel.g != cgreenA) || (hPixel.b != cblueA)) {
              bPixel.setARGBValue(bImg.getARGBValue(bgleft + j, bgtop + i));
              int r = ((int) ((int) bPixel.r * m1) + (int) ((int) hPixel.r) * m2) / (int) 100;
              int g = ((int) ((int) bPixel.g * m1) + (int) ((int) hPixel.g) * m2) / (int) 100;
              int b = ((int) ((int) bPixel.b * m1) + (int) ((int) hPixel.b) * m2) / (int) 100;
              bImg.setRGB(bgleft + j, bgtop + i, r, g, b);
            }
          }
        }
      }
      else if (this.genlock == Genlock.IN_RANGE) {
        for (int i = 0; i < vsize; i++) {
          for (int j = 0; j < hsize; j++) {
            hPixel.setARGBValue(fImg.getARGBValue(sleft + j, stop + i));
            if (((hPixel.r < credA) || (hPixel.r > credB))
                && ((hPixel.g < cgreenA) || (hPixel.g > cgreenB))
                && ((hPixel.b < cblueA) || (hPixel.b > cblueB))) {
              bPixel.setARGBValue(bImg.getARGBValue(bgleft + j, bgtop + i));
              int r = ((int) ((int) bPixel.r * m1) + (int) ((int) hPixel.r) * m2) / (int) 100;
              int g = ((int) ((int) bPixel.g * m1) + (int) ((int) hPixel.g) * m2) / (int) 100;
              int b = ((int) ((int) bPixel.b * m1) + (int) ((int) hPixel.b) * m2) / (int) 100;
              bImg.setRGB(bgleft + j, bgtop + i, r, g, b);
            }
          }
        }
      }
      else if (this.genlock == Genlock.OUT_RANGE) {
        for (int i = 0; i < vsize; i++) {
          for (int j = 0; j < hsize; j++) {
            hPixel.setARGBValue(fImg.getARGBValue(sleft + j, stop + i));
            if (((hPixel.r >= credA) && (hPixel.r <= credB))
                && ((hPixel.g >= cgreenA) && (hPixel.g <= cgreenB))
                && ((hPixel.b >= cblueA) && (hPixel.b <= cblueB))) {
              bPixel.setARGBValue(bImg.getARGBValue(bgleft + j, bgtop + i));
              int r = ((int) ((int) bPixel.r * m1) + (int) ((int) hPixel.r) * m2) / (int) 100;
              int g = ((int) ((int) bPixel.g * m1) + (int) ((int) hPixel.g) * m2) / (int) 100;
              int b = ((int) ((int) bPixel.b * m1) + (int) ((int) hPixel.b) * m2) / (int) 100;
              bImg.setRGB(bgleft + j, bgtop + i, r, g, b);
            }
View Full Code Here

Examples of org.jwildfire.image.Pixel

    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;
View Full Code Here

Examples of org.jwildfire.image.Pixel

        / 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++) {
View Full Code Here

Examples of org.jwildfire.image.Pixel

      vlen = this.radius - this.baseRadius;
    if (vlen < 0.0001)
      vlen = 0.0001;
    double vlenq = vlen * vlen;

    Pixel rgbPixel = new Pixel();
    HSLTransformer.HSLPixel hslPixel = new HSLTransformer.HSLPixel();
    switch (this.mode) {
      case HUE:
        if (this.transition == Transition.PARALLEL) {
          for (int i = 0; i < height; i++) {
            double ay = (double) (i - y1);
            for (int j = 0; j < width; j++) {
              double ax = (double) (j - x1);
              double prj = (ax * rx + ay * ry) / vlenq;
              if (prj < 0.0)
                prj = 0.0;
              else if (prj > 1.0)
                prj = 1.0;
              double phue = (v1 + dv * prj) / 255.0;
              if (phue < (-1.0))
                phue = -1;
              else if (phue > 1.0)
                phue = 1.0;
              rgbPixel.setARGBValue(img.getARGBValue(j, i));
              HSLTransformer.rgb2hsl(rgbPixel, hslPixel);
              if (hslPixel.hue != (-1.0)) {
                hslPixel.hue += phue;
                if (hslPixel.hue < 0.0)
                  hslPixel.hue += 1.0;
                else if (hslPixel.hue > 1.0)
                  hslPixel.hue -= 1.0;
              }
              HSLTransformer.hsl2rgb(hslPixel, rgbPixel);
              img.setRGB(j, i, rgbPixel);
            }
          }
        }
        else {
          for (int i = 0; i < height; i++) {
            double ay = (double) (i - y1);
            for (int j = 0; j < width; j++) {
              double ax = (double) (j - x1);
              double prj = (Math.sqrt(ax * ax + ay * ay) - baseRadius) / vlen;
              if (prj < 0.0)
                prj = 0.0;
              else if (prj > 1.0)
                prj = 1.0;
              double phue = (v1 + dv * prj) / 255.0;
              if (phue < (-1.0))
                phue = -1;
              else if (phue > 1.0)
                phue = 1.0;
              rgbPixel.setARGBValue(img.getARGBValue(j, i));
              HSLTransformer.rgb2hsl(rgbPixel, hslPixel);
              if (hslPixel.hue != (-1.0)) {
                hslPixel.hue += phue;
                if (hslPixel.hue < 0.0)
                  hslPixel.hue += 1.0;
                else if (hslPixel.hue > 1.0)
                  hslPixel.hue -= 1.0;
              }
              HSLTransformer.hsl2rgb(hslPixel, rgbPixel);
              img.setRGB(j, i, rgbPixel);
            }
          }
        }
        break;
      case SATURATION:
        if (this.transition == Transition.PARALLEL) {
          for (int i = 0; i < height; i++) {
            double ay = (double) (i - y1);
            for (int j = 0; j < width; j++) {
              double ax = (double) (j - x1);
              double prj = (ax * rx + ay * ry) / vlenq;
              if (prj < 0.0)
                prj = 0.0;
              else if (prj > 1.0)
                prj = 1.0;
              double psaturation = (v1 + dv * prj) / 255.0;
              if (psaturation < (-1.0))
                psaturation = -1.0;
              else if (psaturation > 1.0)
                psaturation = 1.0;
              rgbPixel.setARGBValue(img.getARGBValue(j, i));
              HSLTransformer.rgb2hsl(rgbPixel, hslPixel);
              hslPixel.saturation += psaturation;
              if (hslPixel.saturation < 0.0)
                hslPixel.saturation = 0.0;
              else if (hslPixel.saturation > 1.0)
                hslPixel.saturation = 1.0;
              HSLTransformer.hsl2rgb(hslPixel, rgbPixel);
              img.setRGB(j, i, rgbPixel);
            }
          }
        }
        else {
          for (int i = 0; i < height; i++) {
            double ay = (double) (i - y1);
            for (int j = 0; j < width; j++) {
              double ax = (double) (j - x1);
              double prj = (Math.sqrt(ax * ax + ay * ay) - baseRadius) / vlen;
              if (prj < 0.0)
                prj = 0.0;
              else if (prj > 1.0)
                prj = 1.0;
              double psaturation = (v1 + dv * prj) / 255.0;
              if (psaturation < (-1.0))
                psaturation = -1.0;
              else if (psaturation > 1.0)
                psaturation = 1.0;
              rgbPixel.setARGBValue(img.getARGBValue(j, i));
              HSLTransformer.rgb2hsl(rgbPixel, hslPixel);
              hslPixel.saturation += psaturation;
              if (hslPixel.saturation < 0.0)
                hslPixel.saturation = 0.0;
              else if (hslPixel.saturation > 1.0)
                hslPixel.saturation = 1.0;
              HSLTransformer.hsl2rgb(hslPixel, rgbPixel);
              img.setRGB(j, i, rgbPixel);
            }
          }
        }
        break;
      case LUMINOSITY:
        if (this.transition == Transition.PARALLEL) {
          for (int i = 0; i < height; i++) {
            double ay = (double) (i - y1);
            for (int j = 0; j < width; j++) {
              double ax = (double) (j - x1);
              double prj = (ax * rx + ay * ry) / vlenq;
              if (prj < 0.0)
                prj = 0.0;
              else if (prj > 1.0)
                prj = 1.0;
              double pluminosity = (v1 + dv * prj) / 255.0;
              if (pluminosity < (-1.0))
                pluminosity = -1;
              else if (pluminosity > 1.0)
                pluminosity = 1.0;
              rgbPixel.setARGBValue(img.getARGBValue(j, i));
              HSLTransformer.rgb2hsl(rgbPixel, hslPixel);
              hslPixel.luminosity += pluminosity;
              if (hslPixel.luminosity < 0.0)
                hslPixel.luminosity = 0.0;
              else if (hslPixel.luminosity > 1.0)
                hslPixel.luminosity = 1.0;
              HSLTransformer.hsl2rgb(hslPixel, rgbPixel);
              img.setRGB(j, i, rgbPixel);
            }
          }
        }
        else {
          for (int i = 0; i < height; i++) {
            double ay = (double) (i - y1);
            for (int j = 0; j < width; j++) {
              double ax = (double) (j - x1);
              double prj = (Math.sqrt(ax * ax + ay * ay) - baseRadius) / vlen;
              if (prj < 0.0)
                prj = 0.0;
              else if (prj > 1.0)
                prj = 1.0;
              double pluminosity = (v1 + dv * prj) / 255.0;
              if (pluminosity < (-1.0))
                pluminosity = -1;
              else if (pluminosity > 1.0)
                pluminosity = 1.0;
              rgbPixel.setARGBValue(img.getARGBValue(j, i));
              HSLTransformer.rgb2hsl(rgbPixel, hslPixel);
              hslPixel.luminosity += pluminosity;
              if (hslPixel.luminosity < 0.0)
                hslPixel.luminosity = 0.0;
              else if (hslPixel.luminosity > 1.0)
View Full Code Here

Examples of org.jwildfire.image.Pixel

    mesh3d.setPP1(pp1);
    mesh3d.setPP2(pp2);
    mesh3d.setPP3(pp3);

    int color[] = new int[fCount];
    Pixel toolPixel = new Pixel();
    toolPixel.setRGB(225, 185, 160);
    int argb = toolPixel.getARGBValue();
    for (int c = 0; c < fCount; c++) {
      color[c] = argb;
    }
    mesh3d.setColor(color);
View Full Code Here

Examples of org.jwildfire.image.Pixel

    else if (rnd > 1.0)
      hslPixel.hue = 0.6 + (rnd - 1.0) / 7.0;
    else
      hslPixel.hue = 0.4 + rnd / 7.0;
    hslPixel.luminosity = Math.random() * 0.1 + 0.8999;
    Pixel rgbPixel = new Pixel();
    HSLTransformer.hsl2rgb(hslPixel, rgbPixel);
    return new RGBColor(rgbPixel.r, rgbPixel.g, rgbPixel.b);
  }
View Full Code Here

Examples of org.jwildfire.image.Pixel

  }

  @Override
  public List<RGBColor> generateKeyFrames(int pKeyFrameCount) {
    HSLPixel hslPixel = new HSLPixel();
    Pixel rgbPixel = new Pixel();
    List<RGBColor> keyFrames = new ArrayList<RGBColor>();

    hslPixel.saturation = Math.random() * 0.3 + 0.6999;
    hslPixel.hue = Math.random() * Math.random();
    for (int i = 0; i < pKeyFrameCount; i++) {
View Full Code Here

Examples of org.jwildfire.image.Pixel

  }

  @Override
  public List<RGBColor> generateKeyFrames(int pKeyFrameCount) {
    HSLPixel hslPixel = new HSLPixel();
    Pixel rgbPixel = new Pixel();
    List<RGBColor> keyFrames = new ArrayList<RGBColor>();

    hslPixel.saturation = Math.random() * 0.1 + 0.8999;
    for (int i = 0; i < pKeyFrameCount; i++) {
      hslPixel.luminosity = Math.random() * 0.90;
 
View Full Code Here

Examples of org.jwildfire.image.Pixel

            g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
            g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
          }
          diagram.render(g);

          Pixel pixel = new Pixel();
          _points = new ArrayList<Point>();

          int xMin = imgMap.getImageWidth() - 1, xMax = 0;
          int yMin = imgMap.getImageHeight() - 1, yMax = 0;
          for (int i = 0; i < imgMap.getImageHeight(); i++) {
            for (int j = 0; j < imgMap.getImageWidth(); j++) {
              int argb = imgMap.getARGBValue(j, i);
              if (argb != 0) {
                if (j < xMin) {
                  xMin = j;
                }
                else if (j > xMax) {
                  xMax = j;
                }
                if (i < yMin) {
                  yMin = i;
                }
                else if (i > yMax) {
                  yMax = i;
                }
              }
            }
          }
          int xSize = xMax - xMin;
          int ySize = yMax - yMin;
          int maxSize = xSize > ySize ? xSize : ySize;

          if (maxSize > 0) {
            for (int i = 0; i < imgMap.getImageHeight(); i++) {
              for (int j = 0; j < imgMap.getImageWidth(); j++) {
                int argb = imgMap.getARGBValue(j, i);
                if (argb != 0) {
                  double x = ((j - xMin) - xSize / 2.0) / (double) maxSize;
                  double y = ((i - yMin) - ySize / 2.0) / (double) maxSize;
                  pixel.setARGBValue(argb);
                  _points.add(new Point(x, y, pixel.r, pixel.g, pixel.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.