Convert from HEX color to RGB struct in C

前端 未结 5 1069
忘了有多久
忘了有多久 2020-12-15 11:07

How do you convert from color HEX code to RGB in pure C using C library only (without C++ or templates)? The RGB struct may be like this:



        
5条回答
  •  不思量自难忘°
    2020-12-15 11:40

    I guess RGB could be stored as 0xRRGGBB on some systems, but in Windows it is actually stored as 0xBBGGRR (see http://msdn.microsoft.com/en-us/library/windows/desktop/dd183449). As the article mentions, there are macros GetRValue, GetGValue, and GetBValue already available.

提交回复
热议问题