Is there anyways to get the pixel value from ImageView
after the click the button
? I have done the digging and searching but most of the solution are using the method imageView.setOnTouchListener(new OnTouchListener()
.
But what I really want is get the pixel value after click on the button
. Any recommendation ?
Try -
private Bitmap bmp;
private int[][] rgbValues;
bmp = BitmapFactory.decodeResource(getResources(), R.drawable.four_colors);
//define the array size
rgbValues = new int[bmp.getWidth()][bmp.getHeight()];
for(int i=0; i < bmp.getWidth(); i++)
{
for(int j=0; j < bmp.getHeight(); j++)
{
rgbValues[i][j] = bmp.getPixel(i, j);
}
}
For full code go to this link.