Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

BufferedImage to BMP, PNG and GIF  RSS feed

 
Tim Alvord
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found and am using the JPEGImageEncoder from com.sun.image.codec.jpeg.*. I tried but was unable to find similar encoders for BMP, PNG and GIF? Does one exist?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should not be using that class. The javax.imageio.ImageIO class handles GIF, JPEG, PNG, BMP and TIFF, *and* is easy to use, *and* is guaranteed to continue working in future Java versions. Now that's what I call a win-win-win situation :-)
 
Tim Alvord
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf,
Thanks! Wow that is much easier!

http://javarevisited.blogspot.com/2011/12/read-write-image-in-java-example.html
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep, and that class can do even more, like work with TIFF, RAW, PNM, and JPEG2000 images, and let you control compression quality in JPEG if image size ever becomes an issue.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!