xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Shyrokov <shyro...@stsci.edu>
Subject Generate my own image
Date Thu, 28 Apr 2011 13:14:04 GMT

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?

I call ParsedURL.registerHandler(new MyProtocolHanlder("myprotocol")); 
and MyProtocolHanlder.parseURL returns MyParsedURLData.

I thought that returning my own stream would work, but it does not. In 
the example bellow I simply load an image from disk and try to display it.

> class MyParsedURLData extends ParsedURLData {
>     public MyParsedURLData() {
>     }
>     @Override
>     public InputStream openStreamRaw(String arg0, Iterator arg1) throws IOException {
>         return new File("some_image_here").toURI().toURL().openStream();
>     }
> }

If in the constructor for MyParsedURLData I set protocol = "file" and 
path="another_image", then another image will be loaded, no matter what 
stream is returned by openStreamRaw.

Any suggestions?

Thank you, Alexander.

To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org

View raw message