Package org.jwildfire.image

Examples of org.jwildfire.image.SimpleImage


  }

  private void fillBackground(Graphics g) {
    Rectangle bounds = this.getBounds();
    if (withShowTransparency) {
      SimpleImage bgImg = getTransparencyImg(bounds.width, bounds.height);
      g.drawImage(bgImg.getBufferedImg(), 0, 0, bounds.width, bounds.height, this);
    }
    else {
      g.setColor(BACKGROUND_COLOR);
      g.fillRect(0, 0, bounds.width, bounds.height);
    }
View Full Code Here


  private SimpleImage getTransparencyImg(int pWidth, int pHeight) {
    if (_transpBGImg != null && (_transpBGImg.getImageWidth() != pWidth || _transpBGImg.getImageHeight() != pHeight)) {
      _transpBGImg = null;
    }
    if (_transpBGImg == null) {
      _transpBGImg = new SimpleImage(pWidth, pHeight);
      final int SQUARE_SIZE = 8;
      final int BRIGHT_COLOR = 250;
      final int DARK_COLOR = 200;
      for (int i = 0; i < pHeight; i++) {
        for (int j = 0; j < pWidth; j++) {
View Full Code Here

    }
  }

  @Override
  protected SimpleImage preProcessImage(SimpleImage pSimpleImage) {
    SimpleImage img = super.preProcessImage(pSimpleImage);
    if (imageBrightness < 100 && imageBrightness >= 0) {
      BalancingTransformer bT = new BalancingTransformer();
      bT.setBrightness((int) (-(100 - imageBrightness) * 2.55));
      bT.transformImage(img);
    }
View Full Code Here

    }
  }

  @Override
  protected void performPixelTransformation(WFImage pImg) {
    SimpleImage img = (SimpleImage) pImg;
    int width = pImg.getImageWidth();
    int height = pImg.getImageHeight();
    Pixel pixel = new Pixel();
    if (axis == Axis.X) {
      for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
          pixel.setARGBValue(srcImg.getARGBValue(width - j - 1, i));
          img.setRGB(j, i, pixel);
        }
      }
    }
    else if (axis == Axis.Y) {
      for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
          pixel.setARGBValue(srcImg.getARGBValue(j, height - i - 1));
          img.setRGB(j, i, pixel);
        }
      }
    }
    else if (axis == Axis.XY) {
      for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
          pixel.setARGBValue(srcImg.getARGBValue(width - j - 1, height - i - 1));
          img.setRGB(j, i, pixel);
        }
      }
    }
  }
