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
# 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
# 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();