Drawing on a large image on disk

Drawing on a large image on disk

Post by Gavi » Sun, 08 Jan 2006 10:58:49

Hi - I'm trying to render some graphics on a very large image. My
understanding of the following code is that it should render the
graphics directly to a new file on disc, so the image size won't be
limited by memory. However, with very large image sizes I still get an
OutOfMemoryError, as if the graphics were being rendered to a
BufferedImage. Here's the code:

// define new file to render graphics to
File myImageFile = new File("my_image_file.bmp");

// create a FileImageOutputStream pointing to myImageFile
FileImageOutputStream fios = new FileImageOutputStream(myImageFile);

//create RenderableGraphics of desired image size
RenderableGraphics rg = new RenderableGraphics(new Rectangle2D.Float(0,
0, width, height));

// draw some graphics
rg.drawLine(10,10,70,100);
...

// render the RenderableGraphics to a File via FileImageOutputStream
ImageIO.write(rg.createDefaultRendering(), "bmp", fios);


Can anyone see what's wrong?

 
 
 

Drawing on a large image on disk

Post by Andrey Kuz » Sun, 08 Jan 2006 11:06:02

> Can anyone see what's wrong?

you should use JAI - PlanarImage
For more info see http://www.yqcomputer.com/

--
Andrey Kuznetsov
http://www.yqcomputer.com/ Unified I/O for Java
http://www.yqcomputer.com/ Java image reader
http://www.yqcomputer.com/ Java GUI components and utilities

 
 
 

Drawing on a large image on disk

Post by Gavi » Sun, 08 Jan 2006 11:57:54

Can you provide a simple example of how you would use PlanarImage in
this case?
 
 
 

Drawing on a large image on disk

Post by Andrey Kuz » Sun, 08 Jan 2006 13:11:36

> Can you provide a simple example of how you would use PlanarImage in
you can find everything at http://www.yqcomputer.com/
Subscribe to mailing list there.

You can also browse old JAI archives:
http://www.yqcomputer.com/

--
Andrey Kuznetsov
http://www.yqcomputer.com/ Unified I/O for Java
http://www.yqcomputer.com/ Java image reader
http://www.yqcomputer.com/ Java GUI components and utilities