title: BitmapFactory.decode method returning null
body: <p>I'm using this code to get the bitmap placed inside the ImageView]</p>
  
  <pre><code>    private Bitmap getBitmap(ImageView imageView) {
            imageView.setDrawingCacheEnabled(true);
  
            imageView.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), 
                                  MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
            imageView.layout(0, 0, imageView.getMeasuredWidth(), imageView.getMeasuredHeight()); 
  
            imageView.buildDrawingCache(true);
            Bitmap b = Bitmap.createBitmap(imageView.getDrawingCache());
                imageView.setDrawingCacheEnabled(false);
                      return b;
                  }});
  </code></pre>
  
  <p>and this code to save it to the database in the form of a byte array</p>
  
  <pre><code> public byte[] convertToBytes(Bitmap image) {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      image.compress(Bitmap.CompressFormat.JPEG, 100, baos);
      byte[] imageBytes = baos.toByteArray();
      Log.d("IMAGE BYTE IS ", imageBytes.toString());
      return imageBytes;
  }
  </code></pre>
  
  <p>Decoding the image using this code to redisplay it returns null</p>
  
  <pre><code> public Bitmap convertToImage(byte[] bytes) {
  
      ByteArrayInputStream imageStream = new ByteArrayInputStream(bytes);
      return BitmapFactory.decodeStream(imageStream);
  }
  </code></pre>
  
  <p>I have logged the byte array before inserting and after retrieving and they both return the same values. Where did it go wrong?</p>