Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » Alpha in Color
Alpha in Color [message #24807] |
Sat, 30 January 2010 23:08 |
andrei_natanael
Messages: 262 Registered: January 2009
|
Experienced Member |
|
|
Is there any reason why Color doesn't have alpha component? It have but it can't be set i.e. Color(255, 123, 223, 128).
Also if converting from RGBA to Color i think it loose color value if alpha is 0 (Color.cpp:76);
Color::Color(RGBA rgba)
{
if(rgba.a == 0)
color = 0xffffffff;
IMO it should preserve colors from rgba even if alpha is 0; I was doing conversion from QPixmap (from Qt) to Image (Upp) in some test for my graduation thesis and i liked the idea to be able to fill QPixmap with a "transparent" color.
|
|
|
Re: Alpha in Color [message #24815 is a reply to message #24807] |
Sun, 31 January 2010 13:36 |
|
mirek
Messages: 14039 Registered: November 2005
|
Ultimate Member |
|
|
andrei_natanael wrote on Sat, 30 January 2010 17:08 | Is there any reason why Color doesn't have alpha component? It have but it can't be set i.e. Color(255, 123, 223, 128).
Also if converting from RGBA to Color i think it loose color value if alpha is 0 (Color.cpp:76);
Color::Color(RGBA rgba)
{
if(rgba.a == 0)
color = 0xffffffff;
IMO it should preserve colors from rgba even if alpha is 0; I was doing conversion from QPixmap (from Qt) to Image (Upp) in some test for my graduation thesis and i liked the idea to be able to fill QPixmap with a "transparent" color.
|
I believe color is simply color. That is no notion of transparency in that term.
As for converting RGBA to Color, beware! RGBA is in premultiplied format, that in turn means that if alpha is 0, there is no color information that can possibly be extracted from RGBA. That is by definition. Correct RGBA should have R,G,B set to zero if alpha is zero. (Sidenote: We have not invented premultiplied RGBA, it is standard). Thus it seems quite logical to set Color to Null in that case.
Getting back to Color with alpha vs not, I guess both options have merits and drawbacks. All in all, I think that keeping both concepts separate causes very little problems. RGBA->Color and Color+alpha -> RGBA are simple.
In fact, as -> RGBA conversion is done using alpha * Color, it fits nicely with the concept of "premultiplication".
[Updated on: Sun, 31 January 2010 13:36] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sat Sep 21 03:48:35 CEST 2024
Total time taken to generate the page: 0.02569 seconds
|