Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting width of an image

Status
Not open for further replies.

cjdrake

Programmer
Jul 11, 2003
30
GB
All I am trying to do is find the width and height of an Image. I am trying to use the getWidth() and getHeight() methods to determine the w/h of the image- [these are unknown otherwise I'd use a BufferedImage]. I don't really know enough about the ImageObserver interface to implement it correctly [have tried using 'null' and 'this' with no success].

Image image = Toolkit.getDefaultToolkit().getImage(imageFile);
int width = image.getWidth(ImageObserver);

Any advice/help would be much appreciated. Thanks.
 
Try making an ImageIcon object with the image file. It has methods for finding the width and height of the image in pixels.
 
Have manage to work around this problem using a different method!

If you can't solve a problem directly - got around it!

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top