Search in sources :

Example 6 with ImageFileChooser

use of org.jwildfire.swing.ImageFileChooser in project JWildfire by thargor6.

the class TinaInteractiveRendererController method saveZBufferButton_clicked.

public void saveZBufferButton_clicked() {
    try {
        pauseRenderThreads();
        try {
            JFileChooser chooser = new ImageFileChooser(Tools.FILEEXT_PNG);
            if (prefs.getOutputImagePath() != null) {
                try {
                    chooser.setCurrentDirectory(new File(prefs.getOutputImagePath()));
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
            if (chooser.showSaveDialog(imageRootPanel) == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                double zBufferScale = Double.parseDouble(JOptionPane.showInputDialog(imageRootPanel, "Enter ZBuffer-Scale", currFlame.getZBufferScale()));
                currFlame.setZBufferScale(zBufferScale);
                RenderedFlame res = renderer.finishZBuffer(displayUpdater.getSampleCount());
                if (res.getZBuffer() != null) {
                    new ImageWriter().saveImage(res.getZBuffer(), file.getAbsolutePath());
                    if (autoLoadImageCBx.isSelected()) {
                        parentCtrl.mainController.loadImage(file.getAbsolutePath(), false);
                    }
                }
            }
        } finally {
            resumeRenderThreads();
        }
    } catch (Throwable ex) {
        errorHandler.handleError(ex);
    }
}
Also used : JFileChooser(javax.swing.JFileChooser) ImageFileChooser(org.jwildfire.swing.ImageFileChooser) ImageWriter(org.jwildfire.io.ImageWriter) File(java.io.File) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 7 with ImageFileChooser

use of org.jwildfire.swing.ImageFileChooser in project JWildfire by thargor6.

the class MeshGenController method generateButton_clicked.

public void generateButton_clicked() {
    if (renderSlicesThread != null) {
        renderSlicesThread.setForceAbort();
        while (renderSlicesThread.isFinished()) {
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        renderSlicesThread = null;
        enableControls();
    } else if (currBaseFlame != null) {
        try {
            JFileChooser chooser;
            if (isPointCloudMode()) {
                chooser = new PointCloudOutputFileChooser(Tools.FILEEXT_PLY);
                if (prefs.getTinaMeshPath() != null) {
                    try {
                        chooser.setCurrentDirectory(new File(prefs.getTinaMeshPath()));
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
            } else {
                chooser = new ImageFileChooser(Tools.FILEEXT_PNG);
                if (prefs.getOutputImagePath() != null) {
                    try {
                        chooser.setCurrentDirectory(new File(prefs.getOutputImagePath()));
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
            }
            if (chooser.showSaveDialog(rootPanel) == JFileChooser.APPROVE_OPTION) {
                final File file = chooser.getSelectedFile();
                prefs.setLastOutputImageFile(file);
                MeshGenGenerateThreadFinishEvent finishEvent = new MeshGenGenerateThreadFinishEvent() {

                    @Override
                    public void succeeded(double pElapsedTime) {
                        try {
                            tinaController.getMessageHelper().showStatusMessage(currBaseFlame, "render time: " + Tools.doubleToString(pElapsedTime) + "s");
                        } catch (Throwable ex) {
                            errorHandler.handleError(ex);
                        }
                        renderSlicesThread = null;
                        enableControls();
                    }

                    @Override
                    public void failed(Throwable exception) {
                        errorHandler.handleError(exception);
                        renderSlicesThread = null;
                        enableControls();
                    }
                };
                Flame flame = currBaseFlame.makeCopy();
                switch(getOutputType()) {
                    case VOXELSTACK:
                        {
                            String outfilenamePattern = SequenceFilenameGen.createFilenamePattern(file);
                            Flame grayFlame = flame.makeCopy();
                            RGBPalette gradient = new RGBPalette();
                            for (int i = 0; i < RGBPalette.PALETTE_SIZE; i++) {
                                gradient.setColor(i, 225, 225, 225);
                            }
                            grayFlame.getFirstLayer().setPalette(gradient);
                            renderSlicesThread = new RenderSlicesThread(prefs, grayFlame, outfilenamePattern, finishEvent, renderSequenceProgressUpdater, renderWidthREd.getIntValue(), renderHeightREd.getIntValue(), sliceCountREd.getIntValue(), slicesPerRenderREd.getIntValue(), renderQualityREd.getIntValue(), zminREd.getDoubleValue(), zmaxREd.getDoubleValue());
                            lastRenderedSequenceOutFilePattern = outfilenamePattern;
                            break;
                        }
                    case POINTCLOUD:
                        {
                            renderSlicesThread = new RenderPointCloudThread(prefs, flame, file.getAbsolutePath(), finishEvent, renderSequenceProgressUpdater, renderWidthREd.getIntValue(), renderHeightREd.getIntValue(), renderQualityREd.getIntValue(), zminREd.getDoubleValue(), zmaxREd.getDoubleValue(), meshGenCellSizeREd.getDoubleValue());
                            break;
                        }
                }
                enableControls();
                new Thread(renderSlicesThread).start();
            }
        } catch (Throwable ex) {
            errorHandler.handleError(ex);
        }
    }
}
Also used : RGBPalette(org.jwildfire.create.tina.palette.RGBPalette) ImageFileChooser(org.jwildfire.swing.ImageFileChooser) RenderSlicesThread(org.jwildfire.create.tina.meshgen.render.RenderSlicesThread) RenderPointCloudThread(org.jwildfire.create.tina.meshgen.render.RenderPointCloudThread) MeshGenRenderThread(org.jwildfire.create.tina.meshgen.render.MeshGenRenderThread) RenderSlicesThread(org.jwildfire.create.tina.meshgen.render.RenderSlicesThread) RenderPointCloudThread(org.jwildfire.create.tina.meshgen.render.RenderPointCloudThread) JFileChooser(javax.swing.JFileChooser) PointCloudOutputFileChooser(org.jwildfire.swing.PointCloudOutputFileChooser) File(java.io.File) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 8 with ImageFileChooser

use of org.jwildfire.swing.ImageFileChooser in project JWildfire by thargor6.

the class IFlamesController method loadImagesButton_clicked.

public void loadImagesButton_clicked() {
    JFileChooser chooser = new ImageFileChooser(Tools.FILEEXT_PNG);
    if (prefs.getInputImagePath() != null) {
        try {
            chooser.setCurrentDirectory(new File(prefs.getInputImagePath()));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    chooser.setMultiSelectionEnabled(true);
    if (chooser.showOpenDialog(centerPanel) == JFileChooser.APPROVE_OPTION) {
        Throwable lastError = null;
        for (File file : chooser.getSelectedFiles()) {
            try {
                String filename = file.getAbsolutePath();
                WFImage img = RessourceManager.getImage(filename);
                if (img.getImageWidth() < 16 || img.getImageHeight() < 16 || !(img instanceof SimpleImage)) {
                    throw new Exception("Invalid image");
                }
                prefs.setLastInputImageFile(file);
                addImageToImageLibrary(filename, new ThumbnailCacheKey(filename));
            } catch (Throwable ex) {
                lastError = ex;
            }
        }
        refreshImageLibrary();
        if (lastError != null) {
            errorHandler.handleError(lastError);
        }
    }
}
Also used : JFileChooser(javax.swing.JFileChooser) WFImage(org.jwildfire.image.WFImage) ThumbnailCacheKey(org.jwildfire.create.tina.swing.ThumbnailCacheKey) ImageFileChooser(org.jwildfire.swing.ImageFileChooser) SimpleImage(org.jwildfire.image.SimpleImage) File(java.io.File)

Example 9 with ImageFileChooser

use of org.jwildfire.swing.ImageFileChooser in project JWildfire by thargor6.

the class MeshGenController method loadSequenceButton_clicked.

public void loadSequenceButton_clicked() {
    JFileChooser chooser = new ImageFileChooser(Tools.FILEEXT_PNG);
    if (prefs.getInputImagePath() != null) {
        try {
            chooser.setCurrentDirectory(new File(prefs.getInputImagePath()));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    if (chooser.showOpenDialog(rootPanel) == JFileChooser.APPROVE_OPTION) {
        File file = chooser.getSelectedFile();
        prefs.setLastInputImageFile(file);
        importSequence(SequenceFilenameGen.guessFilenamePattern(file));
    }
}
Also used : JFileChooser(javax.swing.JFileChooser) ImageFileChooser(org.jwildfire.swing.ImageFileChooser) File(java.io.File)

Example 10 with ImageFileChooser

use of org.jwildfire.swing.ImageFileChooser 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)

Aggregations

File (java.io.File)12 JFileChooser (javax.swing.JFileChooser)12 ImageFileChooser (org.jwildfire.swing.ImageFileChooser)12 SimpleImage (org.jwildfire.image.SimpleImage)5 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)4 WFImage (org.jwildfire.image.WFImage)4 ImageWriter (org.jwildfire.io.ImageWriter)3 Flame (org.jwildfire.create.tina.base.Flame)2 FlameWriter (org.jwildfire.create.tina.io.FlameWriter)2 RGBPalette (org.jwildfire.create.tina.palette.RGBPalette)2 Font (java.awt.Font)1 QualityProfile (org.jwildfire.base.QualityProfile)1 ResolutionProfile (org.jwildfire.base.ResolutionProfile)1 XForm (org.jwildfire.create.tina.base.XForm)1 MaterialSettings (org.jwildfire.create.tina.base.solidrender.MaterialSettings)1 FACLFlameWriter (org.jwildfire.create.tina.faclrender.FACLFlameWriter)1 MeshGenRenderThread (org.jwildfire.create.tina.meshgen.render.MeshGenRenderThread)1 RenderPointCloudThread (org.jwildfire.create.tina.meshgen.render.RenderPointCloudThread)1 RenderSlicesThread (org.jwildfire.create.tina.meshgen.render.RenderSlicesThread)1 MedianCutQuantizer (org.jwildfire.create.tina.palette.MedianCutQuantizer)1