SDL currently isn’t too friendly when it comes to images with alpha.
First, there’s no intrinsic support for images with alpha, loading or
saving. SDL does support Windows BMP files, though, and I see three good
reasons why it should:
-
One of the early stated goals of SDL was to make it easy to port Win32
games to Linux. This goal has been reached, IMO. -
Small apps such as demos, tutorial programs, John’s book, etc, need a
good but simple way to get image data loaded without fuss so they can
focus on what’s important. -
Code bloat. The less stuff your program needs, the less that can go
wrong with any of that stuff. If you don’t really need to be able to
load lots of image formats, you’re best supporting one or two and
saving much headache later on.
The problem with BMP is that while it meets the first point better than
any other format could, the second and third points are only met if the
images loaded need no alpha channel. I’ve been told that it is possible
for BMP to support alpha, but nothing does. So SDL (1.3 most likely?)
should also support a format which does handle alpha.
The best format for this is Targa. As most of you probably know from
other rants I make … every couple months or so … I’m an OpenGL guy.
While alpha channels are not used very much outside of OpenGL programs,
they are just about standard issue in OpenGL. And the standard issue
format for images with alpha channels is Targa - not because it’s a nice
high-compression format. Not at all - it’s used because it’s dead simple
to parse when compared with the alternatives!
The problem with Targa is that the loader is not exactly short if it’s any
good. Targa supports storing the image basically any direction you want.
Top to bottom, bottom to top, right to left, all of the above with or
without RLE, and it happens to support paletted images with palettes
bigger than 256 colors.
Most loaders don’t even support RLE. Targa colormap (palette) support is
even more rare. And all too many loaders only support the image left to
right and bottom to top. Basically, even though the format is as simple
as it gets, the parsers are generally not up to spec. The closest one I
didn’t write seems to be the one in SDL_image. But SDL_image is generally
a big dependency to add to a small project, and doesn’t fit well into
things like demos and tutorial programs. Plus SDL_image doesn’t write any
format it can load. (In some cases, this is a good thing. XCF anyone?)
Anyway, it seems like a good idea to me for 1.3 at least. If combined
with some changes to SDL_DisplayFormat, it could result in SDL_Surface
being a reasonable format even for larger OpenGL programs to use. ;)–
Joseph Carter You expected a coherent reply?
There is no snooze button on a cat who wants breakfast.
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020426/c5f3053a/attachment.pgp