code: public synchronized static Bitmap load(InputStream is, int width, int height) {
          BitmapFactory.Options opt = null;
          try {
              opt = new BitmapFactory.Options();
              if (width > 0 && height > 0) {
                  if (is.markSupported()) {
                      is.mark(is.available());
  
                      opt.inJustDecodeBounds = true;
                      BitmapFactory.decodeStream(is, null, opt);
                      opt.inSampleSize = calculateInSampleSize(opt, width, height);
                      is.reset();
                  }
              }
  
              opt.inJustDecodeBounds = false;
              opt.inPurgeable = true;
              opt.inInputShareable = true;
  
              return BitmapFactory.decodeStream(new FlushedInputStream(is), null, opt);
          } catch (Exception e) {
              Log.e(TAG, "", e);
              return null;
          } finally {
              if (is != null) {
                  try {
                      is.close();
                  } catch (IOException e) {
                      System.out.print(e.toString());
                  }
              }
              opt = null;
          }
      }
docs: BitmapFactory fails to decode the InputStream.