Better performance for Java Canvas Buffered images -
i using java canvas , have draw method, called 20 times second. iterates through array of images , draws scaledinstance of them depending on window size:
g.drawimage(img.getscaledinstance( (short)math.round(rect.width * yvector), (short)math.round(rect.height * yvector), image.scale_smooth), (short)math.round(rect.x * xvector), (short)math.round(rect.y * yvector), null);
performance bad. using buffer strategy , how images, bufferedimage, declared:
try { image = imageio.read(new file("resources/drawable/" + src)); img = (bufferedimage)image.getimage(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); }
the performance issues came getscaledinstance
. scaled image 20 times/second, not performant. our application has fixed positions , sizes, runs stable, high fps rate.
Comments
Post a Comment