You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Harshini Madurapperuma <ha...@ifs.lk> on 2008/02/11 12:03:26 UTC

Converting BufferredImage into FopImage?

Hi All


Does anybody know how to convert a BufferredImage into a FopImage?
BufferredImage bi = " XXX ";
FopImage img = (FopImage)bi;

When doing this I'm getting a ClassCastException.

Regards
Harshini.
------------------------------------------------------------------------------

CONFIDENTIALITY AND DISCLAIMER NOTICE

This e-mail, including any attachments, is confidential and intended only for
the addressee. If you are not the intended recipient, please notify us
immediately and delete this e-mail from your system. Any use or disclosure of
the information contained herein is strictly prohibited.


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


16-bit Bitmap support in BmpImage.java class ?

Posted by Harshini Madurapperuma <ha...@ifs.lk>.
Hi

I have the fop version 0.20.5 and a bit difficult to go for higher version for the moment, and I have to work with bitmap images. BmpImage.java doesn't support for 16-bit images. It throws the exception

"[ERROR] Error in XObject : Image (file:./graphics/SESSION/logbw_16.bmp) has 16 which is not a supported BMP format..."

Will I be able to get the code for 16-bit support?

Many thanks in Advance
Harshini.



-----Original Message-----
From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch]
Sent: Thursday, April 03, 2008 12:55 PM
To: fop-users@xmlgraphics.apache.org
Subject: Re: Bitmap support in BmpImage.java class ?

You obviously missed the announcement of 0.95beta. Please try it out.

