• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question about drawimage

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic