title: Trying to understand Bitmap.Config.ARBG_8888
body: <p>I'm trying to understand packing of color bytes for ARGB_8888 format.</p>
  
  <p>The <a href="https://developer.android.com/reference/android/graphics/Bitmap.Config.html#ARGB_8888" rel="nofollow noreferrer">documentation</a> states that packing should be done using this formula:</p>
  
  <pre><code>int color = (A &amp; 0xff) &lt;&lt; 24 | (B &amp; 0xff) &lt;&lt; 16 | (G &amp; 0xff) &lt;&lt; 8 | (R &amp; 0xff);
  </code></pre>
  
  <p>But shouldn't it be instead:</p>
  
  <pre><code>int color = (A &amp; 0xff) &lt;&lt; 24 | (R &amp; 0xff) &lt;&lt; 16 | (G &amp; 0xff) &lt;&lt; 8 | (B &amp; 0xff);
  </code></pre>
  
  <p>When I unpack a sample pixel from a ARGB_8888 color encoded bitmap that has all red pixels, I'm using:</p>
  
  <pre><code>    final int r = (p &gt;&gt; 16) &amp; 0xff;
      final int g = (p &gt;&gt; 8) &amp; 0xff;
      final int b = p &amp; 0xff;
  </code></pre>
  
  <p>Which indeed returns me correct values for every color. </p>
  
  <p>My point is, is it the documentation wrong or I'm missing something?</p>