【发布时间】:2019-02-08 10:25:39
【问题描述】:
我正在使用OnTouchListener 从ImageView 中获取颜色。
红、绿、蓝三色码可以成功获取,但是无法将RGB转HEX..
示例:我的 rgb 值是
r:21
b:16
g:228
对应的十六进制颜色是#15e410。
我想要#15e410。从 r:21 ,b:16 ,g:228
int pixel = bitmap.getPixel(x,y);
int redValue = Color.red(pixel);
int blueValue = Color.blue(pixel);
int greenValue = Color.green(pixel);
int hexa= Color.rgb(redValue, greenValue, blueValue);
Toast.makeText(getApplicationContext(),"hexa ::"+hexa ,Toast.LENGTH_LONG).show();
【问题讨论】:
-
redValue+greenValue+blueValue没有意义 -
我该如何解决?
-
String.format("#%06X", pixel)?