• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Easiest way to get the dimensions of an image...

 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm probably overlooking a reaaly obvious way to do this.

I've got a method that accepts a java.awt.Image as an argument and calculates the center point of the image.

I noticed the getHeight() and getWidth() methods of the Image class require that an ImageObserver be passed as an argument. In my case I don't have an ImageObserver to pass, and it doesn't really make sense to create one just for this method. I could create an javax.swing.ImageIcon object from the Image and then just call getIconHeight() and getIconWidth() but I wanted to check with you guys so that I could make sure that I wasn't overlooking something easier.

Landon
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it's OK to pass "null" for the ImageObserver. Just make sure to check for "-1" results.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic