Forced Window Placement (was New window / splash screen)

Speaking of this, is there something in SDL (that I’ve missed in my daily
study of the various SDL header files… printed out and being toted
around in my laptop case :wink: that allows the user to force the placement of
a window in your software (and is cross-platform)?

Heheh, this is in the Linux FAQ:
http://www.libsdl.org/faq/FAQ-Linux.html#LINUX_12

The same can be done for Windows, but I don’t have code offhand to do it.
If somebody writes an example, I’ll add it to the Win32 FAQ as well.

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

I couldn’t find any reference to this in the SDL Documentation, but I seem
to remember it being mentioned before.

Until now, I have only used 8-bit BMP’s that I converted to PNG. Now I am
using 24-bit PNG files and not having that palette of course killed my
color-key blitting.

How do you typically do RLE/transparent blitting with high-color surfaces
using SDL_SetColorKey()/ SDL_BlitSurface() ?

Of course, here is what I currently do for 8-bit images:

color_key = SDL_MapRGB(srcimg->format,0x00,0x00,0xFF);
SDL_SetColorKey(srcimg, SDL_SRCCOLORKEY|SDL_RLEACCEL,color_key);

Thanks,–
Brian Hayward

color_key = SDL_MapRGB(srcimg->format,0x00,0x00,0xFF);
SDL_SetColorKey(srcimg, SDL_SRCCOLORKEY|SDL_RLEACCEL,color_key);

That should still work for truecolor surfaces. If it doesn’t, it’s a
bug, and you should send a small code/image sample to me at @slouken

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

Until now, I have only used 8-bit BMP’s that I converted to PNG. Now I am
using 24-bit PNG files and not having that palette of course killed my
color-key blitting.

How do you typically do RLE/transparent blitting with high-color surfaces
using SDL_SetColorKey()/ SDL_BlitSurface() ?

Formats that support color keys (TGA, PNG, GIF) will set the colour key
automatically (in SDL_image 1.0.9 and later) to the “transparent” index
(the one you see as transparent when editing the image in Gimp, for
instance). This is normally restricted to 8-bit images. (PNG supports
colour keys for 24-bit images, and SDL_image contains (untested) code for
taking care of it, but I don’t know of any program that generates it.)

Of course, here is what I currently do for 8-bit images:

color_key = SDL_MapRGB(srcimg->format,0x00,0x00,0xFF);
SDL_SetColorKey(srcimg, SDL_SRCCOLORKEY|SDL_RLEACCEL,color_key);

That should still work very well. Remember to call SDL_SetColorKey before
you call SDL_DisplayFormat. And make certain you don’t use that colour
elsewhere! Note that the 24->16bpp conversion is not one-to-one, so the
colour key should be distinct.

If you find the alpha channel convenient for editing and storing images
but don’t want the slowdown, you can easily convert it to a colour key
using something like

for (x, y) in image
if pixel(x, y) has transparent alpha
set_pixel(x, y, colour_key)
else if pixel(x, y) == colour_key
set_pixel(x, y, ersatz)

With the colour key #ff00ff the ersatz can be, say, #f700f7.