You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Alexander Shyrokov <sh...@stsci.edu> on 2011/04/27 16:03:10 UTC

Generate my own image

Hello,

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