On 03.04.2008 07:56:23 Harshini Madurapperuma wrote:
> Hi Jeremias,
>
> I was working with Bitmap processing and the FOP version 0.94 doesn't
> support 16 bit bitmaps. Then You said the newer version FOP Trunk (
> 0.95) will definetly work for 16 bits and it'll be available by the
> end of February/March this year.
>
> Is it available now? If so can I get code for 16 bit support?
>
> Thanx in advance
> Regard
> Harshini
>
>
>
> -----Original Message-----
> From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch]
> Sent: Wednesday, February 13, 2008 3:08 PM
> To: fop-users@xmlgraphics.apache.org
> Subject: Re: Bitmap support in BmpImage.java class ?
>
> I know 16 bit works with FOP Trunk (and 0.95 when it is available). I don't know about 32 bit because I don't have a bitmap editor that can save 32-bit BMP images. If you can send me such a 32bit BMP I'll gladly test it with FOP Trunk.
>
> 0.94 still has the old image loading package. However, it could be that it supports 16 bit images. I haven't checked but if it does you may be able to get an idea how to decode 16bit images directly. FOP Trunk contains a completely new image loading framework which mostly uses ImageIO to load images so I don't really care about the individual formats anymore but delegate that to the codecs. This is similar to using JAI. But trust me, you don't want to backport the new image loading framework back into 0.20.5. That's far more work than hacking JAI into 0.20.5 to load all sorts of BMP images.
>
> So why don't you go with the JAI suggestion? I have no easier solution for you.
>
> On 13.02.2008 10:04:57 Harshini Madurapperuma wrote:
> > Hi Jeremias,
> >
> > Thanks for your valid suggestions. Does 0.95 supports for 16 and 32
> > bit images? What about the previous versions before 0.95? If you
> > have a higher version can I get the algorithm or the code?
> >
> > Thanks
> > Harshini.
> >
> > -----Original Message-----
> > From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch]
> > Sent: Wednesday, February 13, 2008 12:36 PM
> > To: fop-users@xmlgraphics.apache.org
> > Subject: Re: Bitmap support in BmpImage.java class ?
> >
> > Sure, you can. Either you replace BmpImage with the JAI implementation as discussed earlier or you change BmpImage. In the latter case, you have to convert the 16 and 32 bit image data to 24 bit RGB. Otherwise, the renderers will not process the image data correctly (FOP Trunk is much more flexible here). For this you need to know a few things about the BMP format. Start here to get more information:
> > http://en.wikipedia.org/wiki/BMP_file_format
> >
> > I think it's probably easiest if you use ImageIO or JAI to load BMP
> > images and convert them to the required 24bit pixel stream using the
> > BufferedImage.getRGB() method as done in JAIImage. But if I were you I'd try to upgrade FOP at least as soon as 0.95 is available next month.
> >
> > On 13.02.2008 05:11:01 Harshini Madurapperuma wrote:
> > >  Hi all;
> > >
> > > I have the fop version 0.20.5, and I have to work with bitmap images.
> > > In BmpImage.java class the code supports only for 1,4,8 and 24 bit
> > > sizes, otherwise it throws an exception. Can't I modify this to
> > > support for 16 and 32 bits also with out changing the fop version.
> > > Your suggestions would be greatly appreciated.
> > >
> > > if (this.m_bitsPerPixel == 1)
> > >             bytes = (this.m_width + 7) / 8;
> > >         else if (this.m_bitsPerPixel == 24)
> > >             bytes = this.m_width * 3;
> > >         else if (this.m_bitsPerPixel == 4 || this.m_bitsPerPixel == 8)
> > >             bytes = this.m_width / (8 / this.m_bitsPerPixel);
> > >         else
> > >             throw new FopImageException("Image (" + this.m_href.toString()
> > >                                         + ") has " + this.m_bitsPerPixel
> > >                                         + " which is not a
> > > supported BMP format...");
> > >
> > > Regards,
> > > Harshini.
> >
> >
> >
> > Jeremias Maerki
> >
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail:
> > fop-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail:
> > fop-users-help@xmlgraphics.apache.org
> >
> > --------------------------------------------------------------------
> > --
> > --------
> >
> > CONFIDENTIALITY AND DISCLAIMER NOTICE
> >
> > This e-mail, including any attachments, is confidential and intended
> > only for the addressee. If you are not the intended recipient,
> > please notify us immediately and delete this e-mail from your
> > system. Any use or disclosure of the information contained herein is strictly prohibited.
> >
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail:
> > fop-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail:
> > fop-users-help@xmlgraphics.apache.org
> >
>
>
>
>
> Jeremias Maerki
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>
> ----------------------------------------------------------------------
> --------
>
> CONFIDENTIALITY AND DISCLAIMER NOTICE
>
> This e-mail, including any attachments, is confidential and intended
> only for the addressee. If you are not the intended recipient, please
> notify us immediately and delete this e-mail from your system. Any use
> or disclosure of the information contained herein is strictly prohibited.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>




Jeremias Maerki


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

------------------------------------------------------------------------------

CONFIDENTIALITY AND DISCLAIMER NOTICE

This e-mail, including any attachments, is confidential and intended only for
the addressee. If you are not the intended recipient, please notify us
immediately and delete this e-mail from your system. Any use or disclosure of
the information contained herein is strictly prohibited.


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


Re: Bitmap support in BmpImage.java class ?

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
You obviously missed the announcement of 0.95beta. Please try it out.

On 03.04.2008 07:56:23 Harshini Madurapperuma wrote:
> Hi Jeremias,
> 
> I was working with Bitmap processing and the FOP version 0.94 doesn't
> support 16 bit bitmaps. Then You said the newer version FOP Trunk (
> 0.95) will definetly work for 16 bits and it'll be available by the end of
> February/March this year.
> 
> Is it available now? If so can I get code for 16 bit support?
> 
> Thanx in advance
> Regard
> Harshini
> 
> 
> 
> -----Original Message-----
> From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch]
> Sent: Wednesday, February 13, 2008 3:08 PM
> To: fop-users@xmlgraphics.apache.org
> Subject: Re: Bitmap support in BmpImage.java class ?
> 
> I know 16 bit works with FOP Trunk (and 0.95 when it is available). I don't know about 32 bit because I don't have a bitmap editor that can save 32-bit BMP images. If you can send me such a 32bit BMP I'll gladly test it with FOP Trunk.
> 
> 0.94 still has the old image loading package. However, it could be that it supports 16 bit images. I haven't checked but if it does you may be able to get an idea how to decode 16bit images directly. FOP Trunk contains a completely new image loading framework which mostly uses ImageIO to load images so I don't really care about the individual formats anymore but delegate that to the codecs. This is similar to using JAI. But trust me, you don't want to backport the new image loading framework back into 0.20.5. That's far more work than hacking JAI into 0.20.5 to load all sorts of BMP images.
> 
> So why don't you go with the JAI suggestion? I have no easier solution for you.
> 
> On 13.02.2008 10:04:57 Harshini Madurapperuma wrote:
> > Hi Jeremias,
> >
> > Thanks for your valid suggestions. Does 0.95 supports for 16 and 32
> > bit images? What about the previous versions before 0.95? If you have
> > a higher version can I get the algorithm or the code?
> >
> > Thanks
> > Harshini.
> >
> > -----Original Message-----
> > From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch]
> > Sent: Wednesday, February 13, 2008 12:36 PM
> > To: fop-users@xmlgraphics.apache.org
> > Subject: Re: Bitmap support in BmpImage.java class ?
> >
> > Sure, you can. Either you replace BmpImage with the JAI implementation as discussed earlier or you change BmpImage. In the latter case, you have to convert the 16 and 32 bit image data to 24 bit RGB. Otherwise, the renderers will not process the image data correctly (FOP Trunk is much more flexible here). For this you need to know a few things about the BMP format. Start here to get more information:
> > http://en.wikipedia.org/wiki/BMP_file_format
> >
> > I think it's probably easiest if you use ImageIO or JAI to load BMP
> > images and convert them to the required 24bit pixel stream using the
> > BufferedImage.getRGB() method as done in JAIImage. But if I were you I'd try to upgrade FOP at least as soon as 0.95 is available next month.
> >
> > On 13.02.2008 05:11:01 Harshini Madurapperuma wrote:
> > >  Hi all;
> > >
> > > I have the fop version 0.20.5, and I have to work with bitmap images.
> > > In BmpImage.java class the code supports only for 1,4,8 and 24 bit
> > > sizes, otherwise it throws an exception. Can't I modify this to
> > > support for 16 and 32 bits also with out changing the fop version.
> > > Your suggestions would be greatly appreciated.
> > >
> > > if (this.m_bitsPerPixel == 1)
> > >             bytes = (this.m_width + 7) / 8;
> > >         else if (this.m_bitsPerPixel == 24)
> > >             bytes = this.m_width * 3;
> > >         else if (this.m_bitsPerPixel == 4 || this.m_bitsPerPixel == 8)
> > >             bytes = this.m_width / (8 / this.m_bitsPerPixel);
> > >         else
> > >             throw new FopImageException("Image (" + this.m_href.toString()
> > >                                         + ") has " + this.m_bitsPerPixel
> > >                                         + " which is not a supported
> > > BMP format...");
> > >
> > > Regards,
> > > Harshini.
> >
> >
> >
> > Jeremias Maerki
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> >
> > ----------------------------------------------------------------------
> > --------
> >
> > CONFIDENTIALITY AND DISCLAIMER NOTICE
> >
> > This e-mail, including any attachments, is confidential and intended
> > only for the addressee. If you are not the intended recipient, please
> > notify us immediately and delete this e-mail from your system. Any use
> > or disclosure of the information contained herein is strictly prohibited.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> >
> 
> 
> 
> 
> Jeremias Maerki
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> ------------------------------------------------------------------------------
> 
> CONFIDENTIALITY AND DISCLAIMER NOTICE
> 
> This e-mail, including any attachments, is confidential and intended only for
> the addressee. If you are not the intended recipient, please notify us
> immediately and delete this e-mail from your system. Any use or disclosure of
> the information contained herein is strictly prohibited.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 




Jeremias Maerki


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


RE: Bitmap support in BmpImage.java class ?

Posted by Harshini Madurapperuma <ha...@ifs.lk>.
Hi Jeremias,

I was working with Bitmap processing and the FOP version 0.94 doesn't support 16 bit bitmaps. Then You said the newer version FOP Trunk ( 0.95) will definetly work for 16 bits and it'll be available by the end of February/March this year.

Is it available now? If so can I get code for 16 bit support?

Thanx in advance
Regard
Harshini



-----Original Message-----
From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch]
Sent: Wednesday, February 13, 2008 3:08 PM
To: fop-users@xmlgraphics.apache.org
Subject: Re: Bitmap support in BmpImage.java class ?

