Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » Alpha in Color
Re: Alpha in Color [message #24815 is a reply to message #24807] Sun, 31 January 2010 13:36 Go to previous message
mirek is currently offline  mirek
Messages: 13975
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

 
Read Message
Read Message
Previous Topic: Painter.DrawImage bug
Next Topic: Crash when loading images into 64bit exes
Goto Forum:
  


Current Time: Fri Mar 29 08:32:05 CET 2024

Total time taken to generate the page: 0.01680 seconds