RGB转化int32数值

最近在做一个音箱的开发,其中涉及到了RGB转换int8-32数值,需求如红色部分:

 

 

RGB转化无符号int32数值

 //RGB颜色转换成int32位的数值,每8位分别保存一个RGB值,从右往左,第一个八位保存B值,第二个八位保存G值,第三个八位保存R值,第四个八位全为0
 int converRgbToRgb(int r,int g,int b){
        int color = ((0xFF << 24)|(r << 16)|(g << 8)|b);
        return color;
 }

 

无符号int32转化RGB数值

 void convertUintToARGB(int color) {
        int r = (color >> 16) & 0xFF;
        int g = (color >> 8) & 0xFF;
        int b = (color >> 0) & 0xFF;
        System.out.println(r+"::"+g+"::"+b);

    }

 

posted @ 2020-06-22 10:36  小炮先生  阅读(1837)  评论(0编辑  收藏  举报