Search in sources :

Example 26 with ResolutionProfile

use of org.jwildfire.base.ResolutionProfile in project JWildfire by thargor6.

the class TinaController method refreshResolutionProfileCmb.

private void refreshResolutionProfileCmb(JComboBox pCmb, ResolutionProfile pSelectedProfile) {
    boolean oldCmbRefreshing = cmbRefreshing;
    cmbRefreshing = true;
    try {
        ResolutionProfile selected = pSelectedProfile;
        ResolutionProfile defaultProfile = null;
        pCmb.removeAllItems();
        for (ResolutionProfile profile : prefs.getResolutionProfiles()) {
            if (selected == null && profile.isDefaultProfile()) {
                selected = profile;
            }
            if (defaultProfile == null && profile.isDefaultProfile()) {
                defaultProfile = profile;
            }
            pCmb.addItem(profile);
        }
        if (selected != null) {
            pCmb.setSelectedItem(selected);
        }
        if (pCmb.getSelectedIndex() < 0 && defaultProfile != null) {
            pCmb.setSelectedItem(defaultProfile);
        }
        if (pCmb.getSelectedIndex() < 0 && prefs.getResolutionProfiles().size() > 0) {
            pCmb.setSelectedIndex(0);
        }
    } finally {
        cmbRefreshing = oldCmbRefreshing;
    }
}
Also used : ResolutionProfile(org.jwildfire.base.ResolutionProfile)

Example 27 with ResolutionProfile

use of org.jwildfire.base.ResolutionProfile in project JWildfire by thargor6.

the class TinaController method renderImageButton_actionPerformed.

