Extract by clicking an image area in Android

I am working on a Quiz app and am doing this for normal questions to be shown in my TextView. Next, I need to show the user an image (maybe find the difference between the two images OR find the letters hidden in the image) and for that the user needs to click on some area of ​​the image.

How can I get the point where the user clicked on the image.

+3


source to share


2 answers


bool imagesAreEqual(Image i1, Image i2)
{
    if (i1.getHeight() != i2.getHeight()) return false;
    if (i1.getWidth() != i2.getWidth()) return false;

    for (int y = 0; y < i1.getHeight(); ++y)
       for (int x = 0; x < i1.getWidth(); ++x)
            if (i1.getPixel(x, y) != i2.getPixel(x, y)) return false;

    return true;
}

      

It compares each pixel and returns a boolean if they are equal.



Refer to below thread, compare two images in android

+1


source


you can try something like

to get the point where the user clicked



imageView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN){
                Log.e("Touch coordinates : " + String.valueOf(event.getX()) + "x" + String.valueOf(event.getY()));
            }
            return true;
        }
});

      

you can follow this link to check diff between images (COLOR and PICKEL) https://rosettacode.org/wiki/Percentage_difference_between_images  and also   compare two images in android

0


source







All Articles