Search in sources :

Example 1 with ScaleTransformer

use of org.jwildfire.transform.ScaleTransformer in project JWildfire by thargor6.

the class RGBPaletteRenderer method renderHorizPalette.

public SimpleImage renderHorizPalette(RGBColor[] pColors, int pWidth, int pHeight) {
    if (pColors == null || pWidth < 1 || pHeight < 1)
        throw new IllegalArgumentException();
    SimpleImage img = new SimpleImage(RGBPalette.PALETTE_SIZE, pHeight);
    for (int i = 0; i < pColors.length; i++) {
        RGBColor color = pColors[i];
        if (color == null) {
            color = RGBPalette.BLACK;
        }
        int r = color.getRed();
        int g = color.getGreen();
        int b = color.getBlue();
        for (int j = 0; j < pHeight; j++) {
            img.setRGB(i, j, r, g, b);
        }
    }
    if (img.getImageWidth() != pWidth || img.getImageHeight() != pHeight) {
        ScaleTransformer scaleT = new ScaleTransformer();
        scaleT.setScaleWidth(pWidth);
        scaleT.setScaleHeight(pHeight);
        scaleT.setAspect(ScaleAspect.IGNORE);
        scaleT.setUnit(Unit.PIXELS);
        scaleT.transformImage(img);
    }
    return img;
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) ScaleTransformer(org.jwildfire.transform.ScaleTransformer)

Example 2 with ScaleTransformer

use of org.jwildfire.transform.ScaleTransformer in project JWildfire by thargor6.

the class BaseFlameListCreator method createParamMapList.

