title: How to convert Image into Byte Array in Android
body: <p>I am facing one real issue. I need to convert image into <strong>byte array</strong> format, so that I can upload the byte array into web server. I have tried a lot however its not working. I am also getting negative values for byte array. I am not sure what i am doing wrong to take byte values in array. </p>
  
  <p>Below is my code. Please help me what i am doing wrong?</p>
  
  <pre><code>Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.home_menu_icon);
  ByteArrayOutputStream bos = new ByteArrayOutputStream();
  bmp.compress(Bitmap.CompressFormat.JPEG, 100, bos);
  byte[] data = bos.toByteArray();
  </code></pre>