@Override protected Bitmap transform( @NonNull BitmapPool pool, @NonNull Bitmap toTransform, int outWidth, int outHeight) { return TransformationUtils.rotateImage(toTransform, degreesToRotate); }
@Test public void testRotateImage() { Bitmap toRotate = Bitmap.createBitmap(2, 2, Bitmap.Config.ARGB_8888); Bitmap zero = TransformationUtils.rotateImage(toRotate, 0); assertTrue(toRotate == zero); Bitmap ninety = TransformationUtils.rotateImage(toRotate, 90); assertThat(Shadows.shadowOf(ninety).getDescription()).contains("rotate=90.0"); assertEquals(toRotate.getWidth(), toRotate.getHeight()); }
/** * This is an expensive operation that copies the image in place with the pixels rotated. * If possible rather use getOrientationMatrix, and set that as the imageMatrix on an ImageView. * * @deprecated No longer used by Glide, scheduled to be removed in Glide 4.0 * @param pathToOriginal Path to original image file that may have exif data. * @param imageToOrient Image Bitmap to orient. * @return The oriented bitmap. May be the imageToOrient without modification, or a new Bitmap. */ @Deprecated public static Bitmap orientImage(String pathToOriginal, Bitmap imageToOrient) { int degreesToRotate = getOrientation(pathToOriginal); return rotateImage(imageToOrient, degreesToRotate); }