Alpha and gamma

It appears to me that SDL does alpha blending without
concern for gamma. If so, this is a bug. Alpha blending
may only be done with linear light (gamma==1.0) data.

This shows up as ugly dark edges around objects that
are blitted with fuzzy edges, and as semi-transparent
objects being too dark. Try light grey with dark grey.

The SDL function for adjusting gamma is rather useless
for fixing this, for two reasons:

  1. it doesn’t work with all video drivers
  2. for good looks, gamma==1.0 needs at least 10 bits/channel

Gamma adjustment using a 12-bit lookup table seems to
go pretty fast, even when using floating point for the
linear data.

So… how about having SDL handle this stuff better?

The SDL function for adjusting gamma is rather useless
for fixing this, for two reasons:

  1. it doesn’t work with all video drivers
  2. for good looks, gamma==1.0 needs at least 10 bits/channel

SDL just plugs into the underlying video API for gamma settings.

Gamma adjustment using a 12-bit lookup table seems to
go pretty fast, even when using floating point for the
linear data.

So… how about having SDL handle this stuff better?

Do you have a proposed patch?

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment