Best speeds in 'blitting'

Blitz3D Forums/Blitz3D Programming/Best speeds in 'blitting'

Shifty Geezer(Posted 2007) [#1]
I've just tried writing pixels fast and found it's way slower than the Image commands. I also found the DrawBlock() seemed slower than DrawImage(). Can someone fill me in on the best performance techniques for blitting bits of image around, and maybe even explain why (like why's drawing without masking slower than with?)

Also is there a fast way to do alpha blended blits? Using WritePixel or WritePixelFast is just too slow, but I don't want to convert to a 3D engine and use quad sprites.


VIP3R(Posted 2007) [#2]
Blimey, it's Shifty! Welcome back :)

I can answer one of those questions... the DrawImage function is faster than DrawBlock because it skips the masked pixels, whereas DrawBlock has to draw every pixel regardless.

Don't know of any faster techniques from within Blitz directly, I found WritePixelFast was quite fast, obviously not as fast as DrawImage would be (which is coded in C++). There's bound to be some way of doing it faster though.


Tom(Posted 2007) [#3]
I don't think DX7 supports alpha blitting:

DX7 Docs on 'Blt()'

All DDBLT_ALPHA flag values.
Not currently implemented.



Shifty Geezer(Posted 2007) [#4]
Yep, Shifty's snuck back while no-one was looking! Long time no see! In between other things, I'm developing software once again. No ODE in this one though!

I'm using BMP font to get antialised textboxes which works okay, with read/write pixel fast doing alpha blends with the background. But using the same per-pixel draws for a 160x160 image really drags the machine. The textboxes are updated with a severe lag. And this is on a 9600! Using DrawImage, the program runs smoothly. But I dread to think how lesser machines will manage with the AA'd text, and really want the optimal draw technique.

I suppose in theory I could Peek and Poke from RAM, but Read/WritePixelFast ought to be operating on the same level as that.


Danny(Posted 2007) [#5]
Hi shifty,

Have you checked the FastImage and FastText libraries?! Haven't used them myself yet, but they seem to blow everybody's socks off when it comes to massively improved performace... Must check:

FastImage: http://www.blitzbasic.com/Community/posts.php?topic=66995

FastText: http://www.blitzbasic.com/Community/posts.php?topic=68216

Danny


Shifty Geezer(Posted 2007) [#6]
That is SOOOOOO awesome! Thanks for the heads-up Danny. And huge thanks to MixailV for creating and releasing.

Seeing all those sprites, it was finally like seeing the Amiga all over again! Smooth 2D shapes and blends. Blend modes too! This is the best thing to happen to Blitz3D for ages.


Danny(Posted 2007) [#7]
ya man! :)

Let me know when you got some proper sine-scrollers working ;)