I know 16 bit works with FOP Trunk (and 0.95 when it is available). I don't know about 32 bit because I don't have a bitmap editor that can save 32-bit BMP images. If you can send me such a 32bit BMP I'll gladly test it with FOP Trunk.

0.94 still has the old image loading package. However, it could be that it supports 16 bit images. I haven't checked but if it does you may be able to get an idea how to decode 16bit images directly. FOP Trunk contains a completely new image loading framework which mostly uses ImageIO to load images so I don't really care about the individual formats anymore but delegate that to the codecs. This is similar to using JAI. But trust me, you don't want to backport the new image loading framework back into 0.20.5. That's far more work than hacking JAI into 0.20.5 to load all sorts of BMP images.

So why don't you go with the JAI suggestion? I have no easier solution for you.

On 13.02.2008 10:04:57 Harshini Madurapperuma wrote:
> Hi Jeremias,
>
> Thanks for your valid suggestions. Does 0.95 supports for 16 and 32
> bit images? What about the previous versions before 0.95? If you have
> a higher version can I get the algorithm or the code?
>
> Thanks
> Harshini.
>
> -----Original Message-----
> From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch]
> Sent: Wednesday, February 13, 2008 12:36 PM
> To: fop-users@xmlgraphics.apache.org
> Subject: Re: Bitmap support in BmpImage.java class ?
>
> Sure, you can. Either you replace BmpImage with the JAI implementation as discussed earlier or you change BmpImage. In the latter case, you have to convert the 16 and 32 bit image data to 24 bit RGB. Otherwise, the renderers will not process the image data correctly (FOP Trunk is much more flexible here). For this you need to know a few things about the BMP format. Start here to get more information:
> http://en.wikipedia.org/wiki/BMP_file_format
>
> I think it's probably easiest if you use ImageIO or JAI to load BMP
> images and convert them to the required 24bit pixel stream using the
> BufferedImage.getRGB() method as done in JAIImage. But if I were you I'd try to upgrade FOP at least as soon as 0.95 is available next month.
>
> On 13.02.2008 05:11:01 Harshini Madurapperuma wrote:
> >  Hi all;
> >
> > I have the fop version 0.20.5, and I have to work with bitmap images.
> > In BmpImage.java class the code supports only for 1,4,8 and 24 bit
> > sizes, otherwise it throws an exception. Can't I modify this to
> > support for 16 and 32 bits also with out changing the fop version.
> > Your suggestions would be greatly appreciated.
> >
> > if (this.m_bitsPerPixel == 1)
> >             bytes = (this.m_width + 7) / 8;
> >         else if (this.m_bitsPerPixel == 24)
> >             bytes = this.m_width * 3;
> >         else if (this.m_bitsPerPixel == 4 || this.m_bitsPerPixel == 8)
> >             bytes = this.m_width / (8 / this.m_bitsPerPixel);
> >         else
> >             throw new FopImageException("Image (" + this.m_href.toString()
> >                                         + ") has " + this.m_bitsPerPixel
> >                                         + " which is not a supported
> > BMP format...");
> >
> > Regards,
> > Harshini.
>
>
>
> Jeremias Maerki
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>
> ----------------------------------------------------------------------
> --------
>
> CONFIDENTIALITY AND DISCLAIMER NOTICE
>
> This e-mail, including any attachments, is confidential and intended
> only for the addressee. If you are not the intended recipient, please
> notify us immediately and delete this e-mail from your system. Any use
> or disclosure of the information contained herein is strictly prohibited.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>




Jeremias Maerki


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

------------------------------------------------------------------------------

CONFIDENTIALITY AND DISCLAIMER NOTICE

This e-mail, including any attachments, is confidential and intended only for
the addressee. If you are not the intended recipient, please notify us
immediately and delete this e-mail from your system. Any use or disclosure of
the information contained herein is strictly prohibited.


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


Re: Bitmap support in BmpImage.java class ?

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
I know 16 bit works with FOP Trunk (and 0.95 when it is available). I
don't know about 32 bit because I don't have a bitmap editor that can
save 32-bit BMP images. If you can send me such a 32bit BMP I'll gladly
test it with FOP Trunk.

0.94 still has the old image loading package. However, it could be that
it supports 16 bit images. I haven't checked but if it does you may be
able to get an idea how to decode 16bit images directly. FOP Trunk
contains a completely new image loading framework which mostly uses
ImageIO to load images so I don't really care about the individual
formats anymore but delegate that to the codecs. This is similar to
using JAI. But trust me, you don't want to backport the new image
loading framework back into 0.20.5. That's far more work than hacking
JAI into 0.20.5 to load all sorts of BMP images.

So why don't you go with the JAI suggestion? I have no easier solution
for you.

On 13.02.2008 10:04:57 Harshini Madurapperuma wrote:
> Hi Jeremias,
> 
> Thanks for your valid suggestions. Does 0.95 supports for 16 and 32 bit
> images? What about the previous versions before 0.95? If you have a
> higher version can I get the algorithm or the code?
> 
> Thanks
> Harshini.
> 
> -----Original Message-----
> From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch]
> Sent: Wednesday, February 13, 2008 12:36 PM
> To: fop-users@xmlgraphics.apache.org
> Subject: Re: Bitmap support in BmpImage.java class ?
> 
> Sure, you can. Either you replace BmpImage with the JAI implementation as discussed earlier or you change BmpImage. In the latter case, you have to convert the 16 and 32 bit image data to 24 bit RGB. Otherwise, the renderers will not process the image data correctly (FOP Trunk is much more flexible here). For this you need to know a few things about the BMP format. Start here to get more information:
> http://en.wikipedia.org/wiki/BMP_file_format
> 
> I think it's probably easiest if you use ImageIO or JAI to load BMP images and convert them to the required 24bit pixel stream using the
> BufferedImage.getRGB() method as done in JAIImage. But if I were you I'd try to upgrade FOP at least as soon as 0.95 is available next month.
> 
> On 13.02.2008 05:11:01 Harshini Madurapperuma wrote:
> >  Hi all;
> >
> > I have the fop version 0.20.5, and I have to work with bitmap images.
> > In BmpImage.java class the code supports only for 1,4,8 and 24 bit
> > sizes, otherwise it throws an exception. Can't I modify this to
> > support for 16 and 32 bits also with out changing the fop version.
> > Your suggestions would be greatly appreciated.
> >
> > if (this.m_bitsPerPixel == 1)
> >             bytes = (this.m_width + 7) / 8;
> >         else if (this.m_bitsPerPixel == 24)
> >             bytes = this.m_width * 3;
> >         else if (this.m_bitsPerPixel == 4 || this.m_bitsPerPixel == 8)
> >             bytes = this.m_width / (8 / this.m_bitsPerPixel);
> >         else
> >             throw new FopImageException("Image (" + this.m_href.toString()
> >                                         + ") has " + this.m_bitsPerPixel
> >                                         + " which is not a supported
> > BMP format...");
> >
> > Regards,
> > Harshini.
> 
> 
> 
> Jeremias Maerki
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> ------------------------------------------------------------------------------
> 
> CONFIDENTIALITY AND DISCLAIMER NOTICE
> 
> This e-mail, including any attachments, is confidential and intended only for
> the addressee. If you are not the intended recipient, please notify us
> immediately and delete this e-mail from your system. Any use or disclosure of
> the information contained herein is strictly prohibited.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 




Jeremias Maerki


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


Re: Question on FOP extension automatic detection

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
On 13.02.2008 18:25:29 Andrejus Chaliapinas wrote:
> Jeremias,
> 
> > The example may indeed be a little restricted for your case. But still,
> > you can provide your own URIResolver and do whatever you want inside it.
> > The clue here is that you get a central place for the whole FOP that lets
> > you convert URIs to InputStreams. And how you set up these InputStreams
> > is entirely up to you. FOP doesn't care. At any rate, you don't pass any
> > objects to the FOUserAgent but to your own, custom-built URIResolver
> > which is set on the FopFactory.
> >
> 
> Could I add then custom URIResolver(s) to be activated/used only for
> particular prefixes?

You can only set one URIResolver. However, if you have multiple you can
write a URIResolver that uses the Composite pattern.

> Or should I implement resolve() method for each such
> different prefix and call some default URIResolver class in case of not
> special one is specified.

If you don't use the Composite pattern and only implement one
URIResolver you can listen to any number of prefixes you want.

> Is there any other dev doc on that? I've checked
> your recent SVG TestCase, but not sure if resolve() code should return null
> in default case.

No, URIResolver is an interface from JAXP. We just reuse the concept for
FOP. I'm sure you'll find examples on the net but it's really not that
difficult. Returning null shouldn't be a problem.

Just to give you the pattern:

public class MyURIResolver implements URIResolver {
    public Source resolve(String href, String base) throws TransformerException {
        if (href.startsWith("mystuff:")) {
            InputStream in = <whatever>
            return new StreamSource(in, href);
        } else {
            return null;
        }
    }
}


Jeremias Maerki


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


RE: Question on FOP extension automatic detection

Posted by Andrejus Chaliapinas <a....@infosana.com>.
Jeremias,

> The example may indeed be a little restricted for your case. But still,
> you can provide your own URIResolver and do whatever you want inside it.
> The clue here is that you get a central place for the whole FOP that lets
> you convert URIs to InputStreams. And how you set up these InputStreams
> is entirely up to you. FOP doesn't care. At any rate, you don't pass any
> objects to the FOUserAgent but to your own, custom-built URIResolver
> which is set on the FopFactory.
>

Could I add then custom URIResolver(s) to be activated/used only for
particular prefixes? Or should I implement resolve() method for each such
different prefix and call some default URIResolver class in case of not
special one is specified. Is there any other dev doc on that? I've checked
your recent SVG TestCase, but not sure if resolve() code should return null
in default case.

Thank you,
Andrejus


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


Re: Question on FOP extension automatic detection

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
On 13.02.2008 17:11:44 Andrejus Chaliapinas wrote:
> Hi Jeremias,
> 
> Thanks a lot for your prompt response. Let me clarify some issues.
> 
> > Have you seen this page?
> > http://xmlgraphics.apache.org/fop/dev/extensions.html
> > 
> > It contains the missing piece to auto-register your extension
> > (/META-INF/services/org.apache.fop.fo.ElementMapping).
> >
> 
> Yes, that was exactly that missing piece of information!
> 
> > You should go through the FOUserAgent (getUserAgent().resolveURI() on
> > your extension element) to resolve a URI and obtain an InputStream. If
> > you do that you can use the following information on the Wiki to
> > use authentication when opening network streams:
> > http://wiki.apache.org/xmlgraphics-fop/HowTo/BasicHttpAuthentication
> >
> 
> Well, I'm looking at general authentication procedure, not just basic http
> authentication. That means that in some cases Java program, which starts
> whole transformation process, resides on client machine and have opened let
> say database connection and thus keeps that connection related session
> information in some object. But I don't see that I could pass an arbitrary
> object/parameter to FOUserAgent and then reuse that when I need from inside
> extension.

The example may indeed be a little restricted for your case. But still,
you can provide your own URIResolver and do whatever you want inside it.
The clue here is that you get a central place for the whole FOP that lets
you convert URIs to InputStreams. And how you set up these InputStreams
is entirely up to you. FOP doesn't care. At any rate, you don't pass any
objects to the FOUserAgent but to your own, custom-built URIResolver
which is set on the FopFactory.

> > May I ask what kind of extension you are developing? Just curious.
> >
> 
> It's PDF file embedding feature I was looking into last year (you may remind
> my several question on where to start), but had no time to do. Though
> currently it's very close to initial completion after various experiments
> with other tools, which already do that.

