获得色彩(像素)的信息onTouch(安卓) [英] Get Color(Pixel) information on onTouch (Android)
本文介绍了获得色彩(像素)的信息onTouch(安卓)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法让一个像素的颜色表示(X,Y),并检查它的红色,如果是红色的,然后送触摸事件。
Is there a way to get color of a pixel say (x,y) and check if its red and if it is red then send a touch event.
我希望它在后台运行,它应始终检查像素(X,Y)的颜色,只要它变为红色,触摸事件进行仿真。
I want it to run in background and it should always be checking the color of that pixel (x,y) and as soon as it turns red , a touch event should be simulated.
推荐答案
您可以从下面的例子中得到的值。
You can get values from the following example.
final Bitmap bitmap = ((BitmapDrawable)imageView.getDrawable()).getBitmap();
imageView.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event){
int x = (int)event.getX();
int y = (int)event.getY();
int pixel = bitmap.getPixel(x,y);
int red = Color.red(pixel);
int blue = Color.blue(pixel);
int green = Color.green(pixel);
return false;
}
});
这篇关于获得色彩(像素)的信息onTouch(安卓)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文