Loading an Image

M

mohed.haidar

Hello guys. I have been trying hard to load an Image but with no luck.
Basically I want an application that can take an Image (jpeg) from a
specified location on my disk and show it. I get confused with all the
canvas, paint, render ,update stuff that makes the task seam very
complicated when i feel that its not so. Any ideas ?? And also if you
guys would have a problem like mine how would you go about finding a
solution ?? Thank you for your time.
 
O

Owen Jacobson

Hello guys. I have been trying hard to load an Image but with no luck.
Basically I want an application that can take an Image (jpeg) from a
specified location on my disk and show it. I get confused with all the
canvas, paint, render ,update stuff that makes the task seam very
complicated when i feel that its not so. Any ideas ?? And also if you
guys would have a problem like mine how would you go about finding a
solution ?? Thank you for your time.

1. Use ImageIO to load the file into an Image object:
<http://java.sun.com/docs/books/tutorial/2d/images/loadimage.html>

2. Use the Image object to create an ImageIcon object.

3. Place the ImageIcon widget in a JLabel and add the label to your
window.

Check the javadocs on ImageIO, Image, ImageIcon, and JLabel for a
fairly thorough explanation of how all this fits together. The
tutorial link I gave you proposes a second way to do it, which is more
useful if you need to transform the image (scale, rotate, recolour,
alpha-blend, et cetera) before drawing it.

-o
 
K

Knute Johnson

Owen said:
1. Use ImageIO to load the file into an Image object:
<http://java.sun.com/docs/books/tutorial/2d/images/loadimage.html>

2. Use the Image object to create an ImageIcon object.

3. Place the ImageIcon widget in a JLabel and add the label to your
window.

Check the javadocs on ImageIO, Image, ImageIcon, and JLabel for a
fairly thorough explanation of how all this fits together. The
tutorial link I gave you proposes a second way to do it, which is more
useful if you need to transform the image (scale, rotate, recolour,
alpha-blend, et cetera) before drawing it.

-o

Also look here for some example code on how to load and display and image.

http://rabbitbrush.frazmtn.com

And I would use the ImageIO method not the others.
 
C

Chase Preuninger

In swing all the stuff u nead is in the imageIO package

javax.imageio.ImageIO.load(...);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top