xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas.dewe...@kodak.com
Subject Re: Generate my own image
Date Thu, 12 May 2011 10:32:01 GMT
Hi Alexander,

Alexander Shyrokov <shyrokov@stsci.edu> wrote on 04/28/2011 09:14:04 AM:

> I have a method that generates an array of bytes, which can be 
> represented as a two dimensional image. I would like to show this image 
> as a background image in batik. I do not want to save the array to disk 
> (as image) and then load it into batik. Instead I would like to provide 
> the array to the batik. I though that using ParsedURLData can help me, 
> but I can not figure out how to make it work. Any suggestions?

        So ParsedURL could help if your image data was in JPEG or PNG 
format, but I suspect
it isn't since you mention it's 2D.  Assuming your bytes are RGB color 
values for the pixels in the
image I would suggest figuring out how to wrap that data into the 

        Then you could build a o.a.batik.gvt.RasterImageNode that you 
insert into the GVT tree.
You can take a BufferedImage and set it on the RasterImageNode.  You might 
look at the 
o.a.batik.ext.awt.image.codec.jpeg.JPEGRegistryEntry in particular the 

                cr = GraphicsUtil.wrap(image);
                        filt = new RedRable(cr);

        Which wrap a standard buffered Image such that it's suitable to 
set on a RasterImageNode
(it allows it to scale properly).

        Personally I'd probably encode the image as a JPEG or PNG and
set it as a 'data' URL since that would avoid the direct mucking with
the GVT tree (generally problematic).  The other option is if it will
always be the 'background' would be to modify the Canvas to use your
image as the background fill.

View raw message