title: Fast algorithm to invert an ARGB color value to ABGR?
body: <p>I'm using <code>IntBuffer</code> to manipulate pixels of a Bitmap, but the value in the buffer should be <strong>AABBGGRR</strong>, while the color constants are <strong>AARRGGBB</strong>. I know I can use <code>Color.argb</code>, <code>Color.a</code>, ... to invert, but I think it's not perfect.</p>
  
  <p>I need to manipulate a very large number of pixels, so I need an algorithm that can perform this operator in short time. I think of this Bit Expression, but it's not correct:</p>
  
  <pre><code>0xFFFFFFFF ^ pSourceColor
  </code></pre>
  
  <p>If there's no better one, maybe I will use bit-shift operators (that performs <code>Color.a</code>, ...) instead of calling the functions to reduce the time.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>This is my current function to convert, though I think there shoul be a better algorithm (less operators) to perform it:</p>
  
  <pre><code>private int getBufferedColor(final int pSourceColor) {
      return
              ((pSourceColor &gt;&gt; 24) &lt;&lt; 24) |          // Alpha
              ((pSourceColor &gt;&gt; 16) &amp; 0xFF) |         // Red  -&gt; Blue
              ((pSourceColor &gt;&gt; 8) &amp; 0xFF) &lt;&lt; 8 |     // Green
              ((pSourceColor) &amp; 0xFF) &lt;&lt; 16;          // Blue -&gt; Red
  }
  </code></pre>