RLE and source rects?

i’m setting up some of my image resources. a question hit me
and i thought i’d do some preemptive questioning…

if i have an array of sprite animation images all in one
image and enable RLE transparency, will the surface work?

does SDL handle RLE correctly if i specify a arbitrary
source rectangle? perhaps should i stack the frames
vertically in the image?

thanks again, great newsgroup!

if i have an array of sprite animation images all in one
image and enable RLE transparency, will the surface work?

It will work, but clipping RLE surfaces is slower than clipping normal ones,
since the decoder has to work through the entire image and skip what
shouldn’t be drawn. In other words it is not a very good use of RLE.

You will get better blitting performance by splitting the images into
separate surfaces. If you prefer storing them as one big image on
disk, you can do the split when you load them into memory and convert
them to the display format.

if i have an array of sprite animation images all in one
image and enable RLE transparency, will the surface work?

It will work, but clipping RLE surfaces is slower than clipping normal ones,
since the decoder has to work through the entire image and skip what
shouldn’t be drawn. In other words it is not a very good use of RLE.

You will get better blitting performance by splitting the images into
separate surfaces. If you prefer storing them as one big image on
disk, you can do the split when you load them into memory and convert
them to the display format.

You can also split them by creating multiple individual surfaces with the
appropriate pitch and offset into the full image with
SDL_CreateRGBSurfaceFrom()

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

You can also split them by creating multiple individual surfaces with the
appropriate pitch and offset into the full image with
SDL_CreateRGBSurfaceFrom()

Since he probably wants to convert them to the screen format anyway this
is likely to be a detour

(Good thing you mentioned it btw, found an obscure memory leak in
SDL_RLEaccel.c. Thanks)