support for ImageReader.addIIOReadWarningListener()

View: New views
4 Messages — Rating Filter:   Alert me  

support for ImageReader.addIIOReadWarningListener()

by Philippe Cadé :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I hope this is the right place for this, if not please advise.

Here some context information: using xmlgraphics 1.3.1 via FOP to transform XML to PDF, my XSLT uses external-graphics that reference CGM files. CGM files are read using an ImageIO plugin.

We are currently not supporting all CGM commands and are generating warning messages while parsing the image, I'd like to have access to those messages. Now the ImageReader class provides the possibility to add a IIOReadWarningListener that would be perfect for this.

Question is now: what is the best way to add support for this? I am thinking that adding a addIIOReadWarningListener() method to ImageManager would work, FOP could then have this listener log the messages to the existing log file (cf. ExternalGraphics.bind()). Or would it be better to encapsulate the IIOReadWarningListener into another interface? Or use another access point than ImageManager?

What do you guys think?

Thanks for your help
Philippe

Re: support for ImageReader.addIIOReadWarningListener()

by Jeremias Maerki-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Philippe

On 09.04.2009 15:14:41 Cadé Philippe wrote:
> Hi all,
>
> I hope this is the right place for this, if not please advise.

Totally the right place. :-)

> Here some context information: using xmlgraphics 1.3.1 via FOP to
> transform XML to PDF, my XSLT uses external-graphics that reference CGM
> files. CGM files are read using an ImageIO plugin.

Interesting. CGM is a vector graphic format, right? So if you're using
an ImageIO plugin, that means the CGM images get converted to bitmaps.
If you can send the vector graphics against a Graphics2D interface, you
could write an image loader plug-in and transform the images to vector
graphics in PDF output. That's what we do with SVG or MathML, for
example. Just an thought.

> We are currently not supporting all CGM commands and are generating
> warning messages while parsing the image, I'd like to have access to
> those messages. Now the ImageReader class provides the possibility to
> add a IIOReadWarningListener that would be perfect for this.
>
> Question is now: what is the best way to add support for this? I am
> thinking that adding a addIIOReadWarningListener() method to
> ImageManager would work, FOP could then have this listener log the
> messages to the existing log file (cf. ExternalGraphics.bind()). Or
> would it be better to encapsulate the IIOReadWarningListener into
> another interface? Or use another access point than ImageManager?
>
> What do you guys think?

Hmm, I wouldn't like to see a hard dependency on the listener interface in
any of the API classes of the image loading framework. Ok, I've reused
ImageIO's ImageInputStream in the image loading framework but adding
something to the API classes that is specific to a single plug-in
doesn't feel right. Just for my understanding: is your goal to simply redirect
the warnings from the interface to the logger or do you actually want to
provide your own IIOReadWarningListener from your client code? In the
first case, I'd suggest just extending the ImageIO plugin for the image
loading framework (ImageLoaderImageIO and PreloaderImageIO). That's
easily done in a few lines of code. The second case is more complicated
and invasive. For the image loader, the "hints" parameter of the
ImageLoader's loadImage() method might help here. However, there's no
equivalent for the Preloader stage, yet.

> Thanks for your help
> Philippe




Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@...
For additional commands, e-mail: general-help@...


Re: support for ImageReader.addIIOReadWarningListener()

by Philippe Cadé :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Jeremias,

Jeremias Maerki-2 wrote:
> Here some context information: using xmlgraphics 1.3.1 via FOP to
> transform XML to PDF, my XSLT uses external-graphics that reference CGM
> files. CGM files are read using an ImageIO plugin.

Interesting. CGM is a vector graphic format, right? So if you're using
an ImageIO plugin, that means the CGM images get converted to bitmaps.
If you can send the vector graphics against a Graphics2D interface, you
could write an image loader plug-in and transform the images to vector
graphics in PDF output. That's what we do with SVG or MathML, for
example. Just an thought.
Yes, CGM is vector graphics. I went the ImageIO route at first since we wanted to display CGM graphics in a Swing component also. I hadn't looked into it too closely about handling CGM like SVG but I just implemented a loader plug-in as you suggested and it works well and the PDF output looks much better.

Jeremias Maerki-2 wrote:
Just for my understanding: is your goal to simply redirect
the warnings from the interface to the logger or do you actually want to
provide your own IIOReadWarningListener from your client code? In the
first case, I'd suggest just extending the ImageIO plugin for the image
loading framework (ImageLoaderImageIO and PreloaderImageIO).
Since I am now using an image loader plug-in, I can now easily redirect the warnings happening during the CGM processing to a logger within the plug-in.

Philippe

Re: support for ImageReader.addIIOReadWarningListener()

by Philippe Cadé :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Jeremias,

Jeremias Maerki-2 wrote:
> Here some context information: using xmlgraphics 1.3.1 via FOP to
> transform XML to PDF, my XSLT uses external-graphics that reference CGM
> files. CGM files are read using an ImageIO plugin.

Interesting. CGM is a vector graphic format, right? So if you're using
an ImageIO plugin, that means the CGM images get converted to bitmaps.
If you can send the vector graphics against a Graphics2D interface, you
could write an image loader plug-in and transform the images to vector
graphics in PDF output. That's what we do with SVG or MathML, for
example. Just an thought.
Yes, CGM is vector graphics. I went the ImageIO route at first since we wanted to display CGM graphics in a Swing component also. I hadn't looked into it too closely about handling CGM like SVG but I just implemented a loader plug-in as you suggested (much much easier than I thought) and it works well and the PDF output looks much better.

Jeremias Maerki-2 wrote:
Just for my understanding: is your goal to simply redirect
the warnings from the interface to the logger or do you actually want to
provide your own IIOReadWarningListener from your client code? In the
first case, I'd suggest just extending the ImageIO plugin for the image
loading framework (ImageLoaderImageIO and PreloaderImageIO).
Since I am now using an image loader plug-in, I can now easily redirect the warnings happening during the CGM processing to a logger within the plug-in, no need to alter the ImageIO plug-in.

Philippe