public void renderImageButton_actionPerformed() {
    if (mainRenderThread != null) {
        mainRenderThread.setForceAbort();
        while (mainRenderThread.isFinished()) {
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        mainRenderThread = null;
        enableMainRenderControls();
    } else if (getCurrFlame() != null) {
        try {
            String dfltFileExt = Stereo3dMode.SIDE_BY_SIDE.equals(getCurrFlame().getStereo3dMode()) ? Tools.FILEEXT_PNS : Tools.FILEEXT_PNG;
            JFileChooser chooser = new ImageFileChooser(dfltFileExt);
            if (prefs.getOutputImagePath() != null) {
                try {
                    chooser.setCurrentDirectory(new File(prefs.getOutputImagePath()));
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
            if (chooser.showSaveDialog(centerPanel) == JFileChooser.APPROVE_OPTION) {
                QualityProfile qualProfile = getQualityProfile();
                ResolutionProfile resProfile = getResolutionProfile();
                final Flame flame = getCurrFlame();
                final File file = chooser.getSelectedFile();
                prefs.setLastOutputImageFile(file);
                RenderMainFlameThreadFinishEvent finishEvent = new RenderMainFlameThreadFinishEvent() {

                    @Override
                    public void succeeded(double pElapsedTime) {
                        try {
                            messageHelper.showStatusMessage(flame, "render time: " + Tools.doubleToString(pElapsedTime) + "s");
                            mainController.loadImage(file.getAbsolutePath(), false);
                            File zBuffer = new File(Tools.makeZBufferFilename(file.getAbsolutePath()));
                            if (zBuffer.exists()) {
                                mainController.loadImage(zBuffer.getAbsolutePath(), false);
                            }
                        } catch (Throwable ex) {
                            errorHandler.handleError(ex);
                        }
                        mainRenderThread = null;
                        enableMainRenderControls();
                    }

                    @Override
                    public void failed(Throwable exception) {
                        errorHandler.handleError(exception);
                        mainRenderThread = null;
                        enableMainRenderControls();
                    }
                };
                mainRenderThread = new RenderMainFlameThread(prefs, flame, file, qualProfile, resProfile, finishEvent, mainProgressUpdater);
                enableMainRenderControls();
                Thread worker = new Thread(mainRenderThread);
                worker.setPriority(Thread.MIN_PRIORITY);
                worker.start();
            }
        } catch (Throwable ex) {
            errorHandler.handleError(ex);
        }
    }
}
Also used : ResolutionProfile(org.jwildfire.base.ResolutionProfile) ImageFileChooser(org.jwildfire.swing.ImageFileChooser) JFileChooser(javax.swing.JFileChooser) QualityProfile(org.jwildfire.base.QualityProfile) File(java.io.File) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 28 with ResolutionProfile

use of org.jwildfire.base.ResolutionProfile in project JWildfire by thargor6.

the class TinaInteractiveRendererController method renderButton_clicked.

public void renderButton_clicked() {
    try {
        clearScreen();
        ResolutionProfile resProfile = getResolutionProfile();
        int width = resProfile.getWidth();
        int height = resProfile.getHeight();
        if (quarterSizeButton.isSelected()) {
            width /= 4;
            height /= 4;
        } else if (halveSizeButton.isSelected()) {
            width /= 2;
            height /= 2;
        }
        RenderInfo info = new RenderInfo(width, height, RenderMode.INTERACTIVE);
        Flame flame = getCurrFlame();
        if (!Stereo3dMode.NONE.equals(flame.getStereo3dMode())) {
            throw new Exception("Stereo3d-rendering isn't currently supported in the interactive-renderer. Please use the editor or the batch-renderer to create stereo3d-images");
        }
        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());
        flame.setSampleDensity(10);
        info.setRenderHDR(prefs.isTinaSaveHDRInIR());
        info.setRenderZBuffer(false);
        if (flame.getBgColorRed() > 0 || flame.getBgColorGreen() > 0 || flame.getBgColorBlue() > 0) {
            image.fillBackground(flame.getBgColorRed(), flame.getBgColorGreen(), flame.getBgColorBlue());
        }
        renderer = new FlameRenderer(flame, prefs, flame.isBGTransparency(), false);
        renderer.registerIterationObserver(this);
        displayUpdater = createDisplayUpdater();
        renderStartTime = System.currentTimeMillis();
        pausedRenderTime = 0;
        lastQuality = 0.0;
        lastQualitySpeed = 0.0;
        lastQualityTime = 0;
        displayUpdater.initRender(prefs.getTinaRenderThreads());
        threads = renderer.startRenderFlame(info);
        for (Thread t : threads.getExecutingThreads()) {
            t.setPriority(Thread.MIN_PRIORITY);
        }
        updateDisplayThread = new UpdateDisplayThread();
        startRenderThread(updateDisplayThread);
        state = State.RENDER;
        enableControls();
    } catch (Throwable ex) {
        errorHandler.handleError(ex);
    }
}
Also used : ResolutionProfile(org.jwildfire.base.ResolutionProfile) FlameRenderer(org.jwildfire.create.tina.render.FlameRenderer) RenderInfo(org.jwildfire.create.tina.render.RenderInfo) XYZProjectedPoint(org.jwildfire.create.tina.base.XYZProjectedPoint) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame) AbstractRenderThread(org.jwildfire.create.tina.render.AbstractRenderThread)

Example 29 with ResolutionProfile

use of org.jwildfire.base.ResolutionProfile in project JWildfire by thargor6.

the class TinaInteractiveRendererController method refreshImagePanel.

private void refreshImagePanel() {
    if (imageScrollPane != null) {
        imageRootPanel.remove(imageScrollPane);
        imageScrollPane = null;
    }
    ResolutionProfile profile = getResolutionProfile();
    int width = profile.getWidth();
    int height = profile.getHeight();
    if (quarterSizeButton.isSelected()) {
        width /= 4;
        height /= 4;
    } else if (halveSizeButton.isSelected()) {
        width /= 2;
        height /= 2;
    }
    image = new SimpleImage(width, height);
    image.getBufferedImg().setAccelerationPriority(1.0f);
    image.fillBackground(prefs.getTinaRandomBatchBGColorRed(), prefs.getTinaRandomBatchBGColorGreen(), prefs.getTinaRandomBatchBGColorBlue());
    ImagePanel imagePanel = new ImagePanel(image, 0, 0, image.getImageWidth());
    imagePanel.setSize(image.getImageWidth(), image.getImageHeight());
    imagePanel.setPreferredSize(new Dimension(image.getImageWidth(), image.getImageHeight()));
    imageScrollPane = new JScrollPane(imagePanel);
    imageScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    imageScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    imageRootPanel.add(imageScrollPane, BorderLayout.CENTER);
    imageRootPanel.getParent().validate();
}
Also used : ResolutionProfile(org.jwildfire.base.ResolutionProfile) JScrollPane(javax.swing.JScrollPane) SimpleImage(org.jwildfire.image.SimpleImage) Dimension(java.awt.Dimension) XYZProjectedPoint(org.jwildfire.create.tina.base.XYZProjectedPoint) ImagePanel(org.jwildfire.swing.ImagePanel)

Aggregations

ResolutionProfile (org.jwildfire.base.ResolutionProfile)29 SimpleImage (org.jwildfire.image.SimpleImage)8 Flame (org.jwildfire.create.tina.base.Flame)7 QualityProfile (org.jwildfire.base.QualityProfile)6 ArrayList (java.util.ArrayList)5 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)5 FlamePanel (org.jwildfire.create.tina.swing.flamepanel.FlamePanel)5 Dimension (java.awt.Dimension)3 Point (java.awt.Point)3 File (java.io.File)3 XYZProjectedPoint (org.jwildfire.create.tina.base.XYZProjectedPoint)3 ImagePanel (org.jwildfire.swing.ImagePanel)3 JFileChooser (javax.swing.JFileChooser)2 JPanel (javax.swing.JPanel)2 JScrollPane (javax.swing.JScrollPane)2 Test (org.junit.Test)2 Layer (org.jwildfire.create.tina.base.Layer)2 XForm (org.jwildfire.create.tina.base.XForm)2 HeadlessBatchRendererController (org.jwildfire.create.tina.batch.HeadlessBatchRendererController)2 Job (org.jwildfire.create.tina.batch.Job)2