Ah, I forgot.

> Andrejus



Jeremias Maerki


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


RE: Question on FOP extension automatic detection

Posted by Andrejus Chaliapinas <a....@infosana.com>.
Hi Jeremias,

Thanks a lot for your prompt response. Let me clarify some issues.

> Have you seen this page?
> http://xmlgraphics.apache.org/fop/dev/extensions.html
> 
> It contains the missing piece to auto-register your extension
> (/META-INF/services/org.apache.fop.fo.ElementMapping).
>

Yes, that was exactly that missing piece of information!

> You should go through the FOUserAgent (getUserAgent().resolveURI() on
> your extension element) to resolve a URI and obtain an InputStream. If
> you do that you can use the following information on the Wiki to
> use authentication when opening network streams:
> http://wiki.apache.org/xmlgraphics-fop/HowTo/BasicHttpAuthentication
>

Well, I'm looking at general authentication procedure, not just basic http
authentication. That means that in some cases Java program, which starts
whole transformation process, resides on client machine and have opened let
say database connection and thus keeps that connection related session
information in some object. But I don't see that I could pass an arbitrary
object/parameter to FOUserAgent and then reuse that when I need from inside
extension.

> May I ask what kind of extension you are developing? Just curious.
>

It's PDF file embedding feature I was looking into last year (you may remind
my several question on where to start), but had no time to do. Though
currently it's very close to initial completion after various experiments
with other tools, which already do that.

