Click here to Skip to main content
15,887,962 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an app that uses opencv to detect colors. I placed some code that should detect the color of the pixel touched, to my understanding, but it instead makes the app crash.
How can I fix this issue?
Thanks in advance.

What I have tried:

ImageView imageView = ((ImageView)view);
        final Bitmap bitmap = ((BitmapDrawable)imageView.getDrawable()).getBitmap();
        int px=(int)motionEvent.getX();
        int py=(int)motionEvent.getY();
        int pixel = bitmap.getPixel(px,py);
        red=Color.red(pixel);
        green=Color.green(pixel);
        blue=Color.blue(pixel);
Posted
Comments
David Crow 10-Mar-18 22:15pm    
"...but it instead makes the app crash.
How can I fix this issue?"

I see no error detecting, or try/catch blocks. Is that intentional? What exception is being thrown?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900