color资源文件:
<color name="red">#ffff5454</color>
代码:int color = Resources.getColor(getResources().Color.red);
// how to get paramArrayOfFloat from color?
ColorMatrix localColorMatrix = new ColorMatrix();
localColorMatrix.setSaturation(0.0F);
localColorMatrix.set(paramArrayOfFloat);
如何从色号中得到paramArrayOfFloat
?我想把数字转换成浮点数。这在android中可能吗?
ColorMatrix:
4x5矩阵,用于转换位图的颜色+alpha分量。矩阵存储在单个数组中,其处理如下:[a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s t]应用于颜色[r, g, b, a],结果颜色计算为(装夹后)R' = a*R + b*G + c* b + d* a + e;G' = f*R + G *G + h*B+ i*A + j;B' = k*R + l*G + m*B + n*A + 0;A' = p*R + q*G + R *B + s*A + t;
For red color -
float[] colorTransform = {
0, 1f, 0, 0, 0,
0, 0, 0f, 0, 0,
0, 0, 0, 0f, 0,
0, 0, 0, 1f, 0};
ColorMatrix localColorMatrix = new ColorMatrix();
localColorMatrix.setSaturation(0.0F); //Remove Colour
localColorMatrix.set(colorTransform); //Apply Red say
查看更多信息:ColorMatrixSample和ColorMatrix.
注意:
您可以查看conver- a-web-color to-an-rgb-float-array-for-after-effects的链接