public static Bitmap decodeSampledBitmapFromByte(byte[] data) {
    final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeByteArray(data, 0, data.length, options);

    final int screenWidth = SystemUtils.getScreenWidth();
    final int screenHeight = SystemUtils.getScreenHeight();
    float reqWidth = screenWidth;
    float reqHeight = screenHeight;
    if (reqWidth > options.outWidth)
      reqHeight = reqWidth * 1.0f / options.outWidth * options.outHeight;

    if (reqHeight > 3000) reqHeight = 3000;

    return decodeSampledBitmapFromByte(data, (int) reqWidth, (int) reqHeight);
  }
  public static Bitmap decodeSampledBitmapFromDescriptor(FileDescriptor fileDescriptor) {
    final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options);

    final int screenWidth = SystemUtils.getScreenWidth();
    final int screenHeight = SystemUtils.getScreenHeight();
    float reqWidth = screenWidth * 1.5f;
    float reqHeight = screenHeight;
    if (reqWidth > options.outWidth)
      reqHeight = reqWidth * 1.0f / options.outWidth * options.outHeight;

    if (reqHeight > 3000) reqHeight = 3000;

    return decodeSampledBitmapFromDescriptor(fileDescriptor, (int) reqWidth, (int) reqHeight);
  }