Generate my own image

Alexander Shyrokov <[email protected]>
Newsgroups gmane.text.xml.batik.user
Message-ID <[email protected]>
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.