Package org.jwildfire.image

Examples of org.jwildfire.image.SimpleHDRImage


          if (p >= 0 && p < filename.length() - 2) {
            fileExt = filename.substring(p + 1, filename.length());
          }
        }
        if ("hdr".equalsIgnoreCase(fileExt)) {
          SimpleHDRImage hdrImg = new ImageReader(this).loadHDRImage(currFile.getAbsolutePath());
          SimpleImage img = new FastHDRTonemapper().renderImage(hdrImg);
          ScaleTransformer scaleT = new ScaleTransformer();
          scaleT.setScaleWidth(THUMBNAIL_WIDTH);
          scaleT.setAspect(ScaleAspect.KEEP_WIDTH);
          scaleT.setUnit(Unit.PIXELS);
View Full Code Here


      if (p >= 0 && p < pFilename.length() - 2) {
        fileExt = pFilename.substring(p + 1, pFilename.length());
      }
    }
    if ("hdr".equalsIgnoreCase(fileExt)) {
      SimpleHDRImage img = new ImageReader(desktop).loadHDRImage(pFilename);
      File file = new File(pFilename);
      Buffer buffer = bufferList.addHDRImageBuffer(addBuffersToDesktop ? desktop : null, file.getName(),
          img);
      return buffer;
    }
View Full Code Here

    if (inBuffer == null) {
      dumpBuffers();
      throw new RuntimeException("Input buffer <" + pInputName + "> not found");
    }
    SimpleImage newImg = null;
    SimpleHDRImage newHDRImg = null;
    if (inBuffer.getBufferType() == BufferType.IMAGE) {
      transformer.setStoreMesh3D(pStoreMesh3D);
      newImg = inBuffer.getImage().clone();
      transformer.transformImage(newImg);
    }
View Full Code Here

  @Property(category = PropertyCategory.PRIMARY, description = "Foreground intensity")
  private double intensity = 1.0;

  @Override
  protected void performImageTransformation(WFImage pImg) {
    SimpleHDRImage fgImg = foreground.getHDRImage();
    SimpleHDRImage bgImg = (SimpleHDRImage) pImg;
    if ((fgImg.getImageWidth() != bgImg.getImageWidth()) || (fgImg.getImageHeight() != bgImg.getImageHeight())) {
      throw new IllegalArgumentException();
    }
    SimpleHDRImage res = new SimpleHDRImage(fgImg.getImageWidth(), fgImg.getImageHeight());
    float fgRGB[] = new float[3];
    float bgRGB[] = new float[3];
    float r, g, b;
    float trans = (float) transparency * 0.01f;
    if (trans < 0.0f) {
      trans = 0.0f;
    }
    else if (trans > 1.0f) {
      trans = 1.0f;
    }
    float invTrans = 1.0f - trans;
    float fgScale = (float) intensity;
    float bgScale = (float) intensity;
    float fgRed, fgGreen, fgBlue;
    float bgRed, bgGreen, bgBlue;
    float mergedRed, mergedGreen, mergedBlue;
    HSLTransformer fgHSL = new HSLTransformer();
    HSLTransformer bgHSL = new HSLTransformer();
    HSLTransformer mergedHSL = new HSLTransformer();

    float lum[] = new float[2];
    fgImg.getMinMaxLum(lum);
    float fgLumMin = lum[0];
    float fgLumMax = lum[1];
    if ((fgLumMax - fgLumMin) < MathLib.EPSILON) {
      fgLumMax = fgLumMin + (float) MathLib.EPSILON;
    }
    bgImg.getMinMaxLum(lum);
    float bgLumMin = lum[0];
    float bgLumMax = lum[1];
    if ((bgLumMax - bgLumMin) < MathLib.EPSILON) {
      bgLumMax = bgLumMin + (float) MathLib.EPSILON;
    }
    bgScale *= (fgLumMax - fgLumMin) / (bgLumMax - bgLumMin);
    for (int i = 0; i < fgImg.getImageHeight(); i++) {
      for (int j = 0; j < fgImg.getImageWidth(); j++) {
        fgImg.getRGBValues(fgRGB, j, i);
        fgRed = fgRGB[0] * fgScale;
        fgGreen = fgRGB[1] * fgScale;
        fgBlue = fgRGB[2] * fgScale;
        bgRed = bgRGB[0] * bgScale;
        bgGreen = bgRGB[1] * bgScale;
        bgBlue = bgRGB[2] * bgScale;
        bgImg.getRGBValues(bgRGB, j, i);
        switch (mergeMode) {
          case MULTIPLY:
            mergedRed = fgRed * bgRed;
            mergedGreen = fgGreen * bgGreen;
            mergedBlue = fgBlue * bgBlue;
            break;
          case ADD:
            mergedRed = (fgRed + bgRed) * 0.5f;
            mergedGreen = (fgGreen + bgGreen) * 0.5f;
            mergedBlue = (fgBlue + bgBlue) * 0.5f;
            break;
          case SUBTRACT:
            mergedRed = bgRed - fgRed;
            if (mergedRed < 0.0f) {
              mergedRed = 0.0f;
            }
            mergedGreen = bgGreen - fgGreen;
            if (mergedGreen < 0.0f) {
              mergedGreen = 0.0f;
            }
            mergedBlue = bgBlue - fgBlue;
            if (mergedBlue < 0.0f) {
              mergedBlue = 0.0f;
            }
            break;
          case RED:
            mergedRed = fgRed;
            mergedGreen = bgGreen;
            mergedBlue = bgBlue;
            break;
          case GREEN:
            mergedRed = bgRed;
            mergedGreen = fgGreen;
            mergedBlue = bgBlue;
            break;
          case BLUE:
            mergedRed = bgRed;
            mergedGreen = bgGreen;
            mergedBlue = fgBlue;
            break;
          case LIGHTEN: {
            float fgLum = SimpleHDRImage.calcLum(fgRed, fgGreen, fgBlue);
            float bgLum = SimpleHDRImage.calcLum(bgRed, bgGreen, bgBlue);
            if (fgLum > bgLum) {
              mergedRed = fgRed;
              mergedGreen = fgGreen;
              mergedBlue = fgBlue;
            }
            else {
              mergedRed = bgRed;
              mergedGreen = bgGreen;
              mergedBlue = bgBlue;
            }
          }
            break;
          case DARKEN: {
            float fgLum = SimpleHDRImage.calcLum(fgRed, fgGreen, fgBlue);
            float bgLum = SimpleHDRImage.calcLum(bgRed, bgGreen, bgBlue);
            if (fgLum < bgLum) {
              mergedRed = fgRed;
              mergedGreen = fgGreen;
              mergedBlue = fgBlue;
            }
            else {
              mergedRed = bgRed;
              mergedGreen = bgGreen;
              mergedBlue = bgBlue;
            }
          }
            break;
          case HSL_ADD:
            fgHSL.setRGB(fgRed, fgGreen, fgBlue);
            bgHSL.setRGB(bgRed, bgGreen, bgBlue);
            mergedHSL.setHSL(fgHSL.getHue() + bgHSL.getHue(), fgHSL.getSaturation() + bgHSL.getSaturation(), fgHSL.getLuminosity() + bgHSL.getLuminosity(), fgHSL.getAmp());
            mergedRed = mergedHSL.getRed();
            mergedGreen = mergedHSL.getGreen();
            mergedBlue = mergedHSL.getBlue();
            break;
          default:
            mergedRed = fgRed;
            mergedGreen = fgGreen;
            mergedBlue = fgBlue;
            break;
        }
        r = mergedRed * invTrans + bgRed * trans;
        g = mergedGreen * invTrans + bgGreen * trans;
        b = mergedBlue * invTrans + bgBlue * trans;
        res.setRGB(j, i, r, g, b);
      }
    }

    ((SimpleHDRImage) pImg).assignImage(res);
  }
