• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Question about drawimage

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't post images to this forum?

News to me!
 
zhong hb
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic