The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
December 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Fastest way to blit tile- and spritedata

Posted by Robert Madsen on December 15, 2000 at 5:08 AM

Since noone else wants to answer :-) I better do it myself (I hope that people are more eager to correct, if I am wrong!)

As far as I see it, the best way is to create the image entirely in a bufferedImage, and then blit the hole image to the screen in one drawImage call (Wellknown method, I know)
The important part is, to create the bufferedImage, with the same pixelformat as the screen! This way Java will not need to convert the pixels when blitting to the screen.

Sprites should be stored in a member of the Image-class because this will handle transparent areas. (Images are by default using the same depth as the screen, som they might consume a lot of space, if you have a large amount - But hey, RAM is getting cheaper by the month! :-)

For fire and fog effects you will probably need som bufferedImages with alpha-channels, but keep them as few as possible, since they are slow to render.

I made a couple of tests, trying to use Raster-objects, but since these are transformed to the destination-coordinates, they proved to be 2-3 times slower, than just using Image or BufferedImage classes.

Using these methods, I can blit a 1024x768 screen w. 65K colors, full of 32x32 tiles + fifty 6K-pixel sprites + twentyfive 4K pixel alpha-images in about 40miliseconds on a 600MHz PIII.

This is close to the maximum time I want it to use, but fortunately, it is not normal to redraw the *entire* screen every frame, so it could probably be optimzed by only blitting playfield, and only updating other areas when needed.
I also know, that running NT, the resolution of my timing i 10ms, so it migth be off by that number.

Hope this helps someone!

Regards
Robert Madsen, Denmark



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us