Example usage for android.graphics Bitmap createScaledBitmap

List of usage examples for android.graphics Bitmap createScaledBitmap

Introduction

In this page you can find the example usage for android.graphics Bitmap createScaledBitmap.

Prototype

public static Bitmap createScaledBitmap(@NonNull Bitmap src, int dstWidth, int dstHeight, boolean filter) 

Source Link

Document

Creates a new bitmap, scaled from an existing bitmap, when possible.

Usage

From source file:org.amahi.anywhere.service.AudioService.java

private Bitmap getAudioPlayerNotificationArtwork(Bitmap audioAlbumArt) {
    int iconHeight = (int) getResources().getDimension(android.R.dimen.notification_large_icon_height);
    int iconWidth = (int) getResources().getDimension(android.R.dimen.notification_large_icon_width);

    if (audioAlbumArt == null) {
        return null;
    }//from   w w w  . j a  va 2  s  . c o m

    return Bitmap.createScaledBitmap(audioAlbumArt, iconWidth, iconHeight, false);
}

From source file:com.example.kuassivi.material_avatar.feature.ChooseAvatarActivity.java

/**
 * This method updates the shared view we use on the material transition
 *
 * @param bitmap Bitmap/*from   w w w  .  j  a va 2s . co m*/
 */
private void updateSharedAvatarView(Bitmap bitmap) {
    Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, sharedAvatarSize, sharedAvatarSize, true);
    CircleTransform circleTransform = new CircleTransform();
    mSharedAvatarView
            .setBackground(new BitmapDrawable(getResources(), circleTransform.transform(scaledBitmap)));
}

From source file:com.layer.atlas.Atlas.java

/**
 * @param imageFile   - to create a preview of
 * @param layerClient - required to create {@link MessagePart} 
 * @param tempDir     - required to store preview file until it is picked by LayerClient
 * @return MessagePart[] {previewBytes, json_with_dimensions} or null if preview cannot be built
 *///from www. ja  va2  s  .  c  o  m
