title: Confused about PixelFormat
body: <p>I'm confused about <a href="http://developer.android.com/reference/android/graphics/PixelFormat.html" rel="nofollow noreferrer">PixelFormat</a> on Android. </p>
  
  <p>My device is Motorola Defy.</p>
  
  <p>I have two questions:</p>
  
  <ul>
  <li>On Android 2.3 <code>getWindowManager().getDefaultDisplay().getPixelFormat()</code> returns <strong>4</strong> what stands for <a href="http://developer.android.com/reference/android/graphics/PixelFormat.html#RGB_565" rel="nofollow noreferrer">RGB_565</a>. As far as I know my device has <em>16M</em> colors, that means 3 (or 4 with alpha channel) bytes per pixel:</li>
  </ul>
  
  <blockquote>
  <pre><code>                2^(8*3) = 2^24 = 16M
  </code></pre>
  </blockquote>
  
  <p>But <code>RGB_565</code> format has 2 bytes (16 bits) per pixel, what stands for <em>65K</em> colors:</p>
  
  <blockquote>
  <pre><code>                2^(8*2) = 2^16 = 65K
  </code></pre>
  </blockquote>
  
  <p>So, why <code>getPixelFormat()</code> doesn't return format with 3 (or 4 like RGBA) bytes per pixel? Is it display driver problems or something? Can I set <code>PixelFormat</code> to <a href="http://developer.android.com/reference/android/graphics/PixelFormat.html#RGBA_8888" rel="nofollow noreferrer">RGBA_8888</a> (or analogue)?</p>
  
  <ul>
  <li>On Android 4.1 (custom rom), <code>getPixelFormat()</code> returns <strong>5</strong>. But this value is undocumented. What does it stand for? Actually, in this situation effect is the same as with constant <code>4</code>. But from <a href="http://community.developer.motorola.com/t5/Android-App-Development-for/Android-Milestone-A853-getPixelFormat/td-p/8580" rel="nofollow noreferrer">this discussion</a> I found that <strong>5</strong> stands for <code>RGBA_8888</code> (but there is no proof for that statement). So how can I figure out the <em>real</em> format of device's screen? Also I found one Chinese device on Android 2.2, that also has <code>PixelFormat</code> <strong>5</strong>, but the real format is <strong>4</strong> (as my Motorola).</li>
  </ul>
  
  <p>I have googled these questions and found nothing. The only thing I found is that <a href="https://stackoverflow.com/questions/8829943/how-to-find-the-best-pixelformat-for-an-android-surfaceview">nexus 7  also has 5 format</a>.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>I found method <a href="http://developer.android.com/reference/android/view/Window.html#setFormat%28int%29" rel="nofollow noreferrer"><code>getWindow().setFormat()</code></a> but it actually does not change main pixel format.</p>