Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2006

Tip: Looking for answers? Try searching our database.

ImageIO on in-memory byte array

Thread view: 
roger.books - 19 Oct 2006 20:30 GMT
I have an application that reads TIFFs from a file that is a
concatenation of TIFFs along with some special headers.  For this
question I have the TIFF in a byte array.

I have installed the jai/ImageIO libs from Sun,
ImageIO.getReaderFormatNames() shows TIFF as one of the options.

I can write out the TIFF file and read it in using:

File f = new File("c:\images\myimage.tiff");
BufferedImage bi = ImageIO.read(f);

and write out the converted file using ImageIO.write()

however, I need to do 50,000 images and would prefer to skip the
intermediate file.  Does anyone have any pointers on how to do this?

I appreciate any input.  

Roger Books
Mike  Schilling - 19 Oct 2006 22:37 GMT
>I have an application that reads TIFFs from a file that is a
> concatenation of TIFFs along with some special headers.  For this
[quoted text clipped - 12 lines]
> however, I need to do 50,000 images and would prefer to skip the
> intermediate file.  Does anyone have any pointers on how to do this?

Make an input stream from the byte array and feed that to ImageIO.read().
Knute Johnson - 19 Oct 2006 23:25 GMT
Mike Schilling wrote:
>> I have an application that reads TIFFs from a file that is a
>> concatenation of TIFFs along with some special headers.  For this
[quoted text clipped - 14 lines]
>
> Make an input stream from the byte array and feed that to ImageIO.read().

What is the format of the TIFF byte array?  Could you actually be
reading it in as an image?  That would save you two conversion steps.

Signature

Knute Johnson
email s/nospam/knute/

roger.books - 20 Oct 2006 15:15 GMT
I'm pulling it in from a custom format a bank is using.  It's a small
header
and 50K images concatenated.  The image offsets, sizes, and other
information is stored in an XML file.  I guess I could make an input
stream
that took file name, offfset, and bytes.

Can anyone recommend a resource that shows how to make an input stream?
I _think_ it is just implementing the interface.  Is that correct?

Roger

> Mike Schilling wrote:
> >> I have an application that reads TIFFs from a file that is a
[quoted text clipped - 18 lines]
> What is the format of the TIFF byte array?  Could you actually be
> reading it in as an image?  That would save you two conversion steps.
Knute Johnson - 20 Oct 2006 18:44 GMT
> I'm pulling it in from a custom format a bank is using.  It's a small
> header
[quoted text clipped - 29 lines]
>> What is the format of the TIFF byte array?  Could you actually be
>> reading it in as an image?  That would save you two conversion steps.

The docs say, "Applications that need to define a subclass of
InputStream  must always provide a method that returns the next byte of
input."

But what I might do is write a class that reads the file and returns an
array of BufferedImages.  Then manipulate them as desired and save them
in whatever format you want.

You know the sizes of the images, so read them into a byte[], manipulate
them, create a ByteArrayInputStream from the byte[], and then use
ImageIO to read the TIFF image from BAIS.  Buffer the disk I/O and it
should be plenty fast.

Signature

Knute Johnson
email s/nospam/knute/

roger.books@gmail.com - 20 Oct 2006 19:52 GMT
I just discovered ByteArrayInputStream, that looks like the way to go.

I'll let you know how it goes.  That is if I can ever get an hour
without a meeting.

Thanks,

Roger

> You know the sizes of the images, so read them into a byte[], manipulate
> them, create a ByteArrayInputStream from the byte[], and then use
> ImageIO to read the TIFF image from BAIS.  Buffer the disk I/O and it
> should be plenty fast.
Mike  Schilling - 20 Oct 2006 19:10 GMT
> I'm pulling it in from a custom format a bank is using.  It's a small
> header
[quoted text clipped - 5 lines]
> Can anyone recommend a resource that shows how to make an input stream?
> I _think_ it is just implementing the interface.  Is that correct?

Look at the javadoc for InputStream (an abstract class, not an interface),
which tells you what you need to do to subclass it.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.