Andrejus


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


Re: Question on FOP extension automatic detection

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
On 13.02.2008 14:18:25 Andrejus Chaliapinas wrote:
> Hi All,
> 
> I'm trying to develop my own FOP extension, but while running my
> transformation I always get that "Unknown formatting object" warning from
> ElementMappingRegistry class.
> 
> When I do manual mapping registration via fopFactory.addElementMapping(new
> MyElementMapping()) before transformation start - everything works correctly
> later.
> 
> Should I stay with such fopFactory manual registration or did I miss
> anything in those my custom files to implement/extend?

Have you seen this page? http://xmlgraphics.apache.org/fop/dev/extensions.html

It contains the missing piece to auto-register your extension
(/META-INF/services/org.apache.fop.fo.ElementMapping).

> And another question related to FOP extensions - suppose from inside my
> extension I'd like to open an InputStream. But that stream opening procedure
> requires me some additional information to pass (let say name, password,
> etc.). Is it possible somehow to pass from my Java program some sort of
> external Session/Context object to my extension by some mean? Or the only
> way is to extend some default Renderer with additional member variable and
> then analyze that variable inside extension logic?

You should go through the FOUserAgent (getUserAgent().resolveURI() on
your extension element) to resolve a URI and obtain an InputStream. If
you do that you can use the following information on the Wiki to
use authentication when opening network streams:
http://wiki.apache.org/xmlgraphics-fop/HowTo/BasicHttpAuthentication

> Questions here are related to FOP Trunk version.
> 
> Thank you,
> Andrejus

May I ask what kind of extension you are developing? Just curious.

HTH

Jeremias Maerki


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


Question on FOP extension automatic detection

Posted by Andrejus Chaliapinas <a....@infosana.com>.
Hi All,

I'm trying to develop my own FOP extension, but while running my
transformation I always get that "Unknown formatting object" warning from
ElementMappingRegistry class.

When I do manual mapping registration via fopFactory.addElementMapping(new
MyElementMapping()) before transformation start - everything works correctly
later.

Should I stay with such fopFactory manual registration or did I miss
anything in those my custom files to implement/extend?

And another question related to FOP extensions - suppose from inside my
extension I'd like to open an InputStream. But that stream opening procedure
requires me some additional information to pass (let say name, password,
etc.). Is it possible somehow to pass from my Java program some sort of
external Session/Context object to my extension by some mean? Or the only
way is to extend some default Renderer with additional member variable and
then analyze that variable inside extension logic?

Questions here are related to FOP Trunk version.

Thank you,
Andrejus


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


RE: Bitmap support in BmpImage.java class ?

Posted by Harshini Madurapperuma <ha...@ifs.lk>.
Hi Jeremias,

Thanks for your valid suggestions. Does 0.95 supports for 16 and 32 bit images? What about the previous versions before 0.95? If you have a higher version can I get the algorithm or the code?

Thanks
Harshini.

-----Original Message-----
From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch]
Sent: Wednesday, February 13, 2008 12:36 PM
To: fop-users@xmlgraphics.apache.org
Subject: Re: Bitmap support in BmpImage.java class ?

Sure, you can. Either you replace BmpImage with the JAI implementation as discussed earlier or you change BmpImage. In the latter case, you have to convert the 16 and 32 bit image data to 24 bit RGB. Otherwise, the renderers will not process the image data correctly (FOP Trunk is much more flexible here). For this you need to know a few things about the BMP format. Start here to get more information:
http://en.wikipedia.org/wiki/BMP_file_format

I think it's probably easiest if you use ImageIO or JAI to load BMP images and convert them to the required 24bit pixel stream using the
BufferedImage.getRGB() method as done in JAIImage. But if I were you I'd try to upgrade FOP at least as soon as 0.95 is available next month.

