title: Android Invert a Bitmap at Runtime
body: <p>I am trying to invert a bitmap by using a Paint ColorFilter
  I used this link as a reference:
  <a href="http://www.mail-archive.com/android-developers@googlegroups.com/msg47520.html" rel="nofollow noreferrer">http://www.mail-archive.com/android-developers@googlegroups.com/msg47520.html</a></p>
  <p>but it has absolutely no effect - bitmap is drawn normally can you tell me what I'm doing incorrectly?</p>
  <p>Define float array:</p>
  <pre><code>float invert [] = { 
          -1.0f,  0.0f,  0.0f,  1.0f,  0.0f, 
          0.0f,  -1.0f,  0.0f,  1.0f,  0.0f, 
          0.0f,  0.0f,  -1.0f,  1.0f,  0.0f, 
          1.0f,  1.0f,  1.0f,  1.0f,  0.0f 
  }; 
  </code></pre>
  <p>Setup Paint in constructor</p>
  <pre><code>    ColorMatrix cm = new ColorMatrix(invert); 
      invertPaint.setColorFilter(new ColorMatrixColorFilter(cm)); 
      
  </code></pre>
  <p>Reference in Draw() method</p>
  <pre><code>c.drawBitmap(Bitmap, null, Screen, invertPaint);
  </code></pre>
  <p>EDIT: I was able to get it to work by having the paint assignment in the draw statement:</p>
  <pre><code>ColorMatrix cm = new ColorMatrix(invert); 
  invertPaint.setColorFilter(new ColorMatrixColorFilter(cm)); 
  c.drawBitmap(rm.getBitmap(DefaultKey), null, Screen, invertPaint);
  </code></pre>
  <p>but now it renders really slow (probably because its setting up a complicated matrix every single frame) ...is there a reason it works when it's in the same method?</p>
  <p>EDIT2:
  NEVERMIND!!! Lol, the issue was that I had two constructors and I was only configuring the colorfilter in one of them...the proccess is still very CPU intensive and causes framerate issues</p>