本文整理汇总了Java中com.facebook.imagepipeline.image.CloseableAnimatedImage.getImageResult方法的典型用法代码示例。如果您正苦于以下问题:Java CloseableAnimatedImage.getImageResult方法的具体用法?Java CloseableAnimatedImage.getImageResult怎么用?Java CloseableAnimatedImage.getImageResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.imagepipeline.image.CloseableAnimatedImage
的用法示例。
在下文中一共展示了CloseableAnimatedImage.getImageResult方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCreateDefaults
import com.facebook.imagepipeline.image.CloseableAnimatedImage; //导入方法依赖的package包/类
@Test
public void testCreateDefaults() {
WebPImage mockWebPImage = mock(WebPImage.class);
// Expect a call to WebPImage.create
TrivialPooledByteBuffer byteBuffer = createByteBuffer();
when(mWebPImageMock.decode(byteBuffer.getNativePtr(), byteBuffer.size()))
.thenReturn(mockWebPImage);
EncodedImage encodedImage = new EncodedImage(
CloseableReference.of(byteBuffer, FAKE_RESOURCE_RELEASER));
encodedImage.setImageFormat(ImageFormat.UNKNOWN);
CloseableAnimatedImage closeableImage =
(CloseableAnimatedImage) mAnimatedImageFactory.decodeWebP(
encodedImage,
ImageDecodeOptions.defaults(),
DEFAULT_BITMAP_CONFIG);
// Verify we got the right result
AnimatedImageResult imageResult = closeableImage.getImageResult();
assertSame(mockWebPImage, imageResult.getImage());
assertNull(imageResult.getPreviewBitmap());
assertFalse(imageResult.hasDecodedFrame(0));
// Should not have interacted with these.
verifyZeroInteractions(mMockAnimatedDrawableBackendProvider);
verifyZeroInteractions(mMockBitmapFactory);
}
示例2: testCreateDefaults
import com.facebook.imagepipeline.image.CloseableAnimatedImage; //导入方法依赖的package包/类
@Test
public void testCreateDefaults() {
GifImage mockGifImage = mock(GifImage.class);
// Expect a call to GifImage.create
TrivialPooledByteBuffer byteBuffer = createByteBuffer();
when(mGifImageMock.decode(byteBuffer.getNativePtr(), byteBuffer.size()))
.thenReturn(mockGifImage);
EncodedImage encodedImage = new EncodedImage(
CloseableReference.of(byteBuffer, FAKE_RESOURCE_RELEASER));
encodedImage.setImageFormat(ImageFormat.UNKNOWN);
CloseableAnimatedImage closeableImage =
(CloseableAnimatedImage) mAnimatedImageFactory.decodeGif(
encodedImage,
ImageDecodeOptions.defaults(),
DEFAULT_BITMAP_CONFIG);
// Verify we got the right result
AnimatedImageResult imageResult = closeableImage.getImageResult();
assertSame(mockGifImage, imageResult.getImage());
assertNull(imageResult.getPreviewBitmap());
assertFalse(imageResult.hasDecodedFrame(0));
// Should not have interacted with these.
verifyZeroInteractions(mMockAnimatedDrawableBackendProvider);
verifyZeroInteractions(mMockBitmapFactory);
}
示例3: testCreateWithPreviewBitmap
import com.facebook.imagepipeline.image.CloseableAnimatedImage; //导入方法依赖的package包/类
@Test
public void testCreateWithPreviewBitmap() throws Exception {
WebPImage mockWebPImage = mock(WebPImage.class);
Bitmap mockBitmap = MockBitmapFactory.create(50, 50, DEFAULT_BITMAP_CONFIG);
// Expect a call to WebPImage.create
TrivialPooledByteBuffer byteBuffer = createByteBuffer();
when(mWebPImageMock.decode(byteBuffer.getNativePtr(), byteBuffer.size()))
.thenReturn(mockWebPImage);
when(mockWebPImage.getWidth()).thenReturn(50);
when(mockWebPImage.getHeight()).thenReturn(50);
// For decoding preview frame, expect some calls.
final AnimatedDrawableBackend mockAnimatedDrawableBackend =
createAnimatedDrawableBackendMock(1);
when(mMockAnimatedDrawableBackendProvider.get(
any(AnimatedImageResult.class),
isNull(Rect.class)))
.thenReturn(mockAnimatedDrawableBackend);
when(mMockBitmapFactory.createBitmapInternal(50, 50, DEFAULT_BITMAP_CONFIG))
.thenReturn(CloseableReference.of(mockBitmap, FAKE_BITMAP_RESOURCE_RELEASER));
AnimatedImageCompositor mockCompositor = mock(AnimatedImageCompositor.class);
PowerMockito.whenNew(AnimatedImageCompositor.class)
.withAnyArguments()
.thenReturn(mockCompositor);
ImageDecodeOptions imageDecodeOptions = ImageDecodeOptions.newBuilder()
.setDecodePreviewFrame(true)
.build();
EncodedImage encodedImage = new EncodedImage(
CloseableReference.of(byteBuffer, FAKE_RESOURCE_RELEASER));
encodedImage.setImageFormat(ImageFormat.UNKNOWN);
CloseableAnimatedImage closeableImage =
(CloseableAnimatedImage) mAnimatedImageFactory.decodeWebP(
encodedImage,
imageDecodeOptions,
DEFAULT_BITMAP_CONFIG);
// Verify we got the right result
AnimatedImageResult imageResult = closeableImage.getImageResult();
assertSame(mockWebPImage, imageResult.getImage());
assertNotNull(imageResult.getPreviewBitmap());
assertFalse(imageResult.hasDecodedFrame(0));
// Should not have interacted with these.
verify(mMockAnimatedDrawableBackendProvider).get(
any(AnimatedImageResult.class),
isNull(Rect.class));
verifyNoMoreInteractions(mMockAnimatedDrawableBackendProvider);
verify(mMockBitmapFactory).createBitmapInternal(50, 50, DEFAULT_BITMAP_CONFIG);
verifyNoMoreInteractions(mMockBitmapFactory);
verify(mockCompositor).renderFrame(0, mockBitmap);
}
示例4: testCreateWithDecodeAlFrames
import com.facebook.imagepipeline.image.CloseableAnimatedImage; //导入方法依赖的package包/类
@Test
public void testCreateWithDecodeAlFrames() throws Exception {
WebPImage mockWebPImage = mock(WebPImage.class);
Bitmap mockBitmap1 = MockBitmapFactory.create(50, 50, DEFAULT_BITMAP_CONFIG);
Bitmap mockBitmap2 = MockBitmapFactory.create(50, 50, DEFAULT_BITMAP_CONFIG);
// Expect a call to WebPImage.create
TrivialPooledByteBuffer byteBuffer = createByteBuffer();
when(mWebPImageMock.decode(byteBuffer.getNativePtr(), byteBuffer.size()))
.thenReturn(mockWebPImage);
when(mockWebPImage.getWidth()).thenReturn(50);
when(mockWebPImage.getHeight()).thenReturn(50);
// For decoding preview frame, expect some calls.
final AnimatedDrawableBackend mockAnimatedDrawableBackend =
createAnimatedDrawableBackendMock(2);
when(
mMockAnimatedDrawableBackendProvider.get(
any(AnimatedImageResult.class),
isNull(Rect.class)))
.thenReturn(mockAnimatedDrawableBackend);
when(mMockBitmapFactory.createBitmapInternal(50, 50, DEFAULT_BITMAP_CONFIG))
.thenReturn(CloseableReference.of(mockBitmap1, FAKE_BITMAP_RESOURCE_RELEASER))
.thenReturn(CloseableReference.of(mockBitmap2, FAKE_BITMAP_RESOURCE_RELEASER));
AnimatedImageCompositor mockCompositor = mock(AnimatedImageCompositor.class);
PowerMockito.whenNew(AnimatedImageCompositor.class)
.withAnyArguments()
.thenReturn(mockCompositor);
ImageDecodeOptions imageDecodeOptions = ImageDecodeOptions.newBuilder()
.setDecodePreviewFrame(true)
.setDecodeAllFrames(true)
.build();
EncodedImage encodedImage = new EncodedImage(
CloseableReference.of(byteBuffer, FAKE_RESOURCE_RELEASER));
encodedImage.setImageFormat(ImageFormat.UNKNOWN);
CloseableAnimatedImage closeableImage =
(CloseableAnimatedImage) mAnimatedImageFactory.decodeWebP(
encodedImage,
imageDecodeOptions,
DEFAULT_BITMAP_CONFIG);
// Verify we got the right result
AnimatedImageResult imageResult = closeableImage.getImageResult();
assertSame(mockWebPImage, imageResult.getImage());
assertNotNull(imageResult.getDecodedFrame(0));
assertNotNull(imageResult.getDecodedFrame(1));
assertNotNull(imageResult.getPreviewBitmap());
// Should not have interacted with these.
verify(mMockAnimatedDrawableBackendProvider).get(
any(AnimatedImageResult.class),
isNull(Rect.class));
verifyNoMoreInteractions(mMockAnimatedDrawableBackendProvider);
verify(mMockBitmapFactory, times(2)).createBitmapInternal(50, 50, DEFAULT_BITMAP_CONFIG);
verifyNoMoreInteractions(mMockBitmapFactory);
verify(mockCompositor).renderFrame(0, mockBitmap1);
verify(mockCompositor).renderFrame(1, mockBitmap2);
}
示例5: testCreateWithPreviewBitmap
import com.facebook.imagepipeline.image.CloseableAnimatedImage; //导入方法依赖的package包/类
@Test
public void testCreateWithPreviewBitmap() throws Exception {
GifImage mockGifImage = mock(GifImage.class);
Bitmap mockBitmap = MockBitmapFactory.create(50, 50, DEFAULT_BITMAP_CONFIG);
// Expect a call to WebPImage.create
TrivialPooledByteBuffer byteBuffer = createByteBuffer();
when(mGifImageMock.decode(byteBuffer.getNativePtr(), byteBuffer.size()))
.thenReturn(mockGifImage);
when(mockGifImage.getWidth()).thenReturn(50);
when(mockGifImage.getHeight()).thenReturn(50);
// For decoding preview frame, expect some calls.
final AnimatedDrawableBackend mockAnimatedDrawableBackend =
createAnimatedDrawableBackendMock(1);
when(mMockAnimatedDrawableBackendProvider.get(
any(AnimatedImageResult.class),
isNull(Rect.class)))
.thenReturn(mockAnimatedDrawableBackend);
when(mMockBitmapFactory.createBitmapInternal(50, 50, DEFAULT_BITMAP_CONFIG))
.thenReturn(CloseableReference.of(mockBitmap, FAKE_BITMAP_RESOURCE_RELEASER));
AnimatedImageCompositor mockCompositor = mock(AnimatedImageCompositor.class);
PowerMockito.whenNew(AnimatedImageCompositor.class)
.withAnyArguments()
.thenReturn(mockCompositor);
ImageDecodeOptions imageDecodeOptions = ImageDecodeOptions.newBuilder()
.setDecodePreviewFrame(true)
.build();
EncodedImage encodedImage = new EncodedImage(
CloseableReference.of(byteBuffer, FAKE_RESOURCE_RELEASER));
encodedImage.setImageFormat(ImageFormat.UNKNOWN);
CloseableAnimatedImage closeableImage =
(CloseableAnimatedImage) mAnimatedImageFactory.decodeGif(
encodedImage,
imageDecodeOptions,
DEFAULT_BITMAP_CONFIG);
// Verify we got the right result
AnimatedImageResult imageResult = closeableImage.getImageResult();
assertSame(mockGifImage, imageResult.getImage());
assertNotNull(imageResult.getPreviewBitmap());
assertFalse(imageResult.hasDecodedFrame(0));
// Should not have interacted with these.
verify(mMockAnimatedDrawableBackendProvider).get(
any(AnimatedImageResult.class),
isNull(Rect.class));
verifyNoMoreInteractions(mMockAnimatedDrawableBackendProvider);
verify(mMockBitmapFactory).createBitmapInternal(50, 50, DEFAULT_BITMAP_CONFIG);
verifyNoMoreInteractions(mMockBitmapFactory);
verify(mockCompositor).renderFrame(0, mockBitmap);
}
示例6: testCreateWithDecodeAlFrames
import com.facebook.imagepipeline.image.CloseableAnimatedImage; //导入方法依赖的package包/类
@Test
public void testCreateWithDecodeAlFrames() throws Exception {
GifImage mockGifImage = mock(GifImage.class);
Bitmap mockBitmap1 = MockBitmapFactory.create(50, 50, DEFAULT_BITMAP_CONFIG);
Bitmap mockBitmap2 = MockBitmapFactory.create(50, 50, DEFAULT_BITMAP_CONFIG);
// Expect a call to GifImage.create
TrivialPooledByteBuffer byteBuffer = createByteBuffer();
when(mGifImageMock.decode(byteBuffer.getNativePtr(), byteBuffer.size()))
.thenReturn(mockGifImage);
when(mockGifImage.getWidth()).thenReturn(50);
when(mockGifImage.getHeight()).thenReturn(50);
// For decoding preview frame, expect some calls.
final AnimatedDrawableBackend mockAnimatedDrawableBackend =
createAnimatedDrawableBackendMock(2);
when(
mMockAnimatedDrawableBackendProvider.get(
any(AnimatedImageResult.class),
isNull(Rect.class)))
.thenReturn(mockAnimatedDrawableBackend);
when(mMockBitmapFactory.createBitmapInternal(50, 50, DEFAULT_BITMAP_CONFIG))
.thenReturn(CloseableReference.of(mockBitmap1, FAKE_BITMAP_RESOURCE_RELEASER))
.thenReturn(CloseableReference.of(mockBitmap2, FAKE_BITMAP_RESOURCE_RELEASER));
AnimatedImageCompositor mockCompositor = mock(AnimatedImageCompositor.class);
PowerMockito.whenNew(AnimatedImageCompositor.class)
.withAnyArguments()
.thenReturn(mockCompositor);
ImageDecodeOptions imageDecodeOptions = ImageDecodeOptions.newBuilder()
.setDecodePreviewFrame(true)
.setDecodeAllFrames(true)
.build();
EncodedImage encodedImage = new EncodedImage(
CloseableReference.of(byteBuffer, FAKE_RESOURCE_RELEASER));
encodedImage.setImageFormat(ImageFormat.UNKNOWN);
CloseableAnimatedImage closeableImage =
(CloseableAnimatedImage) mAnimatedImageFactory.decodeGif(
encodedImage,
imageDecodeOptions,
DEFAULT_BITMAP_CONFIG);
// Verify we got the right result
AnimatedImageResult imageResult = closeableImage.getImageResult();
assertSame(mockGifImage, imageResult.getImage());
assertNotNull(imageResult.getDecodedFrame(0));
assertNotNull(imageResult.getDecodedFrame(1));
assertNotNull(imageResult.getPreviewBitmap());
// Should not have interacted with these.
verify(mMockAnimatedDrawableBackendProvider).get(
any(AnimatedImageResult.class),
isNull(Rect.class));
verifyNoMoreInteractions(mMockAnimatedDrawableBackendProvider);
verify(mMockBitmapFactory, times(2)).createBitmapInternal(50, 50, DEFAULT_BITMAP_CONFIG);
verifyNoMoreInteractions(mMockBitmapFactory);
verify(mockCompositor).renderFrame(0, mockBitmap1);
verify(mockCompositor).renderFrame(1, mockBitmap2);
}