Skip to main content

[JAI] Converting CCITT stream into TIFF

6 replies [Last post]
Anonymous

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Burwinkel, Scott

You might look into what type of SeekableStream that the
SeekableStream.wrapInputStream() call is returning.

In fact, if you already have a byte[] (as would have been the input to
your ByteArrayInputStream), why not create a ByteArraySeekableStream
directly?

Scott J Burwinkel - Consultant Software Developer
Fidelity Investments - EPS - Image Capture & Remittance Systems
Now I've got a mind / full of wicked designs /
I've got a non-stop hole in my head / imagination - Poe

-----Original Message-----
From: mark.stephens@ukonline.co.uk [mailto:mark.stephens@ukonline.co.uk]

Sent: Monday, June 06, 2005 3:49 PM
To: interest@jai.dev.java.net
Subject: Re: [JAI] Converting CCITT stream into TIFF

I now have a routine to take a CCITT stream from a PDF, add a tiff
header and decode using JAI. It all works very nicely except for 1
performance issue.

I have the image in a ByteArrayInputStream and convert it to a
BufferedImage using the code

SeekableStream fss=FileSeekableStream.wrapInputStream(bis,true);
img=(JAI.create("stream",fss)).getAsBufferedImage();

The getAsBufferedImage() is coming up in the profiler as taking 48 %
of the program time. Is there a way to optimise it?

Regards,

MArk

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

mark.stephens@ukonline.co.uk

In message <79EA74194B663D40BD89D98DA2A4F63B04A46631@MSGDALCLC2WIN.DMN
1.FMR.COM>
"Burwinkel, Scott" wrote:

> You might look into what type of SeekableStream that the
> SeekableStream.wrapInputStream() call is returning.
>
> In fact, if you already have a byte[] (as would have been the input to
> your ByteArrayInputStream), why not create a ByteArraySeekableStream
> directly?

Faster, but still an order of magnitude slower than using the old Sun
TiffFaxDecoder class to decode the stream and then building an image
around it :-(

Still now I have the correct data I can debug it ;-)

MArk
>
> Scott J Burwinkel - Consultant Software Developer
> Fidelity Investments - EPS - Image Capture & Remittance Systems
> Now I've got a mind / full of wicked designs /
> I've got a non-stop hole in my head / imagination - Poe
>
>
> -----Original Message-----
> From: mark.stephens@ukonline.co.uk [mailto:mark.stephens@ukonline.co.uk]
>
> Sent: Monday, June 06, 2005 3:49 PM
> To: interest@jai.dev.java.net
> Subject: Re: [JAI] Converting CCITT stream into TIFF
>
>
> I now have a routine to take a CCITT stream from a PDF, add a tiff
> header and decode using JAI. It all works very nicely except for 1
> performance issue.
>
> I have the image in a ByteArrayInputStream and convert it to a
> BufferedImage using the code
>
> SeekableStream fss=FileSeekableStream.wrapInputStream(bis,true);
> img=(JAI.create("stream",fss)).getAsBufferedImage();
>
>
> The getAsBufferedImage() is coming up in the profiler as taking 48 %
> of the program time. Is there a way to optimise it?
>
> Regards,
>
> MArk
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Brian Burkhalter

Why do you need a BufferedImage?

Brian

On Mon, 6 Jun 2005 mark.stephens@ukonline.co.uk wrote:

> Faster, but still an order of magnitude slower than using the old Sun
> TiffFaxDecoder class to decode the stream and then building an image
> around it :-(
>
> Still now I have the correct data I can debug it ;-)

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

mark.stephens@ukonline.co.uk

In message
Brian Burkhalter wrote:

> Why do you need a BufferedImage?

I want to convert the CCITT stream into an image so I can render it.
Can I get the bytes directly?

Regards,

MArk

P.S. I've done some investigation into why the Sun TiffFaxDecoder does
not work on some streams. The routine scanNextDataLine will exit if
the first byte is 14 bits (EOL). This appears to be allowed in the
spec. So the image appears all black.
>
> Brian
>
> On Mon, 6 Jun 2005 mark.stephens@ukonline.co.uk wrote:
>
>> Faster, but still an order of magnitude slower than using the old Sun
>> TiffFaxDecoder class to decode the stream and then building an image
>> around it :-(
>>
>> Still now I have the correct data I can debug it ;-)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Brian Burkhalter

You should be able to render the RenderedImage returned by the decoder.

Brian

On Mon, 6 Jun 2005 mark.stephens@ukonline.co.uk wrote:

> > Why do you need a BufferedImage?
>
> I want to convert the CCITT stream into an image so I can render it.
> Can I get the bytes directly?

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

mark.stephens@ukonline.co.uk

I now have a routine to take a CCITT stream from a PDF, add a tiff
header and decode using JAI. It all works very nicely except for 1
performance issue.

I have the image in a ByteArrayInputStream and convert it to a
BufferedImage using the code

SeekableStream fss=FileSeekableStream.wrapInputStream(bis,true);
img=(JAI.create("stream",fss)).getAsBufferedImage();

The getAsBufferedImage() is coming up in the profiler as taking 48 %
of the program time. Is there a way to optimise it?

Regards,

MArk

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net