to draw a blank image

Hello, my target is to draw a blank jpg image with established width and height.

This is my code:

publicvoid drawShape(int w,int h){

Graphics2D myG2D;

BufferedImage bImg =new BufferedImage( w, h, BufferedImage.TYPE_INT_ARGB );

File imgFile =new File("C:\\Documents and Settings\\m.lipreri\\Desktop\\bombs\\test.jpg");

myG2D = bImg.createGraphics();

myG2D.setBackground(Color.WHITE);

myG2D.setColor( Color.WHITE );

try{

ImageIO.write( bImg,"jpg", imgFile );

}catch ( IOException e ){

e.printStackTrace();

}

}

all the time i find out an image with width = w and heght = h but with color background BLACK. Why? thx

[1189 byte] By [mlipreria] at [2007-11-27 10:14:41]
# 1

You have set the color/background. Now you have to fill it in.

There are two ways you can do this:

myG2D = bImg.createGraphics();

// You can do it this way

myG2D.setBackground(Color.WHITE);

myG2D.clearRect(0,0,w,h);

// or you can do it like this

myG2D.setColor( Color.WHITE );

myG2D.fillRect(0,0,w,h);

crwooda at 2007-7-28 15:34:52 > top of Java-index,Security,Cryptography...