public static MessagePart[] buildPreviewAndSize(final File imageFile, final LayerClient layerClient,
        File tempDir) throws IOException {
    if (imageFile == null)
        throw new IllegalArgumentException("imageFile cannot be null");
    if (layerClient == null)
        throw new IllegalArgumentException("layerClient cannot be null");
    if (tempDir == null)
        throw new IllegalArgumentException("tempDir cannot be null");
    if (!tempDir.exists())
        throw new IllegalArgumentException("tempDir doesn't exist");
    if (!tempDir.isDirectory())
        throw new IllegalArgumentException("tempDir must be a directory");

    // prepare preview
    BitmapFactory.Options optOriginal = new BitmapFactory.Options();
    optOriginal.inJustDecodeBounds = true;
    //BitmapFactory.decodeFile(photoFile.getAbsolutePath(), optOriginal);
    BitmapFactory.decodeStream(new FileInputStream(imageFile), null, optOriginal);
    if (debug)
        Log.w(TAG, "buildPreviewAndSize() original: " + optOriginal.outWidth + "x" + optOriginal.outHeight);
    int previewWidthMax = 512;
    int previewHeightMax = 512;
    int previewWidth;
    int previewHeight;
    int sampleSize;
    if (optOriginal.outWidth > optOriginal.outHeight) {
        sampleSize = optOriginal.outWidth / previewWidthMax;
        previewWidth = previewWidthMax;
        previewHeight = (int) (1.0 * previewWidth * optOriginal.outHeight / optOriginal.outWidth);
        if (debug)
            Log.w(TAG, "buildPreviewAndSize() sampleSize: " + sampleSize + ", orig: " + optOriginal.outWidth
                    + "x" + optOriginal.outHeight + ", preview: " + previewWidth + "x" + previewHeight);
    } else {
        sampleSize = optOriginal.outHeight / previewHeightMax;
        previewHeight = previewHeightMax;
        previewWidth = (int) (1.0 * previewHeight * optOriginal.outWidth / optOriginal.outHeight);
        if (debug)
            Log.w(TAG, "buildPreviewAndSize() sampleSize: " + sampleSize + ", orig: " + optOriginal.outWidth
                    + "x" + optOriginal.outHeight + ", preview: " + previewWidth + "x" + previewHeight);
    }

    BitmapFactory.Options optsPreview = new BitmapFactory.Options();
    optsPreview.inSampleSize = sampleSize;
    //Bitmap decodedBmp = BitmapFactory.decodeFile(photoFile.getAbsolutePath(), optsPreview);
    Bitmap decodedBmp = BitmapFactory.decodeStream(new FileInputStream(imageFile), null, optsPreview);
    if (decodedBmp == null) {
        if (debug)
            Log.w(TAG, "buildPreviewAndSize() taking photo, but photo file cannot be decoded: "
                    + imageFile.getPath());
        return null;
    }
    if (debug)
        Log.w(TAG, "buildPreviewAndSize() decoded bitmap: " + decodedBmp.getWidth() + "x"
                + decodedBmp.getHeight() + ", " + decodedBmp.getByteCount() + " bytes ");
    Bitmap bmp = Bitmap.createScaledBitmap(decodedBmp, previewWidth, previewHeight, false);
    if (debug)
        Log.w(TAG, "buildPreviewAndSize() preview bitmap: " + bmp.getWidth() + "x" + bmp.getHeight() + ", "
                + bmp.getByteCount() + " bytes ");

    String fileName = "atlasPreview" + System.currentTimeMillis() + ".jpg";
    final File previewFile = new File(tempDir, fileName);
    FileOutputStream fos = new FileOutputStream(previewFile);
    bmp.compress(Bitmap.CompressFormat.JPEG, 50, fos);
    fos.close();

    FileInputStream fisPreview = new FileInputStream(previewFile) {
        public void close() throws IOException {
            super.close();
            boolean deleted = previewFile.delete();
            if (debug)
                Log.w(TAG, "buildPreviewAndSize() preview file is" + (!deleted ? " not" : "") + " removed: "
                        + previewFile.getName());
        }
    };
    final MessagePart previewPart = layerClient.newMessagePart(MIME_TYPE_IMAGE_JPEG_PREVIEW, fisPreview,
            previewFile.length());

    // prepare dimensions
    JSONObject joDimensions = new JSONObject();
    try {
        joDimensions.put("width", optOriginal.outWidth);
        joDimensions.put("height", optOriginal.outHeight);
        joDimensions.put("orientation", 0);
    } catch (JSONException e) {
        throw new IllegalStateException("Cannot create JSON Object", e);
    }
    if (debug)
        Log.w(TAG, "buildPreviewAndSize() dimensions: " + joDimensions);
    final MessagePart dimensionsPart = layerClient.newMessagePart(MIME_TYPE_IMAGE_DIMENSIONS,
            joDimensions.toString().getBytes());
    MessagePart[] previewAndSize = new MessagePart[] { previewPart, dimensionsPart };
    return previewAndSize;
}

From source file:com.example.klaudia.myapplication.Searcher.java

public HashMap<String, Bitmap> getRecipesTitlesmagesFromArray(JSONArray array) {
    HashMap<String, Bitmap> result = new HashMap<String, Bitmap>();
    try {/*from   w w  w . j a  va 2s.co  m*/
        for (int i = 0; i < array.length(); i++) {
            JSONObject recipe = array.getJSONObject(i);
            String title = recipe.getString("title");
            Bitmap tmp = new DownloadImageTask().execute(recipe.getString("image")).get();
            Bitmap scaled = Bitmap.createScaledBitmap(tmp, 50, 50, true);
            result.put(title, scaled);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result;
}

From source file:im.neon.util.NotificationUtils.java

/**
 * Build a message notification.//from w  ww  . j  ava 2s  .  c  o  m
 * @param context the context
 * @param from the sender
 * @param matrixId the user account id;
 * @param displayMatrixId true to display the matrix id
 * @param largeIcon the notification icon
 * @param unseenNotifiedRoomsCount the number of notified rooms
 * @param body the message body
 * @param roomId the room id
 * @param roomName the room name
 * @param shouldPlaySound true when the notification as sound.
 * @param isInvitationEvent true if it is an invitation notification
 * @return the notification
 */
public static Notification buildMessageNotification(Context context, String from, String matrixId,
        boolean displayMatrixId, Bitmap largeIcon, int unseenNotifiedRoomsCount, String body, String roomId,
        String roomName, boolean shouldPlaySound, boolean isInvitationEvent) {

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
    builder.setWhen(System.currentTimeMillis());

    if (!TextUtils.isEmpty(from)) {
        // don't display the room name for 1:1 room notifications.
        if (!TextUtils.isEmpty(roomName) && !roomName.equals(from)) {
            builder.setContentTitle(from + " (" + roomName + ")");
        } else {
            builder.setContentTitle(from);
        }
    } else {
        builder.setContentTitle(roomName);
    }

    builder.setContentText(body);
    builder.setAutoCancel(true);
    builder.setSmallIcon(R.drawable.message_notification_transparent);

    if (null != largeIcon) {
        largeIcon = createSquareBitmap(largeIcon);

        // add a bubble in the top right
        if (0 != unseenNotifiedRoomsCount) {
            try {
                android.graphics.Bitmap.Config bitmapConfig = largeIcon.getConfig();

                // set default bitmap config if none
                if (bitmapConfig == null) {
                    bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888;
                }

                // setLargeIcon must used a 64 * 64 pixels bitmap
                // rescale to have the same text UI.
                float densityScale = context.getResources().getDisplayMetrics().density;
                int side = (int) (64 * densityScale);

                Bitmap bitmapCopy = Bitmap.createBitmap(side, side, bitmapConfig);
                Canvas canvas = new Canvas(bitmapCopy);

                // resize the bitmap to fill in size
                int bitmapWidth = largeIcon.getWidth();
                int bitmapHeight = largeIcon.getHeight();

                float scale = Math.min((float) canvas.getWidth() / (float) bitmapWidth,
                        (float) canvas.getHeight() / (float) bitmapHeight);

                int scaledWidth = (int) (bitmapWidth * scale);
                int scaledHeight = (int) (bitmapHeight * scale);

                Bitmap rescaledBitmap = Bitmap.createScaledBitmap(largeIcon, scaledWidth, scaledHeight, true);
                canvas.drawBitmap(rescaledBitmap, (side - scaledWidth) / 2, (side - scaledHeight) / 2, null);

                String text = "" + unseenNotifiedRoomsCount;

                // prepare the text drawing
                Paint textPaint = new Paint();
                textPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
                textPaint.setColor(Color.WHITE);
                textPaint.setTextSize(10 * densityScale);

                // get its size
                Rect textBounds = new Rect();

                if (-1 == mUnreadBubbleWidth) {
                    textPaint.getTextBounds("99", 0, 2, textBounds);
                    mUnreadBubbleWidth = textBounds.width();
                }

                textPaint.getTextBounds(text, 0, text.length(), textBounds);

                // draw a red circle
                int radius = mUnreadBubbleWidth;
                Paint paint = new Paint();
                paint.setStyle(Paint.Style.FILL);
                paint.setColor(Color.RED);
                canvas.drawCircle(canvas.getWidth() - radius, radius, radius, paint);

                // draw the text
                canvas.drawText(text,
                        canvas.getWidth() - textBounds.width() - (radius - (textBounds.width() / 2)),
                        -textBounds.top + (radius - (-textBounds.top / 2)), textPaint);

                // get the new bitmap
                largeIcon = bitmapCopy;
            } catch (Exception e) {
                Log.e(LOG_TAG, "## buildMessageNotification(): Exception Msg=" + e.getMessage());
            }
        }

        builder.setLargeIcon(largeIcon);
    }

    String name = ": ";
    if (!TextUtils.isEmpty(roomName)) {
        name = " (" + roomName + "): ";
    }

    if (displayMatrixId) {
        from = "[" + matrixId + "]\n" + from;
    }

    builder.setTicker(from + name + body);

    TaskStackBuilder stackBuilder;
    Intent intent;

    intent = new Intent(context, VectorRoomActivity.class);
    intent.putExtra(VectorRoomActivity.EXTRA_ROOM_ID, roomId);

    if (null != matrixId) {
        intent.putExtra(VectorRoomActivity.EXTRA_MATRIX_ID, matrixId);
    }

    stackBuilder = TaskStackBuilder.create(context).addParentStack(VectorRoomActivity.class)
            .addNextIntent(intent);

    // android 4.3 issue
    // use a generator for the private requestCode.
    // When using 0, the intent is not created/launched when the user taps on the notification.
    //
    PendingIntent pendingIntent = stackBuilder.getPendingIntent((new Random()).nextInt(1000),
            PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(pendingIntent);

    // display the message with more than 1 lines when the device supports it
    NotificationCompat.BigTextStyle textStyle = new NotificationCompat.BigTextStyle();
    textStyle.bigText(from + ":" + body);
    builder.setStyle(textStyle);

    // do not offer to quick respond if the user did not dismiss the previous one
    if (!LockScreenActivity.isDisplayingALockScreenActivity()) {
        if (!isInvitationEvent) {
            // offer to type a quick answer (i.e. without launching the application)
            Intent quickReplyIntent = new Intent(context, LockScreenActivity.class);
            quickReplyIntent.putExtra(LockScreenActivity.EXTRA_ROOM_ID, roomId);
            quickReplyIntent.putExtra(LockScreenActivity.EXTRA_SENDER_NAME, from);
            quickReplyIntent.putExtra(LockScreenActivity.EXTRA_MESSAGE_BODY, body);

            if (null != matrixId) {
                quickReplyIntent.putExtra(LockScreenActivity.EXTRA_MATRIX_ID, matrixId);
            }

            // the action must be unique else the parameters are ignored
            quickReplyIntent.setAction(QUICK_LAUNCH_ACTION + ((int) (System.currentTimeMillis())));
            PendingIntent pIntent = PendingIntent.getActivity(context, 0, quickReplyIntent, 0);
            builder.addAction(R.drawable.vector_notification_quick_reply,
                    context.getString(R.string.action_quick_reply), pIntent);
        } else {
            {
                // offer to type a quick reject button
                Intent leaveIntent = new Intent(context, JoinScreenActivity.class);
                leaveIntent.putExtra(JoinScreenActivity.EXTRA_ROOM_ID, roomId);
                leaveIntent.putExtra(JoinScreenActivity.EXTRA_MATRIX_ID, matrixId);
                leaveIntent.putExtra(JoinScreenActivity.EXTRA_REJECT, true);

                // the action must be unique else the parameters are ignored
                leaveIntent.setAction(QUICK_LAUNCH_ACTION + ((int) (System.currentTimeMillis())));
                PendingIntent pIntent = PendingIntent.getActivity(context, 0, leaveIntent, 0);
                builder.addAction(R.drawable.vector_notification_reject_invitation,
                        context.getString(R.string.reject), pIntent);
            }

            {
                // offer to type a quick accept button
                Intent acceptIntent = new Intent(context, JoinScreenActivity.class);
                acceptIntent.putExtra(JoinScreenActivity.EXTRA_ROOM_ID, roomId);
                acceptIntent.putExtra(JoinScreenActivity.EXTRA_MATRIX_ID, matrixId);
                acceptIntent.putExtra(JoinScreenActivity.EXTRA_JOIN, true);

                // the action must be unique else the parameters are ignored
                acceptIntent.setAction(QUICK_LAUNCH_ACTION + ((int) (System.currentTimeMillis())));
                PendingIntent pIntent = PendingIntent.getActivity(context, 0, acceptIntent, 0);
                builder.addAction(R.drawable.vector_notification_accept_invitation,
                        context.getString(R.string.join), pIntent);
            }
        }

        // Build the pending intent for when the notification is clicked
        Intent roomIntentTap;
        if (isInvitationEvent) {
            // for invitation the room preview must be displayed
            roomIntentTap = CommonActivityUtils.buildIntentPreviewRoom(matrixId, roomId, context,
                    VectorFakeRoomPreviewActivity.class);
        } else {
            roomIntentTap = new Intent(context, VectorRoomActivity.class);
            roomIntentTap.putExtra(VectorRoomActivity.EXTRA_ROOM_ID, roomId);
        }
        // the action must be unique else the parameters are ignored
        roomIntentTap.setAction(TAP_TO_VIEW_ACTION + ((int) (System.currentTimeMillis())));

        // Recreate the back stack
        TaskStackBuilder stackBuilderTap = TaskStackBuilder.create(context)
                .addParentStack(VectorRoomActivity.class).addNextIntent(roomIntentTap);

        builder.addAction(R.drawable.vector_notification_open, context.getString(R.string.action_open),
                stackBuilderTap.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT));
    }

    //extendForCar(context, builder, roomId, roomName, from, body);

    Notification n = builder.build();
    n.flags |= Notification.FLAG_SHOW_LIGHTS;
    n.defaults |= Notification.DEFAULT_LIGHTS;

    if (shouldPlaySound) {
        n.defaults |= Notification.DEFAULT_SOUND;
    }

    if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
        // some devices crash if this field is not set
        // even if it is deprecated

        // setLatestEventInfo() is deprecated on Android M, so we try to use
        // reflection at runtime, to avoid compiler error: "Cannot resolve method.."
        try {
            Method deprecatedMethod = n.getClass().getMethod("setLatestEventInfo", Context.class,
                    CharSequence.class, CharSequence.class, PendingIntent.class);
            deprecatedMethod.invoke(n, context, from, body, pendingIntent);
        } catch (Exception ex) {
            Log.e(LOG_TAG,
                    "## buildMessageNotification(): Exception - setLatestEventInfo() Msg=" + ex.getMessage());
        }
    }

    return n;
}

From source file:cn.edu.nju.dapenti.activity.MainActivity.java

private void selectDrawerItem(int position) {
    mCurrentDrawerPos = position;/*from   w  w w .j  av a  2 s.c  o m*/
    mIcon = null;

    Uri newUri;
    boolean showFeedInfo = true;

    switch (position) {
    case 0:
        newUri = FeedData.EntryColumns.CONTENT_URI;
        break;
    case 1:
        newUri = FeedData.EntryColumns.FAVORITES_CONTENT_URI;
        break;
    default:
        long feedOrGroupId = mDrawerAdapter.getItemId(position);
        if (mDrawerAdapter.isItemAGroup(position)) {
            newUri = FeedData.EntryColumns.ENTRIES_FOR_GROUP_CONTENT_URI(feedOrGroupId);
        } else {
            byte[] iconBytes = mDrawerAdapter.getItemIcon(position);
            if (iconBytes != null && iconBytes.length > 0) {
                int bitmapSizeInDip = UiUtils.dpToPixel(24);
                Bitmap bitmap = BitmapFactory.decodeByteArray(iconBytes, 0, iconBytes.length);
                if (bitmap != null) {
                    if (bitmap.getHeight() != bitmapSizeInDip) {
                        bitmap = Bitmap.createScaledBitmap(bitmap, bitmapSizeInDip, bitmapSizeInDip, false);
                    }

                    mIcon = new BitmapDrawable(getResources(), bitmap);
                }
            }

            newUri = FeedData.EntryColumns.ENTRIES_FOR_FEED_CONTENT_URI(feedOrGroupId);
            showFeedInfo = false;
        }
        mTitle = mDrawerAdapter.getItemName(position);
        break;
    }

    if (!newUri.equals(mEntriesFragment.getUri())) {
        mEntriesFragment.setData(newUri, showFeedInfo);
    }

    mDrawerList.setItemChecked(position, true);

    // First open => we open the drawer for you
    if (PrefUtils.getBoolean(PrefUtils.FIRST_OPEN, true)) {
        PrefUtils.putBoolean(PrefUtils.FIRST_OPEN, false);
        mDrawerLayout.postDelayed(new Runnable() {
            @Override
            public void run() {
                mDrawerLayout.openDrawer(mDrawerList);
            }
        }, 500);
    }
}

From source file:com.dunrite.xpaper.utility.Utils.java

/**
 * Creates drawable for the wallpaper/*from w ww .  j a  v  a2 s  . c o m*/
 * @param context current app context
 * @param foreground foreground drawable
 * @param bgColor color of background
 * @param fgColor color of foreground
 * @param isPreview if this is for the preview or not
 * @return the final, constructed wallpaper
 */
public static Drawable constructWallpaper(Context context, Drawable foreground, int bgColor, int fgColor,
        boolean isPreview) {
    final int WIDTH = 2560;
    final int HEIGHT = 1440;
    Canvas comboImage;
    Bitmap cs, fg;
    Paint fgPaint = new Paint();

    //create bitmap from foreground drawable
    fg = ((BitmapDrawable) foreground).getBitmap();

    if (isPreview)
        cs = Bitmap.createBitmap(WIDTH / 2, HEIGHT / 2, Bitmap.Config.ARGB_8888);
    else
        cs = Bitmap.createBitmap(WIDTH, HEIGHT, Bitmap.Config.ARGB_8888);
    comboImage = new Canvas(cs);

    fgPaint.setFilterBitmap(false);
    fgPaint.setColorFilter(new PorterDuffColorFilter(fgColor, PorterDuff.Mode.SRC_ATOP));

    comboImage.drawRGB(Color.red(bgColor), Color.green(bgColor), Color.blue(bgColor));
    if (isPreview)
        comboImage.drawBitmap(Bitmap.createScaledBitmap(fg, WIDTH / 2, HEIGHT / 2, true), 0, 0, fgPaint);
    else
        comboImage.drawBitmap(fg, 0, 0, fgPaint);

    return new BitmapDrawable(context.getResources(), cs);
}

From source file:com.snt.bt.recon.services.BcScanService.java

private void showNotification() {
    mNotificationManager = (NotificationManager) this
            .getSystemService(getApplicationContext().NOTIFICATION_SERVICE);

    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class),
            PendingIntent.FLAG_UPDATE_CURRENT);//PendingIntent.FLAG_CANCEL_CURRENT //PendingIntent.FLAG_UPDATE_CURRENT

    Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_bc);
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
            .setContentTitle("SnT BlueScanner").setTicker("SnT BlueScanner")
            .setStyle(new NotificationCompat.BigTextStyle().bigText("Recording trip..."))
            .setContentText("Recording trip...").setSmallIcon(R.drawable.ic_bc)
            .setLargeIcon(Bitmap.createScaledBitmap(icon, 128, 128, false)).setOngoing(true);
    mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}

