title: Android: How to get pixels of a single channel 16bit PNG Bitmap
body: <p>I have a png file created with python PIL that contains an height map (positive values).</p>
  
  <p>The format is : single channel (grey level) at 16bit, thus 16 bit per pixel.</p>
  
  <p>I read the file on android with <code>BitmapFactory.decodeStream(&lt;...data input stream...&gt;);</code></p>
  
  <p>I correctly get the size of the image through <code>getWidth()</code> and <code>getHeight()</code>.</p>
  
  <p>However when I loop though the pixels calling the <code>getPixel(i,j)</code> I obtain negative values, something like:  -16776192 -16250872 -16250872 -16250872 -16250872 -16249848 ....</p>
  
  <p>Instead I expect a positive value between 0 and 65535.</p>
  
  <p>I discover that the value -16250872 in binary is 1111111111111111111111111111111111111111000010000000100000001000</p>
  
  <p>This shows that the information relies on the first 16 least significant bits.</p>
  
  <p>I tryed with <code>getPixel(i,j)&amp;0xffff</code> and I obtain a plausible values, however I'm not sure about the endianess: should I to flip the 2 extracted bytes?</p>
  
  <p>Is there a way to do it in more elegant and portable way this conversion ?</p>
  
  <p>NOTE: the file is not a color (RGBA) PNG but a grey level PNG image with a single 16 bit value for each pixel.</p>