【发布时间】:2015-03-08 07:50:16
【问题描述】:
我的代码只能在图像上的触摸像素上提供十六进制代码。 现在我也想给出颜色的名称。 这怎么可能使用Android?请提出一种方法。
public boolean onTouch(View v, MotionEvent event) {
// get x coordinates
int x = (int) event.getX();
// get y coordinates
int y = (int) event.getY();
// get bitmap in touch listener
final Bitmap bitmap = ((BitmapDrawable) image.getDrawable()).getBitmap();
//xand y coordinates stored in to pixel
int pixel = bitmap.getPixel(x, y);
//RGB values
redValue = Color.red(pixel);
blueValue = Color.blue(pixel);
greenValue = Color.green(pixel);
selected_colour.setText(""+redValue+""+blueValue+""+greenValue);
selected_colour.setText("touched color:" + "#" + Integer.toHexString(redValue) + Integer.toHexString(greenValue) + Integer.toHexString(blueValue));
selected_colour.setTextColor(pixel);
return false;
}
});
【问题讨论】:
-
有
16777215不同的十六进制颜色代码。我怀疑有足够的颜色名称来命名所有这些。 -
是的,但我必须尽可能多地添加..
-
android 中是否有任何库返回十六进制颜色代码的颜色名称?
标签: android image-processing color-picker