JAI: loading image file and check for success

A

Andre Raue

Hello,

how do I check, if an image file was successfully loaded when I use
the Java Advanced Imaging API (JAI)?

I thought, that JAI.create("fileload", ...) should return 'null', when
file loading fails. But this is not the case. I never get a return
value of 'null', even if I try to open a .WAV oder .TXT file. Instead,
I receive a Runtime Exception when calling a method of the returned
image object (see example below).

My configuration:
JAI 1.1.2_1
J2SE SDK 1.4.2_04

-------- Example
// load image
PlanarImage image =
JAI.create("fileload", "C:/someValidPath/noImage.xyz");

if(image == null){
System.out.println("Could not load image!"); //<--- never reached
}

// Print out number of bands
System.out.println("image has " + image.getNumBands() +
" band(s)"); // <--- ! Exception !

-------- End of example


Greetings,

Andre
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top