Java 类com.facebook.imagepipeline.animated.base.AnimatedImage 实例源码
项目:GitHub
文件:AnimatedImageFactoryImpl.java
/**
* 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 = sGifAnimatedImageDecoder.decode(input.getNativePtr(), input.size());
return getCloseableImage(options, gifImage, bitmapConfig);
} finally {
CloseableReference.closeSafely(bytesRef);
}
}
项目:GitHub
文件:AnimatedImageFactoryImpl.java
/**
* Decode a WebP 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 WebP image
*/
public CloseableImage decodeWebP(
final EncodedImage encodedImage,
final ImageDecodeOptions options,
final Bitmap.Config bitmapConfig) {
if (sWebpAnimatedImageDecoder == null) {
throw new UnsupportedOperationException("To encode animated webp please add the dependency " +
"to the animated-webp module");
}
final CloseableReference<PooledByteBuffer> bytesRef = encodedImage.getByteBufferRef();
Preconditions.checkNotNull(bytesRef);
try {
final PooledByteBuffer input = bytesRef.get();
AnimatedImage webPImage = sWebpAnimatedImageDecoder.decode(
input.getNativePtr(),
input.size());
return getCloseableImage(options, webPImage, bitmapConfig);
} finally {
CloseableReference.closeSafely(bytesRef);
}
}
项目:GitHub
文件:GifImage.java
@Override
public int getLoopCount() {
// If a GIF image has no Netscape 2.0 loop extension, it is meant to play once and then stop. A
// loop count of 0 indicates an endless looping of the animation. Any loop count X>0 indicates
// that the animation shall be repeated X times, resulting in the animation to play X+1 times.
final int loopCount = nativeGetLoopCount();
switch (loopCount) {
case LOOP_COUNT_FOREVER:
return AnimatedImage.LOOP_COUNT_INFINITE;
case LOOP_COUNT_MISSING:
return 1;
default:
return loopCount + 1;
}
}
项目:fresco
文件:AnimatedImageFactoryImpl.java
/**
* 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 = sGifAnimatedImageDecoder.decode(input.getNativePtr(), input.size());
return getCloseableImage(options, gifImage, bitmapConfig);
} finally {
CloseableReference.closeSafely(bytesRef);
}
}
项目:fresco
文件:AnimatedImageFactoryImpl.java
/**
* Decode a WebP 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 WebP image
*/
public CloseableImage decodeWebP(
final EncodedImage encodedImage,
final ImageDecodeOptions options,
final Bitmap.Config bitmapConfig) {
if (sWebpAnimatedImageDecoder == null) {
throw new UnsupportedOperationException("To encode animated webp please add the dependency " +
"to the animated-webp module");
}
final CloseableReference<PooledByteBuffer> bytesRef = encodedImage.getByteBufferRef();
Preconditions.checkNotNull(bytesRef);
try {
final PooledByteBuffer input = bytesRef.get();
AnimatedImage webPImage = sWebpAnimatedImageDecoder.decode(
input.getNativePtr(),
input.size());
return getCloseableImage(options, webPImage, bitmapConfig);
} finally {
CloseableReference.closeSafely(bytesRef);
}
}
项目:fresco
文件:GifImage.java
@Override
public int getLoopCount() {
// If a GIF image has no Netscape 2.0 loop extension, it is meant to play once and then stop. A
// loop count of 0 indicates an endless looping of the animation. Any loop count X>0 indicates
// that the animation shall be repeated X times, resulting in the animation to play X+1 times.
final int loopCount = nativeGetLoopCount();
switch (loopCount) {
case LOOP_COUNT_FOREVER:
return AnimatedImage.LOOP_COUNT_INFINITE;
case LOOP_COUNT_MISSING:
return 1;
default:
return loopCount + 1;
}
}
项目:GitHub
文件:AnimatedImageFactoryImpl.java
private CloseableImage getCloseableImage(
ImageDecodeOptions options,
AnimatedImage image,
Bitmap.Config bitmapConfig) {
List<CloseableReference<Bitmap>> decodedFrames = null;
CloseableReference<Bitmap> previewBitmap = null;
try {
final int frameForPreview = options.useLastFrameForPreview ? image.getFrameCount() - 1 : 0;
if (options.forceStaticImage) {
return new CloseableStaticBitmap(
createPreviewBitmap(image, bitmapConfig, frameForPreview),
ImmutableQualityInfo.FULL_QUALITY,
0);
}
if (options.decodeAllFrames) {
decodedFrames = decodeAllFrames(image, bitmapConfig);
previewBitmap = CloseableReference.cloneOrNull(decodedFrames.get(frameForPreview));
}
if (options.decodePreviewFrame && previewBitmap == null) {
previewBitmap = createPreviewBitmap(image, bitmapConfig, frameForPreview);
}
AnimatedImageResult animatedImageResult = AnimatedImageResult.newBuilder(image)
.setPreviewBitmap(previewBitmap)
.setFrameForPreview(frameForPreview)
.setDecodedFrames(decodedFrames)
.build();
return new CloseableAnimatedImage(animatedImageResult);
} finally {
CloseableReference.closeSafely(previewBitmap);
CloseableReference.closeSafely(decodedFrames);
}
}
项目:GitHub
文件:AnimatedDrawableBackendImpl.java
private static Rect getBoundsToUse(AnimatedImage image, Rect targetBounds) {
if (targetBounds == null) {
return new Rect(0, 0, image.getWidth(), image.getHeight());
}
return new Rect(
0,
0,
Math.min(targetBounds.width(), image.getWidth()),
Math.min(targetBounds.height(), image.getHeight()));
}
项目:fresco
文件:AnimatedImageFactoryImpl.java
private CloseableImage getCloseableImage(
ImageDecodeOptions options,
AnimatedImage image,
Bitmap.Config bitmapConfig) {
List<CloseableReference<Bitmap>> decodedFrames = null;
CloseableReference<Bitmap> previewBitmap = null;
try {
final int frameForPreview = options.useLastFrameForPreview ? image.getFrameCount() - 1 : 0;
if (options.forceStaticImage) {
return new CloseableStaticBitmap(
createPreviewBitmap(image, bitmapConfig, frameForPreview),
ImmutableQualityInfo.FULL_QUALITY,
0);
}
if (options.decodeAllFrames) {
decodedFrames = decodeAllFrames(image, bitmapConfig);
previewBitmap = CloseableReference.cloneOrNull(decodedFrames.get(frameForPreview));
}
if (options.decodePreviewFrame && previewBitmap == null) {
previewBitmap = createPreviewBitmap(image, bitmapConfig, frameForPreview);
}
AnimatedImageResult animatedImageResult = AnimatedImageResult.newBuilder(image)
.setPreviewBitmap(previewBitmap)
.setFrameForPreview(frameForPreview)
.setDecodedFrames(decodedFrames)
.build();
return new CloseableAnimatedImage(animatedImageResult);
} finally {
CloseableReference.closeSafely(previewBitmap);
CloseableReference.closeSafely(decodedFrames);
}
}
项目:fresco
文件:AnimatedDrawableBackendImpl.java
private static Rect getBoundsToUse(AnimatedImage image, Rect targetBounds) {
if (targetBounds == null) {
return new Rect(0, 0, image.getWidth(), image.getHeight());
}
return new Rect(
0,
0,
Math.min(targetBounds.width(), image.getWidth()),
Math.min(targetBounds.height(), image.getHeight()));
}
项目:GitHub
文件:ExperimentalBitmapAnimationDrawableFactory.java
private AnimatedDrawableBackend createAnimatedDrawableBackend(
AnimatedImageResult animatedImageResult) {
AnimatedImage animatedImage = animatedImageResult.getImage();
Rect initialBounds = new Rect(0, 0, animatedImage.getWidth(), animatedImage.getHeight());
return mAnimatedDrawableBackendProvider.get(animatedImageResult, initialBounds);
}
项目:GitHub
文件:CloseableAnimatedImage.java
public synchronized AnimatedImage getImage() {
return isClosed() ? null : mImageResult.getImage();
}
项目:GitHub
文件:WebPImage.java
@Override
public AnimatedImage decode(long nativePtr, int sizeInBytes) {
return WebPImage.create(nativePtr, sizeInBytes);
}
项目:GitHub
文件:GifImage.java
@Override
public AnimatedImage decode(long nativePtr, int sizeInBytes) {
return GifImage.create(nativePtr, sizeInBytes);
}
项目:fresco
文件:ExperimentalBitmapAnimationDrawableFactory.java
private AnimatedDrawableBackend createAnimatedDrawableBackend(
AnimatedImageResult animatedImageResult) {
AnimatedImage animatedImage = animatedImageResult.getImage();
Rect initialBounds = new Rect(0, 0, animatedImage.getWidth(), animatedImage.getHeight());
return mAnimatedDrawableBackendProvider.get(animatedImageResult, initialBounds);
}
项目:fresco
文件:CloseableAnimatedImage.java
public synchronized AnimatedImage getImage() {
return isClosed() ? null : mImageResult.getImage();
}
项目:fresco
文件:WebPImage.java
@Override
public AnimatedImage decode(long nativePtr, int sizeInBytes) {
return WebPImage.create(nativePtr, sizeInBytes);
}
项目:fresco
文件:GifImage.java
@Override
public AnimatedImage decode(long nativePtr, int sizeInBytes) {
return GifImage.create(nativePtr, sizeInBytes);
}
项目:GitHub
文件:AnimatedImageDecoder.java
/**
* Factory method to create the AnimatedImage from the
* @param nativePtr The native pointer
* @param sizeInBytes The size in byte to allocate
* @return The AnimatedImage allocation
*/
AnimatedImage decode(long nativePtr, int sizeInBytes);
项目:fresco
文件:AnimatedImageDecoder.java
/**
* Factory method to create the AnimatedImage from the
* @param nativePtr The native pointer
* @param sizeInBytes The size in byte to allocate
* @return The AnimatedImage allocation
*/
AnimatedImage decode(long nativePtr, int sizeInBytes);