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;
}
}
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);
}
}
}
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);
}
}
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();
}
Aggregations