有没有办法让一个像素的颜色表示(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;
}
});