Search in sources :

Example 16 with FlameWriter

use of org.jwildfire.create.tina.io.FlameWriter in project JWildfire by thargor6.

the class RenderMainFlameThread method run.

@Override
public void run() {
    finished = forceAbort = false;
    try {
        int width = resProfile.getWidth();
        int height = resProfile.getHeight();
        RenderInfo info = new RenderInfo(width, height, RenderMode.PRODUCTION);
        double wScl = (double) info.getImageWidth() / (double) flame.getWidth();
        double hScl = (double) info.getImageHeight() / (double) flame.getHeight();
        flame.setPixelsPerUnit((wScl + hScl) * 0.5 * flame.getPixelsPerUnit());
        flame.setWidth(info.getImageWidth());
        flame.setHeight(info.getImageHeight());
        boolean renderHDR = qualProfile.isWithHDR();
        info.setRenderHDR(renderHDR);
        boolean renderZBuffer = qualProfile.isWithZBuffer();
        info.setRenderZBuffer(renderZBuffer);
        flame.setSampleDensity(qualProfile.getQuality());
        long t0, t1;
        renderer = new FlameRenderer(flame, prefs, flame.isBGTransparency(), false);
        renderer.setProgressUpdater(progressUpdater);
        t0 = Calendar.getInstance().getTimeInMillis();
        RenderedFlame res = renderer.renderFlame(info);
        if (forceAbort) {
            finished = true;
            return;
        }
        t1 = Calendar.getInstance().getTimeInMillis();
        new ImageWriter().saveImage(res.getImage(), outFile.getAbsolutePath());
        if (res.getHDRImage() != null) {
            new ImageWriter().saveImage(res.getHDRImage(), Tools.makeHDRFilename(outFile.getAbsolutePath()));
        }
        if (res.getZBuffer() != null) {
            new ImageWriter().saveImage(res.getZBuffer(), Tools.makeZBufferFilename(outFile.getAbsolutePath()));
        }
        if (prefs.isTinaSaveFlamesWhenImageIsSaved()) {
            new FlameWriter().writeFlame(flame, outFile.getParentFile().getAbsolutePath() + File.separator + Tools.trimFileExt(outFile.getName()) + ".flame");
        }
        finished = true;
        finishEvent.succeeded((t1 - t0) * 0.001);
    } catch (Throwable ex) {
        finished = true;
        finishEvent.failed(ex);
    }
}
Also used : FlameWriter(org.jwildfire.create.tina.io.FlameWriter) ImageWriter(org.jwildfire.io.ImageWriter) FlameRenderer(org.jwildfire.create.tina.render.FlameRenderer) RenderInfo(org.jwildfire.create.tina.render.RenderInfo) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 17 with FlameWriter

use of org.jwildfire.create.tina.io.FlameWriter in project JWildfire by thargor6.

the class Boarders2Test method visual.

// @Ignore
@Test
public void visual() throws Exception {
    Prefs.getPrefs().setTinaRandomNumberGenerator(RandomGeneratorType.JAVA_INTERNAL);
    System.out.println(Prefs.getPrefs().getTinaRandomNumberGenerator().name());
    int side = 600;
    ResolutionProfile respro = new ResolutionProfile(true, side, side);
    int quality = 80;
    Flame f = new Flame();
    f.setWidth(side);
    f.setHeight(side);
    f.setGamma(4.0);
    f.setBGTransparency(false);
    f.setAntialiasAmount(1.0);
    f.setAntialiasRadius(.1);
    Layer l = new Layer();
    XForm xf = new XForm();
    Boarders2Func bf = new Boarders2Func();
    bf.setParameter("c", .6);
    bf.setParameter("left", .65);
    bf.setParameter("right", .35);
    xf.addVariation(1.0, bf);
    f.setCamZoom(6.461);
    xf.setWeight(5.5);
    l.getXForms().add(xf);
    RGBPalette pal = new RGBPalette();
    for (int i = 0; i < 256; i++) pal.addColor(0, i, 255);
    pal.setFlam3Name("test");
    l.setPalette(pal);
    f.setResolutionProfile(respro);
    f.getLayers().clear();
    f.getLayers().add(l);
    // this is "scale"
    f.setPixelsPerUnit(43.75);
    new FlameWriter().writeFlame(f, "/dev/shm/test.flame");
    JobRenderThreadController controller = new HeadlessBatchRendererController();
    List<Job> joblist = new ArrayList<>();
    Job j = new Job();
    j.setCustomHeight(side);
    j.setCustomWidth(side);
    j.setCustomQuality(quality);
    j.setFlameFilename("/dev/shm/test.flame");
    joblist.add(j);
    QualityProfile qualpro = new QualityProfile();
    qualpro.setQuality(quality);
    JobRenderThread job = new JobRenderThread(controller, joblist, respro, qualpro, true);
    job.run();
}
Also used : ResolutionProfile(org.jwildfire.base.ResolutionProfile) XForm(org.jwildfire.create.tina.base.XForm) RGBPalette(org.jwildfire.create.tina.palette.RGBPalette) HeadlessBatchRendererController(org.jwildfire.create.tina.batch.HeadlessBatchRendererController) ArrayList(java.util.ArrayList) Layer(org.jwildfire.create.tina.base.Layer) XYZPoint(org.jwildfire.create.tina.base.XYZPoint) FlameWriter(org.jwildfire.create.tina.io.FlameWriter) JobRenderThread(org.jwildfire.create.tina.batch.JobRenderThread) QualityProfile(org.jwildfire.base.QualityProfile) Job(org.jwildfire.create.tina.batch.Job) JobRenderThreadController(org.jwildfire.create.tina.batch.JobRenderThreadController) Flame(org.jwildfire.create.tina.base.Flame) Test(org.junit.Test)

