draw on TiledImage as one unified image, still managing memory using tiles

what I am looking for is **exactly** this

http://www.garayed.com/java/186952-question-about-tiledimage-graphics2d-jai.html

"(...)How do I create an arbitrarily large TiledImage from scratch (lacking a

source image) and draw onto it using the TiledImage's graphics context

( TiledImage.createGraphics() ) without causing an

OutOfMemoryException?

The content of the image would be purely Graphics2D geometry. I don't

need to read in any external images, just to be able to create, and

draw on, very large blank images. I'm assuming that TiledImage is the

most appropriate class for this, but haven't been able to find any

sample implementations.

There must be some way to draw on a TiledImage as one unified image,

while still managing memory using tiles.(...)"

any ideas?

TIA

[869 byte] By [kenjishikidaa] at [2007-11-26 18:41:12]
# 1
Try to look at http://www.awprofessional.com/articles/article.asp?p=23668&seqNum=11&rl=1Best Regards,Alexey
AlexeyUshakova at 2007-7-9 6:15:13 > top of Java-index,Security,Cryptography...
# 2

great article

my conclusion is that it seems java can't provide a huge graphics environment for drawing in a transparent manner, I think.

let's suppose I have a huge tiledImage. 20,000 x 20,000 pixels

now I want to draw a huge circle, radius = 10,000, center is the same square center

just an example, to clarify my doubt

when I request a Graphics2D context to draw this circle, tiledImage will intelligently and transparently request the necessary tiles to draw this circle, or I would have to code manually something to grab these tiles, calculate what to draw in each one and manage the tile cache?

TIA

kenjishikidaa at 2007-7-9 6:15:13 > top of Java-index,Security,Cryptography...
# 3

Looks like you are right. Following code throws OutOfMemoryError in createGraphics() with such large images that you want to work with.

int SZX = 20000;

int SZY = 20000;

DirectColorModel dcm = new DirectColorModel(32,0xFF,0xFF00,0xFF0000);

SampleModel sm = dcm.createCompatibleSampleModel(SZX,SZY);

TiledImage til = new TiledImage(0,0,SZX,SZY,500,500,sm,dcm);

Graphics2D gr = til.createGraphics();

AlexeyUshakova at 2007-7-9 6:15:13 > top of Java-index,Security,Cryptography...
# 4

The problem likely stems from the virtual machine running out of memory. Use -Xms and -Xmx options to the virtual machine at start up to increase memory sufficient to handle the image.

Note: with an image that large - 1.6 GB - you are likely to run into trouble unless you are running in a 64 bit environment.

mamorana at 2007-7-9 6:15:13 > top of Java-index,Security,Cryptography...