Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- imageView=(ImageView)findViewById(R.id.imageView);
- final Bitmap bitmap = ((BitmapDrawable)
- imageView.getDrawable()).getBitmap();
- imageView.setOnTouchListener(new View.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 redValue = Color.red(pixel);
- int greenValue = Color.green(pixel);
- int blueValue = Color.blue(pixel);
- // Toast.makeText(MainActivity.this,String.format("#%02x%02x%02x", redValue,
- greenValue, blueValue), Toast.LENGTH_LONG).show();
- Toast.makeText(MainActivity.this, "R= " + redValue + "G= " + greenValue +
- "B= " + blueValue, Toast.LENGTH_LONG).show();
- // Toast.makeText(MainActivity.this,""+x+"tY "+y,Toast.LENGTH_LONG).show();
- return false;
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement