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 に保存したいと思います:
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);