Search in sources :

Example 1 with Stereo3dColor

use of org.jwildfire.create.tina.base.Stereo3dColor in project JWildfire by thargor6.

the class FlameRenderer method renderStereo3dAnaglyph.

private RenderedFlame renderStereo3dAnaglyph(RenderInfo pRenderInfo) {
    RenderInfo localRenderInfo = pRenderInfo.makeCopy();
    localRenderInfo.setRenderHDR(false);
    localRenderInfo.setRenderZBuffer(false);
    eye = Stereo3dEye.LEFT;
    RenderedFlame leftRender = renderImageNormal(localRenderInfo, 2, 0);
    eye = Stereo3dEye.RIGHT;
    RenderedFlame rightRender = renderImageNormal(localRenderInfo, 2, 1);
    if (flame.isStereo3dSwapSides()) {
        RenderedFlame tmp = leftRender;
        leftRender = rightRender;
        rightRender = tmp;
    }
    Pixel lPixel = new Pixel();
    Pixel rPixel = new Pixel();
    Stereo3dColor leftColor = flame.getAnaglyph3dLeftEyeColor();
    Stereo3dColor rightColor = flame.getAnaglyph3dRightEyeColor();
    SimpleImage leftImg = leftRender.getImage();
    SimpleImage rightImg = rightRender.getImage();
    RenderedFlame mergedRender = new RenderedFlame();
    localRenderInfo.setImageWidth(leftRender.getImage().getImageWidth());
    localRenderInfo.setImageHeight(leftRender.getImage().getImageHeight());
    mergedRender.init(localRenderInfo, flame);
    SimpleImage mergedImg = mergedRender.getImage();
    for (int i = 0; i < mergedImg.getImageHeight(); i++) {
        for (int j = 0; j < mergedImg.getImageWidth(); j++) {
            lPixel.setARGBValue(leftImg.getARGBValue(j, i));
            rPixel.setARGBValue(rightImg.getARGBValue(j, i));
            int mr = leftColor.calculateRed(lPixel.r, lPixel.g, lPixel.b) + rightColor.calculateRed(rPixel.r, rPixel.g, rPixel.b);
            if (mr < 0)
                mr = 0;
            else if (mr > 255)
                mr = 255;
            int mg = leftColor.calculateGreen(lPixel.r, lPixel.g, lPixel.b) + rightColor.calculateGreen(rPixel.r, rPixel.g, rPixel.b);
            if (mg < 0)
                mg = 0;
            else if (mg > 255)
                mg = 255;
            int mb = leftColor.calculateBlue(lPixel.r, lPixel.g, lPixel.b) + rightColor.calculateBlue(rPixel.r, rPixel.g, rPixel.b);
            if (mb < 0)
                mb = 0;
            else if (mb > 255)
                mb = 255;
            mergedImg.setRGB(j, i, mr, mg, mb);
        }
    }
    return mergedRender;
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) Stereo3dColor(org.jwildfire.create.tina.base.Stereo3dColor) Pixel(org.jwildfire.image.Pixel) PCPoint(org.jwildfire.create.tina.base.raster.RasterPointCloud.PCPoint)

Aggregations

Stereo3dColor (org.jwildfire.create.tina.base.Stereo3dColor)1 PCPoint (org.jwildfire.create.tina.base.raster.RasterPointCloud.PCPoint)1 Pixel (org.jwildfire.image.Pixel)1 SimpleImage (org.jwildfire.image.SimpleImage)1