This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Drawing of a Scaled Image Fails to show unless stepping through in the debugger Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Drawing of a Scaled Image Fails to show unless stepping through in the debugger" Watch "Drawing of a Scaled Image Fails to show unless stepping through in the debugger" New topic
Author

Drawing of a Scaled Image Fails to show unless stepping through in the debugger

Tim Alvord
Greenhorn

Joined: Jan 24, 2013
Posts: 23
Hi,
I am trying to scale an image I have previously loaded from a file. All drawing of the image works fine until I make a scaled copy of it and try and display it. Then it only will display if I am stepping through the debugger. Do I need to wait somehow until the scaled image is completed before displaying?

Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2724
    
  56
The API docs for getScaledInstance say:
"Creates a scaled version of this image. A new Image object is returned which will render the image at the specified width and height by default. The new Image object may be loaded asynchronously even if the original source image has already been loaded completely."
So yes you may have to wait. Alternatively you can draw a scaled version of the image on the fly using one of the Graphics classes drawImage(...) methods, I've no idea how efficient it is though.
Tim Alvord
Greenhorn

Joined: Jan 24, 2013
Posts: 23
Tony,
Thanks. I ended up using: drawImage(Img, x, y, width, height, this )
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2724
    
  56
You're Welcome
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Drawing of a Scaled Image Fails to show unless stepping through in the debugger
 
It's not a secret anymore!