开发者

How to read image in parts (not ImageIO.read())?

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 开发者_JAVA百科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.


In case you are using PNG format, this library lets you load an image line by line, so you don't need to load it fully in memory http://code.google.com/p/pngj/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