Alpha bug

Hi!

Here’s a small example of the bug (attached)! It appears when loading a png, but
it doesn’t when I use a bmp. At least this is the case in my example. When I
remove the alpha channel from the png, it works.
Perhaps it’s a bug in SDL_image…

Hope this helps,

Karl.
-------------- next part --------------
A non-text attachment was scrubbed…
Name: bug.tar.gz
Type: application/x-gzip
Size: 24824 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20001108/d9154d6b/attachment.bin

Here’s a small example of the bug (attached)! It appears when loading a png, but
it doesn’t when I use a bmp. At least this is the case in my example. When I
remove the alpha channel from the png, it works.

It’s a documented limitation: you can’t specify per-surface alpha for
a surface with alpha channel. Only the alpha channel will be used.

This has been up on the list before. If there’s enough demand, we could
add code to fix it, but it would either require an extra multiplication
(or perhaps a ‘min’ operation) between the two alpha values for each
pixel, or a recoding.

Exercise: Write a function MultiplyAlpha() that multiplies the alpha value
of each pixel in a surface by a given value. Use the format parameters
to make sure it works on all surface with alpha, and optimize the most
common cases. Tidy it up, write documentation, and add it to a library
of Useful Stuff.

“Mattias Engdeg?rd” wrote

Exercise: Write a function MultiplyAlpha() that multiplies the alpha value
of each pixel in a surface by a given value. Use the format parameters
to make sure it works on all surface with alpha, and optimize the most
common cases. Tidy it up, write documentation, and add it to a library
of Useful Stuff.

if someone does conjure a “MultiplyAlpha”, i’d be glad to see
it posted. shoudln’t be that hard, i’ve just got enough going
on am too lazy to attack it currently.

of course, a library of usefull stuff wouldn’t be too bad either :]

Here’s a small example of the bug (attached)! It appears when loading a png, but
it doesn’t when I use a bmp. At least this is the case in my example. When I
remove the alpha channel from the png, it works.

It’s a documented limitation: you can’t specify per-surface alpha for
a surface with alpha channel. Only the alpha channel will be used.
Ooops, sorry. I thought it was just the other way round, probably because this
was the case before the alpha flip.

This has been up on the list before. If there’s enough demand, we could
add code to fix it, but it would either require an extra multiplication
(or perhaps a ‘min’ operation) between the two alpha values for each
pixel, or a recoding.
I think this would be a good thing.

Bye, Karl.