On 13.02.2008 05:11:01 Harshini Madurapperuma wrote:
>  Hi all;
>
> I have the fop version 0.20.5, and I have to work with bitmap images.
> In BmpImage.java class the code supports only for 1,4,8 and 24 bit
> sizes, otherwise it throws an exception. Can't I modify this to
> support for 16 and 32 bits also with out changing the fop version.
> Your suggestions would be greatly appreciated.
>
> if (this.m_bitsPerPixel == 1)
>             bytes = (this.m_width + 7) / 8;
>         else if (this.m_bitsPerPixel == 24)
>             bytes = this.m_width * 3;
>         else if (this.m_bitsPerPixel == 4 || this.m_bitsPerPixel == 8)
>             bytes = this.m_width / (8 / this.m_bitsPerPixel);
>         else
>             throw new FopImageException("Image (" + this.m_href.toString()
>                                         + ") has " + this.m_bitsPerPixel
>                                         + " which is not a supported
> BMP format...");
>
> Regards,
> Harshini.



Jeremias Maerki


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

------------------------------------------------------------------------------

CONFIDENTIALITY AND DISCLAIMER NOTICE

This e-mail, including any attachments, is confidential and intended only for
the addressee. If you are not the intended recipient, please notify us
immediately and delete this e-mail from your system. Any use or disclosure of
the information contained herein is strictly prohibited.


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


Re: Bitmap support in BmpImage.java class ?

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Sure, you can. Either you replace BmpImage with the JAI implementation
as discussed earlier or you change BmpImage. In the latter case, you
have to convert the 16 and 32 bit image data to 24 bit RGB. Otherwise,
the renderers will not process the image data correctly (FOP Trunk is
much more flexible here). For this you need to know a few things about
the BMP format. Start here to get more information:
http://en.wikipedia.org/wiki/BMP_file_format

I think it's probably easiest if you use ImageIO or JAI to load BMP
images and convert them to the required 24bit pixel stream using the
BufferedImage.getRGB() method as done in JAIImage. But if I were you I'd
try to upgrade FOP at least as soon as 0.95 is available next month.

On 13.02.2008 05:11:01 Harshini Madurapperuma wrote:
>  Hi all;
> 
> I have the fop version 0.20.5, and I have to work with bitmap images.
> In BmpImage.java class the code supports only for 1,4,8 and 24 bit sizes,
> otherwise it throws an exception. Can't I modify this to support for 16
> and 32 bits also with out changing the fop version. Your suggestions
> would be greatly appreciated.
> 
> if (this.m_bitsPerPixel == 1)
>             bytes = (this.m_width + 7) / 8;
>         else if (this.m_bitsPerPixel == 24)
>             bytes = this.m_width * 3;
>         else if (this.m_bitsPerPixel == 4 || this.m_bitsPerPixel == 8)
>             bytes = this.m_width / (8 / this.m_bitsPerPixel);
>         else
>             throw new FopImageException("Image (" + this.m_href.toString()
>                                         + ") has " + this.m_bitsPerPixel
>                                         + " which is not a supported BMP format...");
> 
> Regards,
> Harshini.



Jeremias Maerki


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


Bitmap support in BmpImage.java class ?

Posted by Harshini Madurapperuma <ha...@ifs.lk>.
 Hi all;

I have the fop version 0.20.5, and I have to work with bitmap images. In BmpImage.java class the code supports only for 1,4,8 and 24 bit sizes, otherwise it throws an exception. Can't I modify this to support for 16 and 32 bits also with out changing the fop version. Your suggestions would be greatly appreciated.

if (this.m_bitsPerPixel == 1)
            bytes = (this.m_width + 7) / 8;
        else if (this.m_bitsPerPixel == 24)
            bytes = this.m_width * 3;
        else if (this.m_bitsPerPixel == 4 || this.m_bitsPerPixel == 8)
            bytes = this.m_width / (8 / this.m_bitsPerPixel);
        else
            throw new FopImageException("Image (" + this.m_href.toString()
                                        + ") has " + this.m_bitsPerPixel
                                        + " which is not a supported BMP format...");

Regards,
Harshini.
------------------------------------------------------------------------------

CONFIDENTIALITY AND DISCLAIMER NOTICE

This e-mail, including any attachments, is confidential and intended only for
the addressee. If you are not the intended recipient, please notify us
immediately and delete this e-mail from your system. Any use or disclosure of
the information contained herein is strictly prohibited.


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


RE: Converting BufferredImage into FopImage?

Posted by Harshini Madurapperuma <ha...@ifs.lk>.
HI

Yes I'm talking about bitmap images.
BTW FOP doesn't support 16 and 32 bit depth :(( I'm getting this error

:Image (file:./report_designer_graphics/FNDBAS/FND_SESSION_REP/IFSlogbw_16.bmp) has 16 which is not a supported BMP format.

/Harshini

-----Original Message-----
From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch]
Sent: Monday, February 11, 2008 5:10 PM
To: fop-users@xmlgraphics.apache.org
Subject: Re: Converting BufferredImage into FopImage?

I don't understand why you want to do that. There's already a JAIImage.java which uses JAI to read bitmap images and converts a BufferedImage into the format needed by FOP (JAIImage is a subclass of FopImage).

What exactly do you mean by "Bitmap image" in your first post? Windows BMP? There's a BmpImage class that supports them. And in case it doesn't work for the BMP images you use it's quite easy to replace BmpImage by JAIImage (or a customized subclass) in FopImageFactory.

I hope for you that you can soon upgrade to the latest FOP as this stuff gets much easier (or even unnecessary). Good luck!

On 11.02.2008 12:19:30 Harshini Madurapperuma wrote:
> Hi Jeremias;
>
> Following shows the modified code and:
>                 RenderedImage img2 =  (RenderedImage)JAI.create("ImageRead",imageSource);
>             RenderedImageAdapter ria = new RenderedImageAdapter(img2);
>             BufferedImage bi = ria.getAsBufferedImage();
>             FopImage img = (FopImage)bi;
>
> It was like this earlier:
>         FopImage img = FopImageFactory.Make(imageSource);
>
> I'm using FOP 0.20.5, anyway I have to stick to this version for now no way to change it at this moment. This is working fine for .gif, .jpg, .png images and doesn't work for Bitmap images. That's why I have changed the code.
>
> Thanks
> Harshini
>
>
>
> -----Original Message-----
> From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch]
> Sent: Monday, February 11, 2008 4:44 PM
> To: fop-users@xmlgraphics.apache.org
> Subject: Re: Converting BufferredImage into FopImage?
>
> Of course, you get a ClassCastException. These two classes are not related. Can you please start by explaining what you're trying to do (your overall goal, I mean). Maybe I can then guide you in the right direction.
>
> On 11.02.2008 12:03:26 Harshini Madurapperuma wrote:
> >
> > Hi All
> >
> >
> > Does anybody know how to convert a BufferredImage into a FopImage?
> > BufferredImage bi = " XXX ";
> > FopImage img = (FopImage)bi;
> >
> > When doing this I'm getting a ClassCastException.
> >
> > Regards
> > Harshini.
>
>
> Jeremias Maerki
>


