Re: BufferedImage
- From: Thomas Weidenfeller <nobody@xxxxxxxxxxxxxxxx>
- Date: Tue, 31 May 2005 15:12:11 +0200
Martijn Mulder wrote:
I try to load an image into a BufferdImage instance in the constructor of my class. It does not work.
Wrong, loading works. But then you do the wrong thing with it.
//data member graphics2d java.awt.Graphics2D graphics2d=displayimage.createGraphics();
This is the Graphics context of the Image itself.
graphics2d.drawImage(image,0,0,this);
Here you draw the image on itself by using its own Graphics context.
Please note, however, that changing to the "right" Graphics context will not work. There is no right Graphics context the moment you try to paint. The idea of painting ("pushing" graphics onto a component) outside of the paint[Component]() method is basically flawed.
Q3.4 of the comp.lang.java.gui FAQ basically applies to your problem. The TCS article about painting in AWT and Swing is also a good read.
/Thomas
-- The comp.lang.java.gui FAQ: ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq .
- References:
- BufferedImage
- From: Martijn Mulder
- BufferedImage
- Prev by Date: Re: Struts and javascript
- Next by Date: Re: Java WSDP and Tomcat 5
- Previous by thread: BufferedImage
- Next by thread: JBoss XDoclet and Mail beginner question
- Index(es):
Relevant Pages
|