简体   繁体   中英

Using printf to print a COLORREF type variable

我需要打印一个为COLORREF的变量。

A COLORREF is just an integer containing an RGB value. You can print a hex representation this way:

printf("%06X", color);

Note that the order of values is bbggrr , so it will look different from the usual rrggbb format.

You might also want to break it up into the individual RGB components:

printf("R: %i, G: %i, B: %i", GetRValue(color), GetGValue(color), GetBValue(color));

this would give you something like:

R: 255, G: 150, B: 75

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM