首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >C++获取RGB单个值的数据

C++获取RGB单个值的数据

作者头像
ClearSeve
发布2022-02-10 19:00:15
发布2022-02-10 19:00:15
2.4K0
举报
文章被收录于专栏:ClearSeveClearSeve
代码语言:javascript
复制
int nRGBValue = 15391129;

// 方式一
int blueMask = 0xFF0000, greenMask = 0xFF00, redMask = 0xFF;
int r1 = nRGBValue & redMask;
int g1 = (nRGBValue & greenMask) >> 8;
int b1 = (nRGBValue & blueMask) >> 16;

// 方式二
int r2 = nRGBValue & 0xFF;
int g2 = (nRGBValue >> 8)  & 0xFF;
int b2 = (nRGBValue >> 16)  & 0xFF;

// 方式三
int r3 = GetRValue(nRGBValue);
int g3 = GetGValue(nRGBValue);
int b3 = GetBValue(nRGBValue);
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022年1月21日,如有侵权请联系 cloudcommunity@tencent.com 删除
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档