Search in sources :

Example 1 with AnimatedImage

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);
}
Also used : AnimatedDrawableBackend(com.facebook.imagepipeline.animated.base.AnimatedDrawableBackend) Rect(android.graphics.Rect) AnimatedImage(com.facebook.imagepipeline.animated.base.AnimatedImage) CloseableAnimatedImage(com.facebook.imagepipeline.image.CloseableAnimatedImage) AnimatedDrawableCachingBackend(com.facebook.imagepipeline.animated.base.AnimatedDrawableCachingBackend) AnimatedDrawableCachingBackendWrapper(com.facebook.fresco.animation.wrapper.AnimatedDrawableCachingBackendWrapper)

Example 2 with AnimatedImage

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));
}
Also used : AnimatedDrawable2(com.facebook.fresco.animation.drawable.AnimatedDrawable2) CloseableAnimatedImage(com.facebook.imagepipeline.image.CloseableAnimatedImage) CloseableAnimatedImage(com.facebook.imagepipeline.image.CloseableAnimatedImage) AnimatedImage(com.facebook.imagepipeline.animated.base.AnimatedImage)

Example 3 with AnimatedImage

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);
    }
}
Also used : PooledByteBuffer(com.facebook.common.memory.PooledByteBuffer) AnimatedImage(com.facebook.imagepipeline.animated.base.AnimatedImage) CloseableAnimatedImage(com.facebook.imagepipeline.image.CloseableAnimatedImage)

Example 4 with AnimatedImage

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);
}
Also used : AnimatedDrawableBackend(com.facebook.imagepipeline.animated.base.AnimatedDrawableBackend) Rect(android.graphics.Rect) AnimatedImage(com.facebook.imagepipeline.animated.base.AnimatedImage) CloseableAnimatedImage(com.facebook.imagepipeline.image.CloseableAnimatedImage)

Example 5 with AnimatedImage

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);
}
Also used : AnimatedDrawableBackend(com.facebook.imagepipeline.animated.base.AnimatedDrawableBackend) Rect(android.graphics.Rect) AnimatedImage(com.facebook.imagepipeline.animated.base.AnimatedImage) CloseableAnimatedImage(com.facebook.imagepipeline.image.CloseableAnimatedImage)

Aggregations

AnimatedImage (com.facebook.imagepipeline.animated.base.AnimatedImage)7 CloseableAnimatedImage (com.facebook.imagepipeline.image.CloseableAnimatedImage)7 Rect (android.graphics.Rect)4 AnimatedDrawableBackend (com.facebook.imagepipeline.animated.base.AnimatedDrawableBackend)3 PooledByteBuffer (com.facebook.common.memory.PooledByteBuffer)2 AnimatedDrawable2 (com.facebook.fresco.animation.drawable.AnimatedDrawable2)1 AnimatedDrawableCachingBackendWrapper (com.facebook.fresco.animation.wrapper.AnimatedDrawableCachingBackendWrapper)1 AnimatedDrawableCachingBackend (com.facebook.imagepipeline.animated.base.AnimatedDrawableCachingBackend)1