Java Code Examples for com.facebook.imagepipeline.image.CloseableStaticBitmap#getExifOrientation()

The following examples show how to use com.facebook.imagepipeline.image.CloseableStaticBitmap#getExifOrientation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PostprocessorProducer.java    From fresco with MIT License 6 votes vote down vote up
private CloseableReference<CloseableImage> postprocessInternal(CloseableImage sourceImage) {
  CloseableStaticBitmap staticBitmap = (CloseableStaticBitmap) sourceImage;
  Bitmap sourceBitmap = staticBitmap.getUnderlyingBitmap();
  CloseableReference<Bitmap> bitmapRef = mPostprocessor.process(sourceBitmap, mBitmapFactory);
  int rotationAngle = staticBitmap.getRotationAngle();
  int exifOrientation = staticBitmap.getExifOrientation();
  try {
    CloseableStaticBitmap closeableStaticBitmap =
        new CloseableStaticBitmap(
            bitmapRef, sourceImage.getQualityInfo(), rotationAngle, exifOrientation);
    closeableStaticBitmap.setImageExtras(staticBitmap.getExtras());
    return CloseableReference.<CloseableImage>of(closeableStaticBitmap);
  } finally {
    CloseableReference.closeSafely(bitmapRef);
  }
}
 
Example 2
Source File: DefaultDrawableFactory.java    From fresco with MIT License 5 votes vote down vote up
@Override
@Nullable
public Drawable createDrawable(CloseableImage closeableImage) {
  try {
    if (FrescoSystrace.isTracing()) {
      FrescoSystrace.beginSection("DefaultDrawableFactory#createDrawable");
    }
    if (closeableImage instanceof CloseableStaticBitmap) {
      CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) closeableImage;
      Drawable bitmapDrawable =
          new BitmapDrawable(mResources, closeableStaticBitmap.getUnderlyingBitmap());
      if (!hasTransformableRotationAngle(closeableStaticBitmap)
          && !hasTransformableExifOrientation(closeableStaticBitmap)) {
        // Return the bitmap drawable directly as there's nothing to transform in it
        return bitmapDrawable;
      } else {
        return new OrientedDrawable(
            bitmapDrawable,
            closeableStaticBitmap.getRotationAngle(),
            closeableStaticBitmap.getExifOrientation());
      }
    } else if (mAnimatedDrawableFactory != null
        && mAnimatedDrawableFactory.supportsImageType(closeableImage)) {
      return mAnimatedDrawableFactory.createDrawable(closeableImage);
    }
    return null;
  } finally {
    if (FrescoSystrace.isTracing()) {
      FrescoSystrace.endSection();
    }
  }
}
 
Example 3
Source File: BitmapDrawableFactory.java    From fresco with MIT License 5 votes vote down vote up
protected Drawable rotatedDrawable(
    CloseableStaticBitmap closeableStaticBitmap, Drawable drawable) {
  if (!hasTransformableRotationAngle(closeableStaticBitmap)
      && !hasTransformableExifOrientation(closeableStaticBitmap)) {
    // Return the bitmap drawable directly as there's nothing to transform in it
    return drawable;
  } else {
    return new OrientedDrawable(
        drawable,
        closeableStaticBitmap.getRotationAngle(),
        closeableStaticBitmap.getExifOrientation());
  }
}
 
Example 4
Source File: DefaultDrawableFactory.java    From fresco with MIT License 4 votes vote down vote up
private static boolean hasTransformableExifOrientation(
    CloseableStaticBitmap closeableStaticBitmap) {
  return closeableStaticBitmap.getExifOrientation() != ExifInterface.ORIENTATION_NORMAL
      && closeableStaticBitmap.getExifOrientation() != ExifInterface.ORIENTATION_UNDEFINED;
}
 
Example 5
Source File: BitmapDrawableFactory.java    From fresco with MIT License 4 votes vote down vote up
private static boolean hasTransformableExifOrientation(
    CloseableStaticBitmap closeableStaticBitmap) {
  return closeableStaticBitmap.getExifOrientation() != ExifInterface.ORIENTATION_NORMAL
      && closeableStaticBitmap.getExifOrientation() != ExifInterface.ORIENTATION_UNDEFINED;
}