use of com.facebook.imagepipeline.animated.base.AnimatedImage in project fresco by facebook.
the class ExperimentalAnimationFactory method createAnimationBackend.
private AnimationBackend createAnimationBackend(AnimatedImageResult animatedImageResult) {
// Create the animated drawable backend
AnimatedImage animatedImage = animatedImageResult.getImage();
Rect initialBounds = new Rect(0, 0, animatedImage.getWidth(), animatedImage.getHeight());
AnimatedDrawableBackend animatedDrawableBackend = mAnimatedDrawableBackendProvider.get(animatedImageResult, initialBounds);
// Add caching backend
AnimatedDrawableCachingBackend animatedDrawableCachingBackend = mAnimatedDrawableCachingBackendProvider.get(animatedDrawableBackend, AnimatedDrawableOptions.DEFAULTS);
AnimatedDrawableCachingBackendWrapper animatedDrawableCachingBackendWrapper = new AnimatedDrawableCachingBackendWrapper(animatedDrawableCachingBackend);
// Add inactivity check
return AnimationBackendDelegateWithInactivityCheck.createForBackend(animatedDrawableCachingBackendWrapper, mMonotonicClock, mScheduledExecutorServiceForUiThread);
}
use of com.facebook.imagepipeline.animated.base.AnimatedImage in project fresco by facebook.
the class ExperimentalBitmapAnimationDrawableFactory method createDrawable.
@Override
public AnimatedDrawable2 createDrawable(CloseableImage image) {
CloseableAnimatedImage closeable = ((CloseableAnimatedImage) image);
AnimatedImage animatedImage = closeable.getImage();
return new AnimatedDrawable2(createAnimationBackend(Preconditions.checkNotNull(closeable.getImageResult()), animatedImage != null ? animatedImage.getAnimatedBitmapConfig() : null));
}
use of com.facebook.imagepipeline.animated.base.AnimatedImage in project fresco by facebook.
the class AnimatedImageFactoryImpl method decodeGif.
/**
* Decodes a GIF into a CloseableImage.
*
* @param encodedImage encoded image (native byte array holding the encoded bytes and meta data)
* @param options the options for the decode
* @param bitmapConfig the Bitmap.Config used to generate the output bitmaps
* @return a {@link CloseableImage} for the GIF image
*/
public CloseableImage decodeGif(final EncodedImage encodedImage, final ImageDecodeOptions options, final Bitmap.Config bitmapConfig) {
if (sGifAnimatedImageDecoder == null) {
throw new UnsupportedOperationException("To encode animated gif please add the dependency " + "to the animated-gif module");
}
final CloseableReference<PooledByteBuffer> bytesRef = encodedImage.getByteBufferRef();
Preconditions.checkNotNull(bytesRef);
try {
final PooledByteBuffer input = bytesRef.get();
AnimatedImage gifImage;
if (input.getByteBuffer() != null) {
gifImage = sGifAnimatedImageDecoder.decodeFromByteBuffer(input.getByteBuffer(), options);
} else {
gifImage = sGifAnimatedImageDecoder.decodeFromNativeMemory(input.getNativePtr(), input.size(), options);
}
return getCloseableImage(options, gifImage, bitmapConfig);
} finally {
CloseableReference.closeSafely(bytesRef);
}
}
use of com.facebook.imagepipeline.animated.base.AnimatedImage in project fresco by facebook.
the class AnimatedDrawableFactoryImpl method create.
/**
* Creates an {@link AnimatedDrawable} based on an {@link AnimatedImage}.
*
* @param animatedImageResult the result of the code
* @param options additional options
* @return a newly constructed {@link AnimatedDrawable}
*/
private AnimatedDrawable create(AnimatedImageResult animatedImageResult, AnimatedDrawableOptions options) {
AnimatedImage animatedImage = animatedImageResult.getImage();
Rect initialBounds = new Rect(0, 0, animatedImage.getWidth(), animatedImage.getHeight());
AnimatedDrawableBackend animatedDrawableBackend = mAnimatedDrawableBackendProvider.get(animatedImageResult, initialBounds);
return createAnimatedDrawable(options, animatedDrawableBackend);
}
use of com.facebook.imagepipeline.animated.base.AnimatedImage in project fresco by facebook.
the class AnimatedDrawableFactoryImplSupport method create.
/**
* Creates an {@link AnimatedDrawable} based on an {@link AnimatedImage}.
*
* @param animatedImageResult the result of the code
* @param options additional options
* @return a newly constructed {@link AnimatedDrawable}
*/
private AnimatedDrawableSupport create(AnimatedImageResult animatedImageResult, AnimatedDrawableOptions options) {
AnimatedImage animatedImage = animatedImageResult.getImage();
Rect initialBounds = new Rect(0, 0, animatedImage.getWidth(), animatedImage.getHeight());
AnimatedDrawableBackend animatedDrawableBackend = mAnimatedDrawableBackendProvider.get(animatedImageResult, initialBounds);
return createAnimatedDrawable(options, animatedDrawableBackend);
}
Aggregations