I am trying to get an ImageView color in a GridView that previously applied a color filter. I work on Nexus 4 with 4.2.2
I am changing the color of the ImageView as follows. The actual color of the image is white before applying the filter.
Drawable myIcon = getResources().getDrawable(R.drawable.bufferbuildercolor3); myIcon.setColorFilter(new PorterDuffColorFilter(Color.rgb(Color.red(color),Color.green(color), Color.blue(color)),PorterDuff.Mode.MULTIPLY));
Now this does not actually change the color of the source images that I want. It always stays white.
My problem is that I am trying to refer well to the color after I lost the data that I used to set it. I want to click on ImageView for a long time and get its color.
I found the code on the question below, but it does not work, because it always returns white (255,255,255), which is the color of the original image, but not the filter. How to get pixel color in Android?
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);
I tried things like below, but it just crashes when I call getColorFilter.
ImageView image = (ImageView)findViewById(R.drawable.bufferbuildercolor3); ColorFilter test = image.getColorFilter();
I'm not sure what else to do, except maybe finding the X / Y of the actual position of the grid, and then getting the background color of the screens at that point, not the image. There seems to be an easier way to do this though?