use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.
the class TinaController method selectImageForBackgroundButton_actionPerformed.
public void selectImageForBackgroundButton_actionPerformed(ActionEvent e) {
JFileChooser chooser = new ImageFileChooser(Tools.FILEEXT_PNG);
if (prefs.getInputImagePath() != null) {
try {
if (getCurrFlame().getBGImageFilename().length() > 0) {
chooser.setSelectedFile(new File(getCurrFlame().getBGImageFilename()));
} else {
chooser.setCurrentDirectory(new File(prefs.getInputImagePath()));
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
if (chooser.showOpenDialog(centerPanel) == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
try {
String filename = file.getAbsolutePath();
WFImage img = RessourceManager.getImage(filename);
if (img.getImageWidth() < 2 || img.getImageHeight() < 2 || !(img instanceof SimpleImage)) {
throw new Exception("Invalid background image");
}
prefs.setLastInputImageFile(file);
saveUndoPoint();
getCurrFlame().setBGImageFilename(filename);
refreshFlameImage(true, false, 1, true, true);
} catch (Throwable ex) {
errorHandler.handleError(ex);
}
}
}
use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.
the class MapFilePreview method createThumbnail.
public void createThumbnail() {
if (currFile == null) {
currThumbnail = null;
return;
}
try {
if (currFile.exists()) {
List<RGBPalette> gradients = new MapGradientReader().readPalettes(currFile.getAbsolutePath());
int imgWidth = this.getPreferredSize().width;
int imgHeight = this.getPreferredSize().height - BUTTON_HEIGHT;
SimpleImage img = new RGBPaletteRenderer().renderHorizPalette(gradients.get(0), imgWidth, imgHeight);
currThumbnail = new ImageIcon(img.getBufferedImg());
}
} catch (Exception ex) {
currThumbnail = null;
if (ex.getCause() != null) {
ex.getCause().printStackTrace();
} else {
ex.printStackTrace();
}
}
}
use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.
the class TinaSWFAnimatorController method createRandomBatch.
public boolean createRandomBatch(int pCount, String pGeneratorname) {
if (prefs.getTinaRandomBatchRefreshType() == RandomBatchRefreshType.CLEAR) {
randomBatch.clear();
}
int imgCount = prefs.getTinaRandomMovieBatchSize();
List<SimpleImage> imgList = new ArrayList<SimpleImage>();
int maxCount = (pCount > 0 ? pCount : imgCount);
renderProgressUpdater.initProgress(maxCount);
RandomMovieGenerator randGen = RandomMovieGeneratorList.getRandomMovieGeneratorInstance(pGeneratorname, true);
for (int i = 0; i < maxCount; i++) {
MovieThumbnail thumbnail;
thumbnail = new MovieThumbnail(randGen.createMovie(prefs), null);
SimpleImage img = thumbnail.getPreview(3 * prefs.getTinaRenderPreviewQuality() / 4);
if (prefs.getTinaRandomBatchRefreshType() == RandomBatchRefreshType.INSERT) {
randomBatch.add(0, thumbnail);
imgList.add(0, img);
} else {
randomBatch.add(thumbnail);
imgList.add(img);
}
renderProgressUpdater.updateProgress(i + 1);
}
updateThumbnails();
return true;
}
use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.
the class TinaSWFAnimatorController method refreshFlameImage.
public void refreshFlameImage(boolean pQuickRender) {
if (!noRefresh) {
FlamePanel imgPanel = getFlamePanel();
Rectangle bounds = imgPanel.getImageBounds();
int width = bounds.width;
int height = bounds.height;
if (width >= 16 && height >= 16) {
RenderInfo info = new RenderInfo(width, height, RenderMode.PREVIEW);
Flame flame = getCurrFlame();
if (flame != null) {
double oldSpatialFilterRadius = flame.getSpatialFilterRadius();
double oldSampleDensity = flame.getSampleDensity();
try {
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());
FlameRenderer renderer = new FlameRenderer(flame, prefs, false, false);
if (pQuickRender) {
renderer.setProgressUpdater(null);
flame.setSampleDensity(1.0);
flame.setSpatialFilterRadius(0.0);
} else {
renderer.setProgressUpdater(renderProgressUpdater);
flame.setSampleDensity(prefs.getTinaRenderPreviewQuality());
}
RenderedFlame res = renderer.renderFlame(info);
imgPanel.setImage(res.getImage());
} finally {
flame.setSpatialFilterRadius(oldSpatialFilterRadius);
flame.setSampleDensity(oldSampleDensity);
}
}
} else {
imgPanel.setImage(new SimpleImage(width, height));
}
swfAnimatorPreviewRootPanel.repaint();
}
}
use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.
the class FlamePanel method fillBackground.
private void fillBackground(Graphics g) {
Rectangle bounds = this.getBounds();
if (withShowTransparency) {
SimpleImage bgImg = getTransparencyImg(bounds.width, bounds.height);
g.drawImage(bgImg.getBufferedImg(), 0, 0, bounds.width, bounds.height, this);
} else {
g.setColor(BACKGROUND_COLOR);
g.fillRect(0, 0, bounds.width, bounds.height);
}
}
Aggregations