showSmImage.java
import javafx.application.Application;
import javafx.geometry.Rectangle2D;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javax.imageio.*;
import javafx.scene.image.WritableImage;
import javafx.scene.image.ImageView;
import javafx.embed.swing.SwingFXUtils;
import java.util.List;
import java.awt.image.*;
import java.io.*;
public class showSmImage extends Application {
@Override public void start(Stage stage) {
// load the image
String file1 = "test2.png";
List<String> args = getParameters().getRaw();
String filename = (args.size()>0)? args.get(0): file1;
BufferedImage img = ImageOp.readImage(filename);
int mag = args.size()>1? Integer.parseInt(args.get(1)): 32;
BufferedImage out = ImageOp.replicate(img,mag);
int wd = out.getWidth();
int ht = out.getHeight();
ImageView iv = getView(out);
Group root = new Group();
root.getChildren().add(iv);
Scene scene = new Scene(root);
scene.setFill(Color.BLACK);
stage.setTitle("Small");
stage.setWidth(wd+20);
stage.setHeight(ht+20);
stage.setScene(scene);
stage.sizeToScene();
stage.show();
}
public ImageView getView(BufferedImage img) {
WritableImage image = SwingFXUtils.toFXImage(img,null);
ImageView view = new ImageView();
view.setImage(image);
return view;
}
public static void main(String[] args) {
Application.launch(args);
}
}
Maintained by John Loomis, updated Sat Mar 10 15:20:41 2018