title: Android - Get Color From ImageView with ColorFIlter Applied to Drawable
body: <p>I'm trying to get the color of an ImageView within a GridView that I've applied a color filter too previously.  I'm running on a Nexus 4 with 4.2.2</p>
  
  <p>I'm altering the color of the ImageView like this.  The actual color of the image is white before I apply a filter.</p>
  
  <pre><code>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));
  </code></pre>
  
  <p>Now this doesn't actually alter the source images color which is what I want.  That always remains white.</p>
  
  <p>My problem is I'm trying to reference the color well after I've lost the data I used to set it.  I want to long press on the ImageView and get its color.</p>
  
  <p>I found some code at the below question, but it doesn't appear to work as it always returns white (255,255,255), which IS the color of the original image, but not the filter. <a href="https://stackoverflow.com/questions/7807360/how-to-get-pixel-colour-in-android">How to Get Pixel Colour in Android?</a></p>
  
  <pre><code>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);
  </code></pre>
  
  <p>I've tried stuff like the below, but it just crashes when I call getColorFilter.</p>
  
  <pre><code>ImageView image = (ImageView)findViewById(R.drawable.bufferbuildercolor3);
  ColorFilter test = image.getColorFilter();
  </code></pre>
  
  <p>I'm not sure what else to do, except maybe find the X/Y of the actual grid position, and then get the screens background color at that point rather than the images.  It seems like there should be an easier way to do this though?</p>