title: Differences in reading bits from byte pointers
body: <p>I'm finding it difficult to understand the differences between the below code:</p>
  
  <pre><code>    auto pixel = static_cast&lt;uint32_t&gt;( D3DCOLOR_RGBA( r, g, b, a ) );
      auto components = (uint8_t*)&amp;pixel;
      std::array&lt;uint8_t, 4&gt; pixel_colours = { components[0], components[1], components[2], components[3] };
  
      uint8_t b_a = pixel &gt;&gt; 24;
      uint8_t b_r = ( pixel &gt;&gt; 16 ) &amp; 0xFF;
      uint8_t b_g = ( pixel &gt;&gt; 8 ) &amp; 0xFF;
      uint8_t b_b = pixel &amp; 0xFF;
  
      return static_cast&lt;uint32_t&gt;( D3DCOLOR_RGBA( r, g, b, a ) );
  </code></pre>
  
  <p>For r, g, b, a = { 255, 128, 64, 0 }, the value for pixel_colours is <code>{ 64, 128, 255, 0}</code> while b_a, b_r, b_g, b_b are <code>0, 255, 128, 64</code></p>
  
  <p>I don't understand why the differences are occurring - I expect them to be the same. Could someone explain?</p>