Skip to content
Snippets Groups Projects
Commit 0aae829f authored by Matej Kovár's avatar Matej Kovár
Browse files

fixed image preview, showing preview images

parent eeaacb1d
No related branches found
No related tags found
No related merge requests found
......@@ -218,7 +218,7 @@ public class Project {
Path path = this.getCfg().getPathToFaceByName(name);
File file = path.toFile();
face = new HumanFace(file, true); // loads also landmarks, if exist
Path preview = path.resolveSibling(name.concat(".jpg"));
Path preview = path.resolveSibling(name.concat("_preview.jpg"));
face.setPreview(preview);
this.addFace(face);
out.printDuration("Loaded model " + face.getShortName() +" with " + face.getMeshModel().getNumVertices() + " vertices");
......
......@@ -9,6 +9,7 @@ import java.awt.image.BufferedImage;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
......@@ -281,7 +282,7 @@ public class FaceStatePanel extends ControlPanel {
} else if (path != null && path.toFile().exists()) {
String pathString = path.toString();
String name = pathString.substring(0, pathString.lastIndexOf('.')); // remove extention
Path preview = path.resolveSibling(name.concat(".jpg"));
Path preview = Paths.get(name.concat("_preview.jpg"));
try {
image = ImageIO.read(preview.toFile());
......@@ -298,8 +299,9 @@ public class FaceStatePanel extends ControlPanel {
return previewBasic;
}
image = scaleAndRotateIfNeeded(image);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
image = Scalr.resize(image, (int)screenSize.getHeight() - 200);
previewFace = new ImageIcon(image);
photo.setToolTipText("Click to enlarge the image");
......@@ -307,24 +309,6 @@ public class FaceStatePanel extends ControlPanel {
}
/**
* Scales photo and rotates if width is bigger than height
* @param image BufferedImage to be scaled or rotated
* @return scaled and rotated image
*/
private BufferedImage scaleAndRotateIfNeeded(BufferedImage image) {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
if (image.getWidth() > image.getHeight()) {
image = Scalr.rotate(image, Scalr.Rotation.CW_270, Scalr.OP_ANTIALIAS);
}
image = Scalr.resize(image, (int)screenSize.getHeight() - 200);
return image;
}
/**
* Gets path text
* @param path Path
......
......@@ -69,12 +69,11 @@ public class ModelsTableModel extends DefaultTableModel {
} else {
try {
BufferedImage image = ImageIO.read(path.toFile());
if (image.getWidth() > image.getHeight()) {
image = Scalr.rotate(image, Scalr.Rotation.CW_270, Scalr.OP_ANTIALIAS);
}
//BufferedImage rotatedImage = Scalr.rotate(image, Scalr.Rotation.CW_90, Scalr.OP_ANTIALIAS);
// Scale image to fit into column
BufferedImage scaledImage = Scalr.resize(image, 70, 55);
addRow(new Object[]{false, name, new ImageIcon(scaledImage)});
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
......
......@@ -521,7 +521,7 @@ public class ProjectPanel extends JPanel {
if (project.addNewPath(path)) {
//Path preview = path.resolveSibling(name.concat("_preview_small.jpg"));
Path preview = path.resolveSibling(name.concat(".jpg"));
Path preview = path.resolveSibling(name.concat("_preview.jpg"));
model.addRowWithName(name, preview);
filterPanel.checkAllFacesLoaded(false);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment