Wednesday, January 30, 2008

Easily display BufferedImage

In many situations, you may want to display the image from the instance of BufferedImage for debugging purposes.

The obvious way is to create a JPanel and overrides its paint(Graphics g) method. But that consumes time and energy!

The better solution is to instantiate an object of ImageIcon and use its setImage(Image image) method to host the BufferedImage instance in it. After that, you can easily display the image by using JOptionPane.

6 comments:

tot-anusak said...

Thanks!! It's very useful.

But... why don't use 'is/are to' instead of 'was to'?

^ ^

.:: m3rLinEz ::. said...

Thanks! It's my grammar mistake :$

It will be corrected very soon :)

Anonymous said...

Thanks, your code helped me. But could you provide it without HTML Tags? It's hard to copy and paste with all those
s around.

FinalSin said...

Such a great little idea. Saved me a precious few minutes, thanks!

Anonymous said...

Hey that was helpful! Thank you!

Anonymous said...

It is really usefull, thanks!