private List<SimpleImage> createParamMapList(SimpleImage structureMap, int pIndex) {
    List<SimpleImage> res = new ArrayList<SimpleImage>();
    for (FlameParams flameParam : flameParams) {
        SimpleImage paramMap = null;
        try {
            String flameParamname;
            String flameParamMapFilename;
            switch(pIndex) {
                case 0:
                    flameParamname = flameParam.getFlameParam1();
                    flameParamMapFilename = flameParam.getFlameParamMap1Filename();
                    break;
                case 1:
                    flameParamname = flameParam.getFlameParam2();
                    flameParamMapFilename = flameParam.getFlameParamMap2Filename();
                    break;
                case 2:
                    flameParamname = flameParam.getFlameParam3();
                    flameParamMapFilename = flameParam.getFlameParamMap3Filename();
                    break;
                default:
                    throw new IllegalArgumentException();
            }
            if (flameParamname != null && flameParamname.length() > 0 && flameParamMapFilename != null && flameParamMapFilename.length() > 0) {
                SimpleImage map = (SimpleImage) RessourceManager.getImage(flameParamMapFilename);
                if ((map.getImageWidth() != structureMap.getImageWidth()) || (map.getImageHeight() != structureMap.getImageHeight())) {
                    map = map.clone();
                    ScaleTransformer scaleT = new ScaleTransformer();
                    scaleT.setScaleWidth(structureMap.getImageWidth());
                    scaleT.setScaleHeight(structureMap.getImageHeight());
                    scaleT.setAspect(ScaleAspect.IGNORE);
                    scaleT.transformImage(map);
                    paramMap = map;
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        res.add(paramMap);
    }
    return res;
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) ArrayList(java.util.ArrayList) ScaleTransformer(org.jwildfire.transform.ScaleTransformer)

Example 3 with ScaleTransformer

use of org.jwildfire.transform.ScaleTransformer in project JWildfire by thargor6.

the class FlameRenderer method renderImageStereo3d.

private RenderedFlame renderImageStereo3d(RenderInfo pRenderInfo) {
    Stereo3dEye storedEye = eye;
    double storedAngle = flame.getStereo3dAngle();
    double storedEyeDist = flame.getStereo3dEyeDist();
    try {
        switch(pRenderInfo.getRenderMode()) {
            case PREVIEW:
                switch(flame.getStereo3dPreview()) {
                    case SIDE_BY_SIDE:
                        {
                            RenderedFlame result = renderStereo3dSideBySide(pRenderInfo);
                            ScaleTransformer scaleTransformer = new ScaleTransformer();
                            scaleTransformer.setAspect(ScaleAspect.IGNORE);
                            scaleTransformer.setScaleWidth(pRenderInfo.getImageWidth() * renderScale);
                            scaleTransformer.setScaleHeight(pRenderInfo.getImageHeight() * renderScale);
                            scaleTransformer.transformImage(result.getImage());
                            return result;
                        }
                    case SIDE_BY_SIDE_FULL:
                        {
                            int oldWidth = pRenderInfo.getImageWidth();
                            pRenderInfo.setImageWidth(oldWidth / 2);
                            RenderedFlame result = renderStereo3dSideBySide(pRenderInfo);
                            pRenderInfo.setImageWidth(oldWidth);
                            return result;
                        }
                    case ANAGLYPH:
                        {
                            return renderStereo3dAnaglyph(pRenderInfo);
                        }
                    case NONE:
                        return renderImageNormal(pRenderInfo, 1, 0);
                    default:
                        throw new IllegalStateException(pRenderInfo.getRenderMode().toString());
                }
            case PRODUCTION:
                switch(flame.getStereo3dMode()) {
                    case ANAGLYPH:
                        return renderStereo3dAnaglyph(pRenderInfo);
                    case INTERPOLATED_IMAGES:
                        {
                            RenderInfo localRenderInfo = pRenderInfo.makeCopy();
                            localRenderInfo.setRenderHDR(false);
                            localRenderInfo.setRenderZBuffer(false);
                            RenderedFlame[] leftRenders = new RenderedFlame[flame.getStereo3dInterpolatedImageCount()];
                            double dAngle = storedAngle / (double) leftRenders.length;
                            double dEyeDist = storedEyeDist / (double) leftRenders.length;
                            int totalImageCount = 2 * leftRenders.length;
                            int totalImageIdx = 0;
                            for (int i = 0; i < leftRenders.length; i++) {
                                eye = Stereo3dEye.LEFT;
                                flame.setStereo3dAngle((i + 1) * dAngle);
                                flame.setStereo3dEyeDist((i + 1) * dEyeDist);
                                leftRenders[i] = renderImageNormal(localRenderInfo, totalImageCount, totalImageIdx++);
                            }
                            RenderedFlame[] rightRenders = new RenderedFlame[flame.getStereo3dInterpolatedImageCount()];
                            for (int i = 0; i < rightRenders.length; i++) {
                                eye = Stereo3dEye.RIGHT;
                                flame.setStereo3dAngle((i + 1) * dAngle);
                                flame.setStereo3dEyeDist((i + 1) * dEyeDist);
                                rightRenders[i] = renderImageNormal(localRenderInfo, totalImageCount, totalImageIdx++);
                            }
                            if (flame.isStereo3dSwapSides()) {
                                RenderedFlame[] tmp = leftRenders;
                                leftRenders = rightRenders;
                                rightRenders = tmp;
                            }
                            RenderedFlame mergedRender = new RenderedFlame();
                            localRenderInfo.setImageWidth(2 * pRenderInfo.getImageWidth());
                            localRenderInfo.setImageHeight(leftRenders.length * pRenderInfo.getImageHeight());
                            mergedRender.init(localRenderInfo, flame);
                            SimpleImage mergedImg = mergedRender.getImage();
                            ComposeTransformer composeTransformer = new ComposeTransformer();
                            composeTransformer.setHAlign(HAlignment.OFF);
                            composeTransformer.setVAlign(VAlignment.OFF);
                            int yOff = 0;
                            for (int i = 0; i < leftRenders.length; i++) {
                                composeTransformer.setLeft(0);
                                composeTransformer.setTop(yOff);
                                composeTransformer.setForegroundImage(leftRenders[i].getImage());
                                composeTransformer.transformImage(mergedImg);
                                yOff += pRenderInfo.getImageHeight();
                            }
                            yOff = 0;
                            for (int i = 0; i < rightRenders.length; i++) {
                                composeTransformer.setLeft(pRenderInfo.getImageWidth());
                                composeTransformer.setTop(yOff);
                                composeTransformer.setForegroundImage(rightRenders[i].getImage());
                                composeTransformer.transformImage(mergedImg);
                                yOff += pRenderInfo.getImageHeight();
                            }
                            return mergedRender;
                        }
                    case SIDE_BY_SIDE:
                        return renderStereo3dSideBySide(pRenderInfo);
                    case NONE:
                        return renderImageNormal(pRenderInfo, 1, 0);
                    default:
                        throw new IllegalStateException(flame.getStereo3dMode().toString());
                }
            default:
                throw new IllegalStateException(pRenderInfo.getRenderMode().toString());
        }
    } finally {
        eye = storedEye;
        flame.setStereo3dAngle(storedAngle);
        flame.setStereo3dEyeDist(storedEyeDist);
    }
}
Also used : ComposeTransformer(org.jwildfire.transform.ComposeTransformer) Stereo3dEye(org.jwildfire.create.tina.base.Stereo3dEye) SimpleImage(org.jwildfire.image.SimpleImage) ScaleTransformer(org.jwildfire.transform.ScaleTransformer)

Example 4 with ScaleTransformer

use of org.jwildfire.transform.ScaleTransformer in project JWildfire by thargor6.

the class TileBrickCreator method fillImage.

@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);
            }
            ComposeTransformer cT = new ComposeTransformer();
            cT.setHAlign(ComposeTransformer.HAlignment.OFF);
            cT.setVAlign(ComposeTransformer.VAlignment.OFF);
            cT.setTop(i * brickHeight);
            int left = j * brickWidth + off;
            cT.setLeft(left);
            cT.setForegroundImage(compImg);
            cT.transformImage(res);
        }
    }
}
Also used : BalancingTransformer(org.jwildfire.transform.BalancingTransformer) ComposeTransformer(org.jwildfire.transform.ComposeTransformer) SimpleImage(org.jwildfire.image.SimpleImage) ScaleTransformer(org.jwildfire.transform.ScaleTransformer)

