[SDL] Blitting on 8 bit surfaces

Sylvain Beucler beuc at beuc.net
Sat Dec 22 01:47:17 PST 2007


Hi,

On Sat, Dec 22, 2007 at 12:26:12AM +0100, Christian Meyer wrote:
> Hello!
> 
> I am working on a tool, that converts several graphic formats. Therefore 
> I am looking for informations about what the blitting of 8 bit surfaces 
> exactly does.
> It seems, that there are no informations about that on the net.
> 
> What is exactly happening with the colortables, when I blit a 8 bit 
> surface on an other 8 bit one?
> When the source surface contains a color that is not in the dest table, 
> is it automatically added? What happens when the dest color table whould 
> have more the 256 colors after a blit?
> Are the in indices of the source surface automatically changed to match 
> the dest color table?

In a 8bit->8bit blit (which I'm familiar with):
- source and destination palettes are left unchanged
- the blit uses the closest match color in the destination palette
- software (not hardware) palettes are used

The color matching is pretty simple and is done pixel by pixel; for
example, there's no dithering / Floyd-Steinberg.

If you want the blit to respect the color indices while not respecting
the colors, you can set the same palette to the source and destination
surfaces (with SDL_SetPalette(,SDL_LOGPAL,,,)).


> What happens, when the same color is more then once in the table?

I don't think this changes anything: the blit just chose the closest
color to the source color in the destination palette.

Cheers,

-- 
Sylvain


More information about the SDL mailing list