I need to save a large image on disk - so large it creates outofmemory errors (like 10000x10000 px). It's suppose to be a tiling and I have the tile stored in memory as a BufferedImage. I read something about TiledImage class being able to work only with part of image, the rest being stored on disk, but I haven't found a simple example of how to do this? Could you please point me to or create a tutorial for dummies on how to store a large image on disk without having it all in memory? Like "create large image straight on disk like this:", "access its part and store data in it like this:" or however it works..

I know this has been asked here a couple of times, but I read through all of that and googled a lot but still haven't found a whole working (or comprehendable) example. Maybe it's the language barrier, or I'm just stupid in this kinda stuff, anyway, help, please :)

有帮助吗?

解决方案

Have you checked out DiskMemImage, from their documentation:

This class serves the same purpose as JAI's standard TiledImage class: namely, a writable image that can accommodate a variety of data types, an optional ColorModel, and data arranged in tiles. However, unlike TiledImage, DiskMemImage uses disk as well as memory storage to allow very large images to be handled in limited memory.

其他提示

You can give a look to PNGJ, I created that library for a similar scenario.

Easy way to solve OutOfMemoryError in java is to increase the maximum heap size by using JVM options

I would just increase your maximum memory, it is much simpler. Try it with -Xmx1g on the command line.

There is no magic to using tiles. You just break up your image into smaller images when you stitch together on the screen so it looks like a large one. e.g. Google maps do this.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top