Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8090651

Make it possible to create Images with a limit on the maximum storage dimensions (subsampling larger images)


    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 7u6
    • Fix Version/s: tbd
    • Component/s: javafx
    • Labels:
    • Environment:



      I just ran into a neat little issue. I have many images stored in a database from external sources. These images vary in size a lot, and are used (in varying sizes) throughout my application. In general, what I want is to decode the provided images in their original resolution so that when they are displayed in my application they can be scaled with the highest quality to fit any scenario (from full screen to thumbnail).

      However, it turns out some of these images are huge (4000x6000 for example, roughly 100 MB heap space), and I would like to impose an upper limit on them (no bigger than the Stage size for example). The problem is, I cannot do this with the Image constructor without also scaling up images that are already nice and small.

      For example, if I construct my images with:

      new Image("http://sample.com/res/flower.png", 1920, 1200, true, true);

      Then small images will get scaled up to 1920x1200, consuming extra space without gaining extra resolution.

      However, there is no way to know in advance whether an image is going to be huge (and would thus benefit from scaling down) or tiny (and thus would waste a ton of memory as it gets scaled up to 1920x1200).

      Workarounds: I donot know of any -- doing a test decode to see how big the image is defeats the purpose of scaling them down while loading them :)




            • Assignee:
              jhendrikx John Hendrikx
            • Votes:
              0 Vote for this issue
              3 Start watching this issue


              • Created: