File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Using ImageIO to read a bmp file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Using ImageIO to read a bmp file" Watch "Using ImageIO to read a bmp file" New topic
Author

Using ImageIO to read a bmp file

ying lam
Ranch Hand

Joined: May 17, 2004
Posts: 85
Hi,

I have this piece of code which read bmp file from disk:



I get an image object when i run the program under java 1.6.
But when i run the same program under java 1.4, image is null.

Can you please tell me how can I get imagIO onjava 1.4 to read bmp file?

Thank you.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Have you tried to explicitly use a newer version of JAI? https://jai.dev.java.net/


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35224
    
    7
Support for BMP images wasn't added to ImageIO until Java 5.

You should be able to grab the sources for the GNU ImageIO BMP implementation, and use those with Java 1.4. That would still allow you to use ImageIO.

I wouldn't use JAI for image loading/saving; my impression is that it's been abandoned for the most part.


Android appsImageJ pluginsJava web charts
ying lam
Ranch Hand

Joined: May 17, 2004
Posts: 85
Thank you.

I take all the source from 'http://www.docjar.com/docs/api/gnu/javax/imageio/overview-summary.html'

I am not sure how can i call the BMPDecoder to decode a bmp image?

Thank you.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35224
    
    7
The only thing your code needs to do is register the classes with ImageIO; something like this:

Then you can just use ImageIO.read as if ImageIO supported BMP natively.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Using ImageIO to read a bmp file
 
Similar Threads
Exception: java.lang.ClassVersionError:
unix/ias/java help
unix/ias/java help
how to create an image through bufferedimage,image and other helper class using byte array
Byte[] to image