Results 1 to 3 of 3
Thread: how to resize an image
- 08-20-2009, 01:03 PM #1Member
- Join Date
- Aug 2009
- Rep Power
You probably draw your image via Graphics#drawImage(....) within your paintComponent method. Check out the Graphics API for the different overloads for that method. You may find one that suits your purposes well. To draw text, in the same paintComponent overridden method, call drawString on your Graphics object. To draw on the image, draw the string after you draw the image.
- 08-21-2009, 04:10 AM #3
I'm no expert on this subject, but I have used Image.getScaledInstance to rescale an image. I have found that paint() methods get called a lot more often than I originally expected, and creating and saving a scaled image and using that until the panel size changes may produce a noticeable performance improvement...
- By jithan in forum New To JavaReplies: 4Last Post: 11-07-2008, 09:26 AM
- By pele in forum SWT / JFaceReplies: 3Last Post: 06-09-2008, 08:31 AM
- By osval in forum New To JavaReplies: 1Last Post: 08-02-2007, 03:02 AM
- By lenny in forum AWT / SwingReplies: 1Last Post: 07-29-2007, 11:18 PM
- By paul in forum AWT / SwingReplies: 1Last Post: 07-16-2007, 04:11 PM