转自:http://hxluo.blog.163.com/blog/static/1966022762013111766216/,感谢这位作者,因为在java代码当中利用调色板得到的是一串十六进制的,需要传入到js代码中,使用RGB的颜色值,找到如下文章:
首先ARGB区别于RGB的地方就是RGB色彩模式附加上Alpha(透明度)通道,常见于32位位图的存储结构。
同样可以~
RGB编码格式如下:
RGB | Red | Green | Blue |
共24bit | 16-24bit | 8-15bit | 0-7bit |
而ARGB则在RGB的基础上加了一个透明的通道
ARGB的编码格式:
ARGB | Alpha | Red | Green | Blue |
共32bit | 25-32bit | 16-24bit | 8-15bit | 0-7bit |
怎么转化相信大家很清楚了。
这里贴一个方法:
Java Code
1
2 3 4 5 6 7 8 |
public
static
int[] getArgb(
int color){
final int a = (color >>> 24); final int r = (color >> 16) & 0xFF; final int g = (color >> 8) & 0xFF; final int b = (color) & 0xFF; return new int[]{ClippedColorPart(a), ClippedColorPart(r), ClippedColorPart(g), ClippedColorPart(b)}; } |
也可以调用color的方法:android.graphics.Color;包
Java Code
1
2 3 |
red = Color.red(newARGBColor);
green = Color.green(newARGBColor); blue = Color.blue(newARGBColor); |