title: Android : some problems when converting drawable image to byte array
body: <p>I want to convert an image in my app to a Base64 encoded string. This image may be of any type like jpeg, png etc. </p>
  
  <p>What I have done is, I converted the drawable to a Bitmap. Then I converted this Bitmap to ByteArrayOutputStream using compress metheod And I am converting this ByteArrayOutputStream to byte array. And then I am encoding it to Base64 using encodeToString().</p>
  
  <p>I can display the image using the above method if the image is of PNG or JPEG. </p>
  
  <pre><code>ByteArrayOutputStream objByteOutput = new ByteArrayOutputStream();
   imgBitmap.compress(CompressFormat.JPEG, 0, objByteOutput);
  </code></pre>
  
  <p>But the problem is if the image is in any other types than PNG or JPEG, how can I display the image?</p>
  
  <p>Or please suggest me some another method to get byte array from Bitmap.</p>
  
  <p>Thank you...</p>