From source file:com.lightbox.android.bitmap.BitmapUtils.java

public static Bitmap createUserPhotoThumbnail(Bitmap bitmap) {
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();

    Bitmap scaledBitmap;/*from w  w w. j  av a2 s .c  om*/
    //TODO get thumb size constant from somewhere, but where?
    if (width > height) {
        scaledBitmap = Bitmap.createScaledBitmap(bitmap,
                (int) (BitmapSource.THM_SIZE_PX * ((float) width / height)), BitmapSource.THM_SIZE_PX, true);
    } else {
        scaledBitmap = Bitmap.createScaledBitmap(bitmap, BitmapSource.THM_SIZE_PX,
                (int) (BitmapSource.THM_SIZE_PX * ((float) height / width)), true);
    }

    Bitmap thumb = Bitmap.createBitmap(scaledBitmap, (scaledBitmap.getWidth() - BitmapSource.THM_SIZE_PX) / 2,
            (scaledBitmap.getHeight() - BitmapSource.THM_SIZE_PX) / 2, BitmapSource.THM_SIZE_PX,
            BitmapSource.THM_SIZE_PX);

    scaledBitmap.recycle();

    return thumb;
}

From source file:com.mobicage.rogerthat.GroupDetailActivity.java

private Bitmap squeezeImage(Uri source) {
    T.UI();//from   w w  w  .j  a  v  a2 s.  com
    Bitmap bm = Bitmap.createScaledBitmap(BitmapFactory.decodeFile(source.getPath()), AVATAR_SIZE, AVATAR_SIZE,
            false);
    try {
        FileOutputStream out = new FileOutputStream(mUriSavedImage.getPath());
        try {
            bm.compress(Bitmap.CompressFormat.PNG, 100, out);
        } finally {
            out.close();
        }
    } catch (Exception e1) {
        L.bug(e1);
        return null;
    }
    mPhoneExifRotation = CropUtil.getExifRotation(source.getPath());
    return ImageHelper.rotateBitmap(bm, mPhoneExifRotation);
}