Example 18 with FlameWriter

use of org.jwildfire.create.tina.io.FlameWriter in project JWildfire by thargor6.

the class JWildfireApplet method copyToClipboardBtn_clicked.

protected void copyToClipboardBtn_clicked() throws Exception {
    Flame currFlame = getCurrFlame();
    if (currFlame != null) {
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        String xml = new FlameWriter().getFlameXML(currFlame);
        StringSelection data = new StringSelection(xml);
        clipboard.setContents(data, data);
    }
}
Also used : FlameWriter(org.jwildfire.create.tina.io.FlameWriter) Clipboard(java.awt.datatransfer.Clipboard) Flame(org.jwildfire.create.tina.base.Flame) StringSelection(java.awt.datatransfer.StringSelection)

Example 19 with FlameWriter

use of org.jwildfire.create.tina.io.FlameWriter in project JWildfire by thargor6.

the class FlamesGPURenderController method toClipboardButton_clicked.

public void toClipboardButton_clicked() {
    try {
        Flame currFlame = getCurrFlame();
        if (currFlame != null) {
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            String xml = new FlameWriter().getFlameXML(currFlame);
            StringSelection data = new StringSelection(xml);
            clipboard.setContents(data, data);
        }
    } catch (Throwable ex) {
        errorHandler.handleError(ex);
    }
}
Also used : FACLFlameWriter(org.jwildfire.create.tina.faclrender.FACLFlameWriter) FlameWriter(org.jwildfire.create.tina.io.FlameWriter) Clipboard(java.awt.datatransfer.Clipboard) Flame(org.jwildfire.create.tina.base.Flame) StringSelection(java.awt.datatransfer.StringSelection)

Example 20 with FlameWriter

use of org.jwildfire.create.tina.io.FlameWriter in project JWildfire by thargor6.

the class FlamesGPURenderController method saveFlameButton_clicked.

public void saveFlameButton_clicked() {
    try {
        Flame currFlame = getCurrFlame();
        if (currFlame != null) {
            JFileChooser chooser = new FlameFileChooser(prefs);
            if (prefs.getOutputFlamePath() != null) {
                try {
                    chooser.setCurrentDirectory(new File(prefs.getOutputFlamePath()));
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
            if (chooser.showSaveDialog(imageRootPanel) == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                new FlameWriter().writeFlame(currFlame, file.getAbsolutePath());
                prefs.setLastOutputFlameFile(file);
            }
        }
    } catch (Throwable ex) {
        errorHandler.handleError(ex);
    }
}
Also used : FACLFlameWriter(org.jwildfire.create.tina.faclrender.FACLFlameWriter) FlameWriter(org.jwildfire.create.tina.io.FlameWriter) JFileChooser(javax.swing.JFileChooser) File(java.io.File) Flame(org.jwildfire.create.tina.base.Flame)

Aggregations

FlameWriter (org.jwildfire.create.tina.io.FlameWriter)25 Flame (org.jwildfire.create.tina.base.Flame)15 File (java.io.File)11 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)9 JFileChooser (javax.swing.JFileChooser)8 XForm (org.jwildfire.create.tina.base.XForm)6 Clipboard (java.awt.datatransfer.Clipboard)5 StringSelection (java.awt.datatransfer.StringSelection)5 ArrayList (java.util.ArrayList)5 Layer (org.jwildfire.create.tina.base.Layer)5 FACLFlameWriter (org.jwildfire.create.tina.faclrender.FACLFlameWriter)3 ImageWriter (org.jwildfire.io.ImageWriter)3 Test (org.junit.Test)2 QualityProfile (org.jwildfire.base.QualityProfile)2 ResolutionProfile (org.jwildfire.base.ResolutionProfile)2 HeadlessBatchRendererController (org.jwildfire.create.tina.batch.HeadlessBatchRendererController)2 Job (org.jwildfire.create.tina.batch.Job)2 JobRenderThread (org.jwildfire.create.tina.batch.JobRenderThread)2 JobRenderThreadController (org.jwildfire.create.tina.batch.JobRenderThreadController)2 RGBPalette (org.jwildfire.create.tina.palette.RGBPalette)2