The question here is simple. You create the Image with getInstance. If an
exception was not thrown and calling image.type() returns Element.JPEG then
you have a jpeg.

Best Regards,
Paulo Soares

> -----Original Message-----
> From: Cinzia S [SMTP:[EMAIL PROTECTED]
> Sent: Wednesday, June 25, 2003 12:04
> To:   Paulo Soares; [EMAIL PROTECTED]
> Subject:      Re: [iText-questions] testing for jpeg encoding
> 
> I'm sorry Paulo, but I don't get it, in JAI I'm encoding an image so that
> I
> get a jpeg encoded format, RTF accepts jpgs so it should be happy with it.
> The only way to add this to an RTF document is by creating a
> com.lowagie.text.Image, which I do by using static Image's getInstance()
> method. Why a jpeg encoded image is not recognized as such when going
> through and output stream which is not a FileOuputStream? I know I might
> be
> lacking some basic knowledge here, but thanks for your help.
> 
> 
> ----- Original Message -----
> From: "Paulo Soares" <[EMAIL PROTECTED]>
> To: "'Cinzia S'" <[EMAIL PROTECTED]>; "Paulo Soares"
> <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Wednesday, June 25, 2003 10:56 AM
> Subject: RE: [iText-questions] testing for jpeg encoding
> 
> 
> >
> >
> > > -----Original Message-----
> > > From: Cinzia S [SMTP:[EMAIL PROTECTED]
> > > Sent: Wednesday, June 25, 2003 11:01
> > > To: Paulo Soares; [EMAIL PROTECTED]
> > > Subject: Re: [iText-questions] testing for jpeg encoding
> > >
> > > Does this mean that
> > > 1) plain RGB is not a jpeg thing
> > >
> > jpeg is a compression format. You must decompress it first to work
> > with the image.
> >
> > > 2) there is no way I can skip creating a new jpeg file?
> > >
> > If you want the format to be saved as jpeg in the pdf, no.
> >
> > Best Regards,
> > Paulo Soares
> >
> > > Thank you
> > > Cinzia
> > >
> > > ----- Original Message -----
> > > From: "Paulo Soares" <[EMAIL PROTECTED]>
> > > To: "'Cinzia S'" <[EMAIL PROTECTED]>;
> > > <[EMAIL PROTECTED]>
> > > Sent: Wednesday, June 25, 2003 10:46 AM
> > > Subject: RE: [iText-questions] testing for jpeg encoding
> > >
> > >
> > > > When the jpeg is loaded by JAI it's converted to plain RGB. You'll
> have
> > > to
> > > > save it again to jpeg with JAI.
> > > >
> > > > Best Regards,
> > > > Paulo Soares
> > > >
> > > > > -----Original Message-----
> > > > > From: Cinzia S [SMTP:[EMAIL PROTECTED]
> > > > > Sent: Wednesday, June 25, 2003 10:25
> > > > > To: [EMAIL PROTECTED]
> > > > > Subject: [iText-questions] testing for jpeg encoding
> > > > >
> > > > > Hi,
> > > > >
> > > > > I'm trying to add a jpeg image to an rtf document. First I read in
> a
> > > jpg,
> > > > > scale it and output it to a ByteArrayOutputStream (using JAI).
> > > However,
> > > > > when
> > > > > I convert this image data to an instance of com.lowagie.text.Image
> and
> > > > > test
> > > > > for its type, it doesn't seem to be recongized as a jpeg, but as
> raw
> > > image
> > > > > data. Does anyone know what is going wrong? I've included some
> > > portions
> > > of
> > > > > code:
> > > > >
> > > > > // IN JAITest class
> > > > >   public ByteArrayOutputStream writeImageToBuffer( PlanarImage
> img,
> > > > > JPEGEncodeParam encodeParam )
> > > > >   {
> > > > >     ByteArrayOutputStream out = null;
> > > > >
> > > > >     try {
> > > > >       out = new ByteArrayOutputStream();
> > > > >       ImageEncoder encoder = ImageCodec.createImageEncoder(
> "JPEG",
> > > out,
> > > > > encodeParam );
> > > > >       encoder.encode( img );
> > > > >     } catch (Exception e) { e.printStackTrace(); }
> > > > >
> > > > >     return out;
> > > > >   }
> > > > >
> > > > >
> > > > > // IN RTFTest class
> > > > >   public void addImage( ByteArrayOutputStream out, int width, int
> > > height )
> > > > >   {
> > > > >     byte data[] = out.toByteArray();
> > > > >
> > > > >     try {
> > > > >       com.lowagie.text.Image img =
> com.lowagie.text.Image.getInstance(
> > > > >         width, height, RGB_COMPONENTS, BITS_PER_COMPONENT, data );
> > > > >       document_.add( img );
> > > > >
> > > > >       System.out.println( "Is ImgRaw " + String.valueOf(
> > > > >         img.isImgRaw() ) );
> > > > >       System.out.println( "Is Jpeg " + String.valueOf(
> > > > >         img.isJpeg() ) );
> > > > >
> > > > >       out.close();
> > > > >     }
> > > > >     catch ( IOException ie ) { ie.printStackTrace(); }
> > > > >     catch ( com.lowagie.text.BadElementException be ) {}
> > > > >     catch ( com.lowagie.text.DocumentException de ) {
> > > > > de.printStackTrace(); }
> > > > >
> > > > >   }
> > > > >
> > > > > // OUTPUT
> > > > >   Is ImgRaw true
> > > > >   Is Jpeg false
> > > > >
> > > > >
> > > > > It might be important to say that if I write the scaled jpeg to a
> file
> > > > > with
> > > > > a
> > > > > FileOutputStream and then create an instance of
> com.lowagie.text.Image
> > > > > using
> > > > > this file, it works fine. But if I can skip having to create a new
> > > file
> > > > > just
> > > > > to scale done the image that would be great.
> > > > >
> > > > > Thanks for any help
> > > > > Cinzia
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > -------------------------------------------------------
> > > > > This SF.Net email is sponsored by: INetU
> > > > > Attention Web Developers & Consultants: Become An INetU Hosting
> > > Partner.
> > > > > Refer Dedicated Servers. We Manage Them. You Get 10% Monthly
> > > Commission!
> > > > > INetU Dedicated Managed Hosting
> http://www.inetu.net/partner/index.php
> > > > > _______________________________________________
> > > > > iText-questions mailing list
> > > > > [EMAIL PROTECTED]
> > > > > https://lists.sourceforge.net/lists/listinfo/itext-questions
> > > >


-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to