Clipmask by palette index -- possible?

Hi,

just started converting my Xlib game “Rocks’n’Diamonds”
(http://www.artsoft.org/rocksndiamonds/) to SDL and directly
ran into the first problem: :wink:

In the current (non-SDL) version, I use my own PCX file loader
which returns two Pixmaps: one with the actual picture that has
the same depth as the X server’s display, and one with depth 1
that contains a clipmask for all pixels in the PCX image which
have an index != 0 (that means that the first color in the palette
is transparent, where all other colors should be actually drawn).

I can then use XSetClipMask, XSetClipOrigin and XCopyArea
to blit the non-transparent pixels to the destination (Pixmap or
Window).

SDL offers the function SDL_SetColorKey which seems to do
something similar with the one important exception: It takes a
color value (as 32-bit RGB value) and not the index of the color
in the color palette. If I would use this function, I would not only
set the color with palette index 0 to transparent (which is usually
black in my PCX images), but also those pixels which have the
same color but should be non-transparent.

Is there a solution for this in SDL which does not require
modification of the PCX images?
Or am I forced to use a filter to set color 0 to an unused color
to mark it later as the transparent pixel?

Thanks in advance!

Best regards,
Holger–
Holger.Schemel at mediaWays.net ++49 +5241 80-1438

Or am I forced to use a filter to set color 0 to an unused color
to mark it later as the transparent pixel?

Cyan is a commonly used color for this. :slight_smile:

See ya!
-Sam Lantinga (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec

Or am I forced to use a filter to set color 0 to an unused color
to mark it later as the transparent pixel?

That’s exactly what you have to do.

See ya!
-Sam Lantinga (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec

Holger Schemel wrote:

[snip]

Is there a solution for this in SDL which does not require
modification of the PCX images?

You could always write a blitter that uses the alpha mask bitmap to blit
the
color bitmap.–
~ Frank J. Ramsay
. . fjr at epsion.com
/ V \
/( )\ Any sufficiently advanced operating system is
^^_^^ indistinguishable from Linux.