Write swing component to large TIFF image using JAI

前端 未结 2 1834
说谎
说谎 2020-12-21 09:53

I have a large swing component to write to TIFF. The component is too large to load the TIFF in memory, so I either need to make a big BufferedImage which is backed by a dis

2条回答
  •  被撕碎了的回忆
    2020-12-21 10:10

    I had the same situation and I used these steps:

    • Load as BufferedImage with JAI

    • Resize BufferedImage size to preferable size (600x600px) maintaining aspect-ratio using Image#getScaledInstance(int w, int h, Image.SCALE_SMOOTH)

    • Draw image using Graphics2d.drawImage(..) method in JComponent#paintComponent(java.awt.Graphics) method

    That helped me with showing and manipulating TIFF images ~50MB (5000x5000px).

提交回复
热议问题