Thursday, June 5, 2008

Show TIFF in JAVA

Java has very high capabilities in graphics than numerical computations. There are several classes to manipulate different image formats. The JPEG, GIF and PNG formats and directly manipulate using normal java.imageio library. But if u want to render some TIFF format images you should have another library called Java Advanced Imaging(JAI) API. It's very easy to use this library. Here are some examples.
You should install JAI for java in your machine or you should refer to the library in you project.

You should import javax.media.jai.* library to have following functions.

If you want to show a tiff stored in your local machine.
RenderedImage image = JAI.create("fileload", filename);

When you want to get a TIFF from server you can use following method.
RenderedImage image = JAI.create("url", u);
Here "u" is url to the tiff you refer. For example the url can be "http://www.kasun.com/mytest.tiff". There is a url class under java.net library.



No comments: