250X increase in BufferedImage draw time from 1.5 to 1.6

I had a program running fine in 1.5, had 3-4ms to draw 45 of the image to the screen, for a large image scaled small before drawing. Now after 1.6, I'm getting 820 ms for the same thing, and -version:1.5 will return it to 3-4. Did something change from 1.5 to 1.6? drawing the loaded image to a second image before drawing seems to drastically speed it up, as shown in this code.

import java.awt.image.BufferedImage;

import javax.swing.JFrame;

publicclass Testextends JFrame{

public Test(java.awt.image.BufferedImage bu){

b=new BufferedImage(bu.getWidth(),bu.getHeight(),BufferedImage.TYPE_INT_ARGB);

b.getGraphics().drawImage(bu,b.getWidth(),b.getHeight(),null);

c=bu;

}

publicstaticvoid main(String[] args){

Test t;

try{

t=new Test(javax.imageio.ImageIO.read(new java.io.File("tank.png")));

t.setSize(640,480);

t.setVisible(true);

for(int i=0;i<20;t.repaint())

t.invalidate();

System.out.println("done");

}catch(Exception e){

System.out.println("error");

e.printStackTrace();

}

}

publicvoid paint(java.awt.Graphics g){

System.out.println("c");

long t=System.nanoTime();

for(int i=0;i<50;i++){

g.drawImage(c,(i%10)*50,(i/10)*50,50,50,null);

}

System.out.println(System.nanoTime()-t);

System.out.println("b");

t=System.nanoTime();

for(int i=0;i<50;i++){

g.drawImage(b,(i%10)*50,(i/10)*50,50,50,null);

}

System.out.println(System.nanoTime()-t);

System.out.println("c");

t=System.nanoTime();

for(int i=0;i<50;i++){

g.drawImage(c,(i%10)*50,(i/10)*50,50,50,null);

}

System.out.println(System.nanoTime()-t);

try{

Thread.currentThread().sleep(100);}catch(Exception e){

}

}

BufferedImage b;

BufferedImage c;

}

I got this output (partial)

c

735032245

b

5980649

c

621233145

c

636763611

b

5810794

c

674099920

c

684414360

b

8663950

c

722404663

c

653634191

b

6532674

c

674372301

c

684147566

b

5422477

c

643982684

c

665757240

b

6029816

c

682749902

c

654843563

b

5109588

c

656486789

c

655536388

b

5046451

c

630079801

c

669861114

b

5156241

c

663675970

c

658672541

b

5067124

c

701646718

c

739559357

b

6100775

c

683766233

c

717030237

b

6912052

c

745393060

c

675646486

b

4612038

c

735275852

c

742058837

b

4696407

c

806628776

c

711131722

b

16984282

c

707504166

c

648611765

b

5418845

c

654920947

c

646268171

b

17911494

c

639430710

c

678515286

b

4755073

c

617724040

c

648390787

b

4743899

c

657646153

c

652459740

b

4634109

c

661877138

c

649476400

b

4591086

c

642310964

c

681698651

b

5361295

c

679005572

c

675222131

b

4662604

c

676943857

c

687534309

b

6773207

c

641403307

c

669728136

b

5059303

c

658017150

c

672984695

b

4617905

c

648743346

c

634762798

b

4681600

c

690653980

c

638157643

b

4729372

c

748789022

c

674756429

b

6717054

c

697223809

c

689808062

b

4664000

c

638143115

c

678560264

b

4724343

c

674861190

c

670472085

b

7397309

c

660327779

c

690909878

b

4992534

c

747887790

c

621971228

b

17102732

c

628246886

c

628726277

b

5182781

c

632977376

c

661510611

b

16858287

c

645003485

The image I used is at http://greyscribes.com/images/uploaded/Tank.png

[6339 byte] By [compuwinna] at [2007-11-27 7:37:30]
# 1
uhm...Maybe if you implement paintComponent() instead of paint().
RaulHuertasa at 2007-7-12 19:18:06 > top of Java-index,Security,Cryptography...
# 2
The way I was doing it originally was by grabbing the graphics from the GraphicsDevice, not using paint, so the method name doesn't matter. the issue is simply with graphics objects and images loaded from files into BufferedImages.
compuwinna at 2007-7-12 19:18:06 > top of Java-index,Security,Cryptography...