0

Is it possible to detect on color touch with Bitmap on 'Android'?

The screen will look like this:

enter image description here

The black arrow is the Bitmap object that user can move up and down. It should detect when black arrow is touching the blue line and add points for each second that it has touched the line.

Maybe it is worth noting that arrow can be only moved up and down and the blue lines are what are moving from right to left.

There is a wierd background and the background may contain blue since it will be a camera preview screen and the Canvas where the arrow and the blue line are moving will be transparent. Will that be an issue or is there maybe a better way to detect collision?

The most important part that I need here is to detect 'collision' or weather the bitmap and the line are touching or not but the second part of the question would be, is there a way to add an animation or something that would show the user that the lines are touching, maybe chaing the arrow for a golden one or something.

The line is made with 'GraphView' and thus I can not really treat that as an 'object'. More about graphview - http://www.android-graphview.org/

If there is any need for source code then I can provide that but I'd rather not share it right off the bat.

EDIT I have tried using Pixels and detecting color that way but I have not gotten it to work.

Richard
  • 1,087
  • 18
  • 52

1 Answers1

2

For a given pixel, x and y:

ImageView imageView = (ImageView)v;
Bitmap bitmap = ((BitmapDrawable)imageView.getDrawable()).getBitmap();
int pixel = bitmap.getPixel(x,y);

int redValue = Color.red(pixel);
int blueValue = Color.blue(pixel);
int greenValue = Color.green(pixel);

Reference here.

RonTLV
  • 2,376
  • 2
  • 24
  • 38
  • Thank you for your answer, I do not think that this can be done with pixel color detection but it gave me some ideas that I will try. – Richard Jun 05 '18 at 16:46