• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using ImageIO to read a bmp file  RSS feed

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried to explicitly use a newer version of JAI? https://jai.dev.java.net/
 
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
ying lam
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!