Jeremias Maerki


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

------------------------------------------------------------------------------

CONFIDENTIALITY AND DISCLAIMER NOTICE

This e-mail, including any attachments, is confidential and intended only for
the addressee. If you are not the intended recipient, please notify us
immediately and delete this e-mail from your system. Any use or disclosure of
the information contained herein is strictly prohibited.


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


Re: Converting BufferredImage into FopImage?

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
I don't understand why you want to do that. There's already a
JAIImage.java which uses JAI to read bitmap images and converts a
BufferedImage into the format needed by FOP (JAIImage is a subclass of
FopImage).

What exactly do you mean by "Bitmap image" in your first post? Windows
BMP? There's a BmpImage class that supports them. And in case it doesn't
work for the BMP images you use it's quite easy to replace BmpImage by
JAIImage (or a customized subclass) in FopImageFactory.

I hope for you that you can soon upgrade to the latest FOP as this stuff
gets much easier (or even unnecessary). Good luck!

On 11.02.2008 12:19:30 Harshini Madurapperuma wrote:
> Hi Jeremias;
> 
> Following shows the modified code and:
>                 RenderedImage img2 =  (RenderedImage)JAI.create("ImageRead",imageSource);
>             RenderedImageAdapter ria = new RenderedImageAdapter(img2);
>             BufferedImage bi = ria.getAsBufferedImage();
>             FopImage img = (FopImage)bi;
> 
> It was like this earlier:
>         FopImage img = FopImageFactory.Make(imageSource);
> 
> I'm using FOP 0.20.5, anyway I have to stick to this version for now no way to change it at this moment. This is working fine for .gif, .jpg, .png images and doesn't work for Bitmap images. That's why I have changed the code.
> 
> Thanks
> Harshini
> 
> 
> 
> -----Original Message-----
> From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch]
> Sent: Monday, February 11, 2008 4:44 PM
> To: fop-users@xmlgraphics.apache.org
> Subject: Re: Converting BufferredImage into FopImage?
> 
> Of course, you get a ClassCastException. These two classes are not related. Can you please start by explaining what you're trying to do (your overall goal, I mean). Maybe I can then guide you in the right direction.
> 
> On 11.02.2008 12:03:26 Harshini Madurapperuma wrote:
> >
> > Hi All
> >
> >
> > Does anybody know how to convert a BufferredImage into a FopImage?
> > BufferredImage bi = " XXX ";
> > FopImage img = (FopImage)bi;
> >
> > When doing this I'm getting a ClassCastException.
> >
> > Regards
> > Harshini.
> 
> 
> Jeremias Maerki
> 


Jeremias Maerki


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


RE: Converting BufferredImage into FopImage?

Posted by Harshini Madurapperuma <ha...@ifs.lk>.
Hi Jeremias;

Following shows the modified code and:
                RenderedImage img2 =  (RenderedImage)JAI.create("ImageRead",imageSource);
            RenderedImageAdapter ria = new RenderedImageAdapter(img2);
            BufferedImage bi = ria.getAsBufferedImage();
            FopImage img = (FopImage)bi;

It was like this earlier:
        FopImage img = FopImageFactory.Make(imageSource);

I'm using FOP 0.20.5, anyway I have to stick to this version for now no way to change it at this moment. This is working fine for .gif, .jpg, .png images and doesn't work for Bitmap images. That's why I have changed the code.

Thanks
Harshini



-----Original Message-----
From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch]
Sent: Monday, February 11, 2008 4:44 PM
To: fop-users@xmlgraphics.apache.org
Subject: Re: Converting BufferredImage into FopImage?

Of course, you get a ClassCastException. These two classes are not related. Can you please start by explaining what you're trying to do (your overall goal, I mean). Maybe I can then guide you in the right direction.

On 11.02.2008 12:03:26 Harshini Madurapperuma wrote:
>
> Hi All
>
>
> Does anybody know how to convert a BufferredImage into a FopImage?
> BufferredImage bi = " XXX ";
> FopImage img = (FopImage)bi;
>
> When doing this I'm getting a ClassCastException.
>
> Regards
> Harshini.


Jeremias Maerki


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

------------------------------------------------------------------------------

CONFIDENTIALITY AND DISCLAIMER NOTICE

This e-mail, including any attachments, is confidential and intended only for
the addressee. If you are not the intended recipient, please notify us
immediately and delete this e-mail from your system. Any use or disclosure of
the information contained herein is strictly prohibited.


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


Re: Converting BufferredImage into FopImage?

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Of course, you get a ClassCastException. These two classes are not
related. Can you please start by explaining what you're trying to do
(your overall goal, I mean). Maybe I can then guide you in the right
direction.

On 11.02.2008 12:03:26 Harshini Madurapperuma wrote:
> 
> Hi All
> 
> 
> Does anybody know how to convert a BufferredImage into a FopImage?
> BufferredImage bi = " XXX ";
> FopImage img = (FopImage)bi;
> 
> When doing this I'm getting a ClassCastException.
> 
> Regards
> Harshini.


Jeremias Maerki


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