Bastian
Bastian

Reputation: 1593

JavaFX: ImageView doesn't display large images

I've an issue with displaying large images in an JavaFX ImageView. The ImageView simply doesn't show anything. It works perfectly fine with small images but not with ones with a size around 4,5mb and above. The images are in TIFF format but have the extension ".jpg" but I can't think of influences in reference to this.

I use following code to display them:

public void nextImage(){
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            Image img = new Image(imgList.getNext().toURI().toString(), true);
            imageView.setFitWidth(300);
            imageView.setPreserveRatio(true);
            imageView.setCache(true);
            imageView.setImage(img);
            if (imgList.atEnd()){
                nextButton.setDisable(true);
            }
        }
    });
}

I've already checked if any errors occuring by using img.isError() and img.getException(). But unfortunately, there are no errors.

Upvotes: 0

Views: 681

Answers (1)

Roland
Roland

Reputation: 18415

JavaFX doesn't automagically support TIFF by renaming the image file to JPG. These are the supported formats:

  • BMP
  • GIF
  • JPEG
  • PNG

Upvotes: 2

Related Questions