开发者

Any way to easily show a very large image in a Java Applet (using lesser parts)?

I need the functionality to show large images on a Java Applet without increasing the default heap space. I'm getting the "Out of memory" exception when reading the large image using ImageIO.read() into a BufferedImage (what was expected to happen).

To solve this issue, the first thing that comes to mind is to divide the large image into lesser parts.

My question is:

Does anyone have some tips on which direction to take to implement 开发者_开发百科this functionality (which includes showing the correct part when scrolling the image)? Does Java have anything built-in to support this? Any examples?


You must work with parts. The simplest is to have the server provider smallish tiles you Can request As needed.

If not you must dó it yourself in the applet. Load the image - split it in tiles and have each tile reencode itself to a bytestream e.g as jpeg. Attach the rendered tile as a soft reference so it Will be garbage collected as late as possible. If the rendered tile has been gc'ed then decode the jpeg bytestream.

If you have a LOT then even consider serializong tiles to local storage.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