Example 5 with ScaleTransformer

use of org.jwildfire.transform.ScaleTransformer in project JWildfire by thargor6.

the class ScriptProcessor method executeTransformer.

public TransformResult executeTransformer(String pInputName, boolean pStoreMesh3D, String pOutputName, String pOutput3DName, boolean pRecordAction) {
    Buffer inBuffer = bufferList.bufferByName(pInputName);
    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);
    } else if (inBuffer.getBufferType() == BufferType.HDR_IMAGE) {
        transformer.setStoreMesh3D(pStoreMesh3D);
        newHDRImg = inBuffer.getHDRImage().clone();
        transformer.transformImage(newHDRImg);
    } else if (inBuffer.getBufferType() == BufferType.MESH3D) {
        transformer.setStoreMesh3D(pStoreMesh3D);
        Mesh3D mesh3D = inBuffer.getMesh3D();
        newImg = new SimpleImage(mesh3D.getImageWidth(), mesh3D.getImageHeight());
        transformer.setInputMesh3D(mesh3D);
        transformer.transformImage(newImg);
    }
    Buffer outBuffer = null;
    if (newImg != null) {
        outBuffer = bufferList.addImageBuffer(addBuffersToDesktop ? desktop : null, transformer.getName(), newImg);
        if ((pOutputName != null) && (pOutputName.length() > 0))
            outBuffer.setName(pOutputName);
    }
    Buffer outHDRBuffer = null;
    if (newHDRImg != null) {
        outHDRBuffer = bufferList.addHDRImageBuffer(addBuffersToDesktop ? desktop : null, transformer.getName(), newHDRImg);
        if ((pOutputName != null) && (pOutputName.length() > 0))
            outHDRBuffer.setName(pOutputName);
    }
    Buffer outBuffer3D = null;
    if (pStoreMesh3D) {
        ScaleTransformer scaleT = new ScaleTransformer();
        scaleT.setAspect(ScaleAspect.KEEP_WIDTH);
        scaleT.setUnit(ScaleTransformer.Unit.PIXELS);
        scaleT.setScaleWidth(120);
        SimpleImage scaledImg = newImg.clone();
        scaleT.transformImage(scaledImg);
        outBuffer3D = bufferList.addMesh3DBuffer(addBuffersToDesktop ? desktop : null, pInputName, transformer.getOutputMesh3D(true), scaledImg);
        if ((pOutput3DName != null) && (pOutput3DName.length() > 0))
            outBuffer3D.setName(pOutput3DName);
    }
    return new TransformResult(inBuffer, outBuffer, outHDRBuffer, outBuffer3D);
}
Also used : SimpleHDRImage(org.jwildfire.image.SimpleHDRImage) Mesh3D(org.jwildfire.transform.Mesh3D) SimpleImage(org.jwildfire.image.SimpleImage) ScaleTransformer(org.jwildfire.transform.ScaleTransformer)

Aggregations

SimpleImage (org.jwildfire.image.SimpleImage)8 ScaleTransformer (org.jwildfire.transform.ScaleTransformer)8 ArrayList (java.util.ArrayList)2 SimpleHDRImage (org.jwildfire.image.SimpleHDRImage)2 ComposeTransformer (org.jwildfire.transform.ComposeTransformer)2 ImageIcon (javax.swing.ImageIcon)1 Stereo3dEye (org.jwildfire.create.tina.base.Stereo3dEye)1 FastHDRTonemapper (org.jwildfire.image.FastHDRTonemapper)1 ImageReader (org.jwildfire.io.ImageReader)1 BalancingTransformer (org.jwildfire.transform.BalancingTransformer)1 Mesh3D (org.jwildfire.transform.Mesh3D)1