RGB (r, g, B) is a macro. In fact, what it does is (COLORREF) (BYTE) (r) | (WORD) (BYTE) (g) <8) | (DWORD) (BYTE) (B) <16 ))) Rgb (r, g, B) = An integer value = R + G *
256 + B * 255*256 COLORREF is a 32-bit integer value, which represents a color. You can Use RGB correspondence to initialize COLORREFIts definition is typedef DWORD. COLORREF;COLORREF variables can be assigned in two ways: ● The first COLORREF cf = RGB (,); ● the second CColorDialog colorDialog; COLORREF color; If (colorDialog. DoModal () = IDOK) { Color = colorDialog. GetColor (); }How can I retrieve the RGB component value from COLORREF using the color pairs in MFC? You can use the macro GetRValue GetGValue GetBValueTheir definition is as follows # define GetRValue (rgb) (BYTE) (rgb ))# Define GetGValue (rgb) (BYTE) (WORD) (rgb)> 8 ))# Define GetBValue (rgb) (BYTE) (rgb)> 16 ))
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.