Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Scaling image: black box until repainting

 
Rikki Bostelmann
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm trying to load an image, rescale it, and draw it on a panel.

After loading an Image and using getScaledInstance printed nothing, I read
that one should use BufferedImage. However, the following code produces
only a black box, until forcing a repaint by changing the size of the
window or minimizing.



Why?
Thanks a ton,
Rikki

[ October 02, 2004: Message edited by: Rikki Bostelmann ]
[ October 02, 2004: Message edited by: Rikki Bostelmann ]
 
Craig Wood
Ranch Hand
Pie
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

A variation in option two above (xform) is to make the scaled image one time and then render it in paintComponent vis–a–vis scaling it each time it is rendered. The approach shown above is better suited for ongoing image manipulation while this (suggested variation) is better if you do not need to make anymore changes in the scaled image, such as in a background image for a JPanel.
 
Rikki Bostelmann
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Craig,

that's exactly what I needed, awesome!!!

Thanks,
Rikki
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic