aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Question about drawimage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Question about drawimage" Watch "Question about drawimage" New topic
Author

Question about drawimage

zhong hb
Greenhorn

Joined: Oct 18, 2005
Posts: 7
I want to draw a image on a rectangle,the code is:

int x = rectangle.getX();
int y = rectangle.getY();

int w = rectangle.getWidth();
int h = rectangle.getHeidht();

ImageIcon icon = new ImageIcon(imageName);
Image image = icon.getImage();

AffineTransform at = new AffineTransform();
at.translate(x,y);
at.scale(w/image.getWidth(this),h/image.getHeight(this));
graphics2d.drawImage(image,at,this);

because the forum can't show image, I take a char 'A' to replace image.under jre1.4.1, the result is 'A',which is good. but under jre1.5.0,'A''A''A'is showing. Why?? Thanks!
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
You can't post images to this forum?

News to me!


There is no emoticon for what I am feeling!
zhong hb
Greenhorn

Joined: Oct 18, 2005
Posts: 7
Thank you. I find that AffineTransform is a key for image showing.
if the scale is suitable, the showing is good.
[ November 10, 2005: Message edited by: zhong hb ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about drawimage