View Full Code Here

  }

  public void init(RenderInfo pRenderInfo) {
    image = new SimpleImage(pRenderInfo.getImageWidth(), pRenderInfo.getImageHeight());
    if (pRenderInfo.isRenderHDR()) {
      hdrImage = new SimpleHDRImage(pRenderInfo.getImageWidth(), pRenderInfo.getImageHeight());
    }
    if (pRenderInfo.isRenderHDRIntensityMap()) {
      hdrHeightMap = new SimpleHDRImage(pRenderInfo.getImageWidth(), pRenderInfo.getImageHeight());
    }
  }
View Full Code Here

    if (!matcher.find()) {
      throw new IllegalArgumentException("Invalid dimension identifier<" + dimension + ">");
    }
    int width = Integer.parseInt(matcher.group(2));
    int height = Integer.parseInt(matcher.group(1));
    SimpleHDRImage res = new SimpleHDRImage(width, height);
    for (int i = 0; i < height; i++) {
      for (int j = 0; j < width; j++) {
        int r = f.read();
        int g = f.read();
        int b = f.read();
        int e = f.read();
        res.setRGBEValue(j, i, r, g, b, e);
      }
    }
    return res;
  }
View Full Code Here

    }

    double origZoom = flame.getCamZoom();
    try {
      SimpleImage img = renderNormal ? res.getImage() : null;
      SimpleHDRImage hdrImg = renderHDR ? res.getHDRImage() : null;
      SimpleHDRImage hdrIntensityMapImg = renderHDRIntensityMap ? res.getHDRIntensityMap() : null;
      if (renderNormal) {
        initRaster(img.getImageWidth(), img.getImageHeight());
      }
      else if (renderHDR) {
        initRaster(hdrImg.getImageWidth(), hdrImg.getImageHeight());
      }
      else if (renderHDRIntensityMap) {
        initRaster(hdrIntensityMapImg.getImageWidth(), hdrIntensityMapImg.getImageHeight());
      }
      else {
        throw new IllegalStateException();
      }
      List<List<RenderPacket>> renderFlames = new ArrayList<List<RenderPacket>>();
View Full Code Here

TOP

Related Classes of org.jwildfire.image.SimpleHDRImage

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.