Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下颜色值 - 0xFFFF40、0xFFFF20、0xff5099。
我想将这些 C++ 代码转换为 RGB 值,我需要怎么做呢?
谢谢
编辑:我基本上想将这些值存储在 3 个不同的无符号短裤中:
unsigned short red; unsigned short green; unsigned short blue;
您可以通过单独屏蔽它们来获取每个通道:
// Original color std::size_t color = 0xFFFF40; std::size_t red = (color & 0xff0000) >> 16; std::size_t green = (color & 0x00ff00) >> 8; std::size_t blue = (color & 0x0000ff);