• 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

load image using mediatracker

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am using mediatracker in loading image.


try {

MediaTracker tracker = new MediaTracker(null);

while(i<=filenames.length-1) {

Image im = Toolkit.getDefaultToolkit().getImage("D:/photos/thumb/"+filenames[i]);



tracker.addImage(im,i);



tracker.waitForID(i);


width=im.getWidth(null);
height=im.getHeight(null);

}
}catch(Exception e) { out.println(e.getMessage()); }


but it gived error : null


where is problem?
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by pavan sharma:

MediaTracker tracker = new MediaTracker(null);



This is no good. If you intend to use the tracker for anything you must pass in an actual Component (or JComponent) to the constructor.
 
pavan sharma
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,


I got another way - and it return actual width and height in first time.

BufferedImage image = ImageIO.read(new URL("http://today.java.net/jag/bio/JagHeadshot.jpg"));

int w = image.getWidth(); //if you want...
int h = image.getHeight();//if you want.



Thanks,
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic