vendredi 27 février 2015

Can't draw an image in Graphics2D

I'm making a video of handwriting. For that, I create images of the correspondent text at a given time. All images should have a background image like this:background image


So I've got this code to add this image before I add the text:



File srcImg = new File("maskTEXT2.png");
BufferedImage img = ImageIO.read(srcImg);
java.awt.Image tmp = img.getScaledInstance(WIDTH, HEIGHT, java.awt.Image.SCALE_SMOOTH);
graphics.setBackground(Color.WHITE);
boolean x=false;
while(!x){
x= graphics.drawImage(tmp, 1, 1, null);
}


graphics is a Graphics2D object. I printed the size of the image (img and tmp) and it isn't -1 so the image is loading correctly.


When I run the program all images are saved like this:image generated


Aucun commentaire:

Enregistrer un commentaire