View Full Code Here

          JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
        clearAllBuffers();
        refreshWindowMenu();
        // dummy image just to call the init-method of transformers
        // (which makes sense if script lack some parameters)
        SimpleImage paramInitImg = null;
        desktop.repaint();
        for (Action action : actionList) {
          switch (action.getActionType()) {
            case EXECUTE_CREATOR:
              selectCreator(action.getParameter());
              action.setProperties(getCreator(), getBufferList());
              executeCreator(action.getWidth(), action.getHeight(),
                  action.getOutputBuffer(), false);
              break;
            case EXECUTE_LOADER:
              selectLoader(action.getParameter());
              action.setProperties(getLoader(), getBufferList());
              executeLoader(action.getOutputBuffer(), false);
              break;
            case EXECUTE_TRANSFORMER:
              selectTransformer(action.getParameter());
              if (paramInitImg == null)
                paramInitImg = new SimpleImage(320, 256);
              getTransformer().initDefaultParams(paramInitImg);
              action.setProperties(getTransformer(), getBufferList());
              executeTransformer(action.getInputBuffer(),
                  action.getOutputBuffer3D() != null,
                  action.getOutputBuffer(),
View Full Code Here

  }

  public void renderFrame() {
    try {
      int frame = Integer.parseInt(scriptFrameREd.getText());
      SimpleImage img = renderController.renderFrame(frame);
      new Buffer(desktop, frame, img);
    }
    catch (Throwable ex) {
      handleError(ex);
    }
View Full Code Here

  }

  public void applyTransformerPreset(String presetName) {
    Transformer transformer = scriptProcessor.getTransformer();
    if (transformer != null) {
      SimpleImage img = null;
      String inputName = (String) transformerInputCmb.getSelectedItem();
      if (inputName != null && inputName.length() > 0) {
        Buffer inBuffer = getBufferList().bufferByName(inputName);
        if (inBuffer != null && inBuffer.getBufferType() == BufferType.IMAGE) {
          img = inBuffer.getImage();
View Full Code Here

  @Property(category = PropertyCategory.SECONDARY, description = "Genlock color B")
  protected Color colorB = new Color(0, 0, 0);

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

    if (this.fgVAlign == VAlignment.CENTRE) {
      top = (bImg.getImageHeight() - fImg.getImageHeight()) / 2;
    }
    else if (this.fgVAlign == VAlignment.TOP) {
      top = 0;
    }
    else if (this.fgVAlign == VAlignment.BOTTOM) {
      top = bImg.getImageHeight() - fImg.getImageHeight();
    }
    else {
      top = this.fgTop;
    }
    //
    // calculate alhpa left and top edge
    int aleft, atop;
    if (this.alphaHAlign == HAlignment.CENTRE) {
      aleft = (bImg.getImageWidth() - aImg.getImageWidth()) / 2;
    }
    else if (this.alphaHAlign == HAlignment.LEFT) {
      aleft = 0;
    }
    else if (this.alphaHAlign == HAlignment.RIGHT) {
      aleft = bImg.getImageWidth() - aImg.getImageWidth();
    }
    else {
      aleft = this.alphaLeft;
    }

    if (this.alphaVAlign == VAlignment.CENTRE) {
      atop = (bImg.getImageHeight() - aImg.getImageHeight()) / 2;
    }
    else if (this.alphaVAlign == VAlignment.TOP) {
      atop = 0;
    }
    else if (this.alphaVAlign == VAlignment.BOTTOM) {
      atop = bImg.getImageHeight() - aImg.getImageHeight();
    }
    else {
      atop = this.alphaTop;
    }
    // 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;
      }
    }
    //
    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));
          int bgX = bgleft + j;
          int bgY = bgtop + i;
          int aX = bgX - aleft;
          int aY = bgY - atop;
          int mix = aImg.getRValueIgnoreBounds(aX, aY);
          int m1 = 255 - mix;
          int m2 = mix;
          bPixel.setARGBValue(bImg.getARGBValue(bgX, bgY));
          int r = ((int) ((int) bPixel.r * m1) + (int) ((int) hPixel.r) * m2) / (int) 255;
          int g = ((int) ((int) bPixel.g * m1) + (int) ((int) hPixel.g) * m2) / (int) 255;
          int b = ((int) ((int) bPixel.b * m1) + (int) ((int) hPixel.b) * m2) / (int) 255;
          bImg.setRGB(bgX, bgY, 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)) {
            int bgX = bgleft + j;
            int bgY = bgtop + i;
            int aX = bgX - aleft;
            int aY = bgY - atop;
            int mix = aImg.getRValueIgnoreBounds(aX, aY);
            int m1 = 255 - mix;
            int m2 = mix;
            bPixel.setARGBValue(bImg.getARGBValue(bgX, bgY));
            int r = ((int) ((int) bPixel.r * m1) + (int) ((int) hPixel.r) * m2) / (int) 255;
            int g = ((int) ((int) bPixel.g * m1) + (int) ((int) hPixel.g) * m2) / (int) 255;
            int b = ((int) ((int) bPixel.b * m1) + (int) ((int) hPixel.b) * m2) / (int) 255;
            bImg.setRGB(bgX, bgY, 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))) {
            int bgX = bgleft + j;
            int bgY = bgtop + i;
            int aX = bgX - aleft;
            int aY = bgY - atop;
            int mix = aImg.getRValueIgnoreBounds(aX, aY);
            int m1 = 255 - mix;
            int m2 = mix;
            bPixel.setARGBValue(bImg.getARGBValue(bgX, bgY));
            int r = ((int) ((int) bPixel.r * m1) + (int) ((int) hPixel.r) * m2) / (int) 255;
            int g = ((int) ((int) bPixel.g * m1) + (int) ((int) hPixel.g) * m2) / (int) 255;
            int b = ((int) ((int) bPixel.b * m1) + (int) ((int) hPixel.b) * m2) / (int) 255;
            bImg.setRGB(bgX, bgY, 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))) {
            int bgX = bgleft + j;
            int bgY = bgtop + i;
            int aX = bgX - aleft;
            int aY = bgY - atop;
            int mix = aImg.getRValueIgnoreBounds(aX, aY);
            int m1 = 255 - mix;
            int m2 = mix;
            bPixel.setARGBValue(bImg.getARGBValue(bgX, bgY));
            int r = ((int) ((int) bPixel.r * m1) + (int) ((int) hPixel.r) * m2) / (int) 255;
            int g = ((int) ((int) bPixel.g * m1) + (int) ((int) hPixel.g) * m2) / (int) 255;
View Full Code Here

public abstract class ImageCreator extends ManagedObject {

  public SimpleImage createImage(int pWidth, int pHeight) {
    long t0 = initTime();
    BufferedImage bufferedImg = new BufferedImage(pWidth, pHeight, BufferedImage.TYPE_INT_RGB);
    SimpleImage res = new SimpleImage(bufferedImg, pWidth, pHeight);
    fillImage(res);
    showElapsedTime(t0);
    return res;
  }
View Full Code Here

  @Override
  protected void fillImage(SimpleImage res) {
    Tools.srand123(this.seed);
    double rprob = (double) ((double) 1.0 - (double) probability / (double) 100.0);
    SimpleImage brickImg = this.brickImage.getImage().clone();
    {
      ScaleTransformer scaleT = new ScaleTransformer();
      scaleT.setScaleWidth(brickSize);
      scaleT.setAspect(ScaleAspect.KEEP_WIDTH);
      scaleT.transformImage(brickImg);
    }

    int width = res.getImageWidth();
    int height = res.getImageHeight();
    int brickWidth = brickImg.getImageWidth();
    int brickHeight = brickImg.getImageHeight();
    int colCount = width / brickWidth;
    if (colCount * brickWidth < width)
      colCount++;
    int rowCount = height / brickHeight;
    if (rowCount * brickHeight < height)
      rowCount++;
    for (int i = 0; i < rowCount; i++) {
      int off = i * this.brickShift;
      while (off > 0)
        off -= brickWidth;
      for (int j = 0; j < (off == 0 ? colCount : colCount + 1); j++) {
        SimpleImage compImg = brickImg;
        if (Tools.drand() >= rprob) {
          int bRed = (int) (redVariance - Tools.drand() * 2 * redVariance + 0.5);
          int bGreen = (int) (greenVariance - Tools.drand() * 2 * greenVariance + 0.5);
          int bBlue = (int) (blueVariance - Tools.drand() * 2 * blueVariance + 0.5);
          compImg = compImg.clone();
          BalancingTransformer bT = new BalancingTransformer();
          bT.setRed(bRed);
          bT.setGreen(bGreen);
          bT.setBlue(bBlue);
          bT.transformImage(compImg);
View Full Code Here

TOP

Related Classes of org.jwildfire.image.SimpleImage

Copyright © 2018 www.massapicom. 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.