javafx.scene.image.Image() constructor hangs (infinite loop?) on some corrupted images
Sample code (image is attached):
import java.io.FileInputStream;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
launch();
}
@Override
public void start(Stage stage) throws Exception {
FileInputStream input_byte_stream = new FileInputStream("corrupted_image.png");
Image image = new Image(input_byte_stream);
HBox pane = new HBox();
ImageView view = new ImageView(image);
pane.getChildren().add(view);
Scene scene = new Scene(pane, 1024, 1024);
stage.setScene(scene);
stage.show();
}
}
Sample code (image is attached):
import java.io.FileInputStream;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
launch();
}
@Override
public void start(Stage stage) throws Exception {
FileInputStream input_byte_stream = new FileInputStream("corrupted_image.png");
Image image = new Image(input_byte_stream);
HBox pane = new HBox();
ImageView view = new ImageView(image);
pane.getChildren().add(view);
Scene scene = new Scene(pane, 1024, 1024);
stage.setScene(scene);
stage.show();
}
}