Calling the sRGB to/from linear conversions "color space conversions"
is a bit misleading. The black point, white point, and primaries all
remain the same. It’s really a gamma conversion, using the special
gamma curve defined by the sRGB standard.
Yes, it is gamma correction, and therefore is a separate operation from
alpha blending. Not even vaguely related. Since the rest of what you are
talking about is all based on your confusing alpha blending and gamma
correction, it is time to drop this subject.
I’m not confused. Perhaps you are? I hope you don’t wish to
simply pretend this problem doesn’t exist. I know it’s ugly
to fix, but it looks ugly on the screen too.
Sorry, but you are seriously confused. You have combined to different
problems and therefore have a rather unique take on how to correct them.
First off, most of the problem with “dark edges” that are seeing is due
to software alpha blending that is not clamping colors components to the
range 0 to 255. The use of 1/256 means that you can get 256 as a result
of alpha blending and that wraps to zero. Which gives you very dark
colors.
The situation:
a. All alpha blending must be done with linear (gamma==1.0) data.
Any other use of alpha blending is a serious bug.
That is one way of looking at it. Another is that alpha blending is
defined to work over a linear space and therefore doesn’t know or care
about non-linear data.
b. All modern computer displays require non-linear (gamma!=1.0)
data by default; many are not configurable.
Which, of course, has nothing to do with alpha blending because alpha
blending is defined to work over a linear range.
The gamma problem is completely separate from the way alpha blending is
defined to work.
BTW, I have never encountered a display that “required” non-linear data.
Yes, it would not provide the correct color with out it, but so what,
they still worked. Also, it has been a long time since I have seen a
video card that did not support gamma correct on the output. It has been
nearly as long since I saw anyone actually configure the gamma
correction for a display.
I once worked with a man who could see Mach banding in a 24 bit color
display. I, personally, can not.
c. The vast majority of image files contain non-linear data.
That is an assertion on your part. I personally doubt that it is true.
But, there are certainly image files that have non-linear data in them.
If you want to use do alpha blending with them you are responsible for
converting them to linear form. That is, you need to apply the source
gamma to the image so that alpha blending will work.
Suppose I wish to do an alpha-blending blit to the screen.
In general, SDL is unable to correctly blit the image!
No, SDL correctly blits the image. If it isn’t correct, it is because
you have not correctly adjusted the image data before you did the
blit. If you have linearized the images and the result looks wrong
it is most likely because you have not correctly set the output gamma.
Various ways to deal with this:
a. Only use alpha==100% and alpha==0%.
b. sRGB->linear on file load, and linear->sRGB to the screen
(so all in-memory buffers are linear)
That is pretty much the only way to do it.
c. alpha blend operation gets built-in gamma conversion
The problem with that approach is that even if you did mangle the
software blitters in SDL to do the odd operations that you want done,
you would still not get the results you are asking for on systems that
are doing the blits using hardware blitters. Hardware blitters work
pretty much the way SDL’s software blitters work. Hardware blitters
usually get the 1/255 right and usually clamp the result properly (I say
usually because I have worked with some that did neither). But, they do
not try to do linearizion while doing alpha blending.
Good grief, you would have to provide a gamma table with each image to
get the results you want.
You can verify what I have said by reading any introductory text on
computer graphics.
Enough
Bob PendletonOn Sat, 2005-02-26 at 21:58 -0500, Albert Cahalan wrote:
On Sat, 2005-02-26 at 18:48 -0600, Bob Pendleton wrote:
On Sat, 2005-02-26 at 14:50 -0500, Albert Cahalan wrote:
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl