[SDL] What is SDL RLE acceleration ???
William Kendrick
nbs at sonic.net
Sat Jun 17 15:14:27 PDT 2000
>
> Hello!!!!
>
> What the SDL RLE acceleration does???
RLE accelleration is used when using a colorkey (that is, when you pick
a particular color in your surface that you wish to be transparent...
it's like the transparency capabilities of GIF images).
RLE (Run-Length-Encoding) is a way of compressing data so that repeats
are made smaller. For example, if you had an image that looked like this:
--------
--####--
-######-
-######-
--####--
--------
("-" is white and "#" is black)
Instead of saying "white," "white, white, white, white, white," ...
"white, white, black, black, black, black, white, white....", etc.,
(storing each and every pixel)...
the RLE version would say "10 whites, 4 blacks, 3 whites, 6 blacks,
2 whites, 6 blacks, 3 whites, 4 blacks, 10 whites," which in many cases
would save lots of space in a file.
How this works in SDL when doing colorkey blitting is by replacing this
kind of code:
if (pixel != the_transparent_color)
draw_pixel(...);
which would result in "width * height" 'if' comparisons, the RLE blitting
speeds this up by using memcpy() to copy chunks of non-transparent pixels
all at once (much in the way that an SDL_BlitSurface() works when dealing
with an image that does NOT have a colorkey)
Whew.. Hope that made sense..
-bill!
(who's distracted by what's going on in the living room :) )
More information about the SDL
mailing list