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 » Should RGBA have got 4 arguments constructor?
Re: Should RGBA have got 4 arguments constructor? [message #43178 is a reply to message #43080] Thu, 29 May 2014 11:18 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14257
Registered: November 2005
Ultimate Member
According to C++03 rules, adding constructor would make RGBA non-POD, which has implications on what operations are legal with it.

Furthermore, the issue is tricky, because the standard format is premultiplied, so e.g.

RGBA(0, 255, 0, 128)

would be wrong if constructor would just assign numbers to respective fields.

RGBA rgba = Color(255, 0, 0);
rgba.a = 255;


No need to set .a here, it is automatically set to 255.

Note that there is also operator* to add alpha to Color:

RGBA x = 128 * Red(); // Sets Red with alpha = 128

[Updated on: Thu, 29 May 2014 11:18]

Report message to a moderator

 
Read Message icon5.gif
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Drawing performance issue
Next Topic: Painter and viewports
Goto Forum:
  


Current Time: Tue May 13 01:38:59 CEST 2025

Total time taken to generate the page: 0.03684 seconds