Java supports reading of whole images with ImageIO.read(), but is there a way of reading an image only partially?
Background:
I’m working on a map application that reads large images, splits them up, then uses the generated tiles as the background of a map. In some cases the provided image can be so large that reading the Image as a BufferedImage might already cause an OutOfMemoryError.
I’m aware I could grant the VM more heap space, still I’d prefer a way to further reduce the risk by reading the image only in parts, i. e. in tiles of 256*256 pixels, that I could save straight away to the file system.
It’s a long time since I’ve used it but you can do it with JAI (Java Advanced Imaging) using a TiledImage.
JAI homepage.