• Post Reply Bookmark Topic Watch Topic
  • New Topic

Saving a picture in BMP format  RSS feed

 
Ranch Hand
Posts: 34
Eclipse IDE Fedora Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Helo!

If i want to save this picture in BMP format, this code create a pic.bmp file with size zero byte and of course i cannot open that .bmp file.
There is the same problem with GIF format. This operation works in PNG, and JPG format.

Does someone have any idea how to change this code?
Thank you in advance for any help you can provide.

 
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried your code and it worked. I got 4 different files, none of them were empty. The file pic.BMP is 12 KB. I'm using Java SE 6 update 31 on Windows Vista.
 
Edward Bloom
Ranch Hand
Posts: 34
Eclipse IDE Fedora Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've gone home, i'll try it on my pc. (My worker pc generated this problem)
 
Saloon Keeper
Posts: 4038
94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hm, BMP should work. GIF was added in Java 6, for earlier JREs you'd have to add a plugin, just like for TIFF.
 
Edward Bloom
Ranch Hand
Posts: 34
Eclipse IDE Fedora Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks the answer!
Yes.. You are right. Both of you. I tried this code on my home pc. I'm using JSE6u31 on Windows7 and this code works. At my workplace we have to use an older version the Java 1.4 i think on Windows XP.
Is it possible the Java 1.4 cannot make BMP file? If yes, can i add and use any plugin for the solution?
 
Edward Bloom
Ranch Hand
Posts: 34
Eclipse IDE Fedora Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At my workplace we use IBM Rational Application Developer V6.0, JDK 1.4 and as we thought it could be the problem.
I'd like to find the solution. I should to add a plugin to solve my null bmp problem?
One of these could be good? If that isn't what i have to looking for, where should i search? How can i add a bmp plugin into eclipse based RADV6.0?

Thanks in advance.
 
Tim Moores
Saloon Keeper
Posts: 4038
94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BMP has been supported by ImageIO from the beginning; there is no plugin you could (or need to) add. It's possible that there are bugs in the implementation, especially on earlier JDKs. Instead of working around those bugs from 10 years ago, migrate to a newer JDK, at least Java 6.
 
Edward Bloom
Ranch Hand
Posts: 34
Eclipse IDE Fedora Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Tim, i know you are right about that we should to migrate to JDK 6 or 7 (and of course, i use the 7 version at home), but it is not practicable yet, because i am new at my workplace and i am a simple inferior, therefore i cannot do anything about this. So therefore i should do solve this in the 1.4 version of JDK. Do you know, or somebody know any possibility?
 
Tim Moores
Saloon Keeper
Posts: 4038
94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are any number of ways to convert images from one format to another. If you want to do this in Java, check out the ImageJ library.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ed fromhadria wrote:Yes Tim, i know you are right about that we should to migrate to JDK 6 or 7 (and of course, i use the 7 version at home), but it is not practicable yet, because i am new at my workplace and i am a simple inferior, therefore i cannot do anything about this. So therefore i should do solve this in the 1.4 version of JDK.

Hmmm.... I hope that you'll be able to convince your employer someday soon that using Java 1.4 is not a good idea anymore. Java 1.4 and also Java 5 have passed their end-of-life date long ago, which means that Oracle does not provide any security fixes or bugfixes for these versions anymore, unless your company has an expensive contract with Oracle.

See: Java SE EOL Policy. Java 1.4 has not been supported anymore since October 2008 and Java 5 hasn't been supported anymore since October 2009. Even support for Java 6 is going to be dropped in November this year!
 
Rancher
Posts: 4686
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More on @tim's idea, why are you trying to do this in Java? Why not use ImageMagick, which is free, open source, cross platform and amazingly powerful.

Sometimes the best program to use is one that someone else wrote, debugged and documented.
 
Edward Bloom
Ranch Hand
Posts: 34
Eclipse IDE Fedora Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper, Pat! As i've said i know you are right! (: I have to do in java, because my coproration uses servlets for our activity.
Well as i see i cannot solve this problem.
Apart from, thank You so much the answers!
 
Pat Farrell
Rancher
Posts: 4686
7
Linux Mac OS X VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ed fromhadria wrote:Jesper, Pat! As i've said i know you are right! (: I have to do in java, because my coproration uses servlets for our activity.


Simple, write the file out, use Java to call exec() and have ImageMagick do the work.
read the result back in.

Kinda silly, but beats writing all that code
 
Edward Bloom
Ranch Hand
Posts: 34
Eclipse IDE Fedora Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pat! Thank you so much this solution!
I could change my leaders opinion, so now the png format also good and not just the bmp.
But i'll keep your message for the emergency.
Thank you, all of You!
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!