本文整理汇总了Java中com.facebook.imagepipeline.common.ImageDecodeOptions类的典型用法代码示例。如果您正苦于以下问题:Java ImageDecodeOptions类的具体用法?Java ImageDecodeOptions怎么用?Java ImageDecodeOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImageDecodeOptions类属于com.facebook.imagepipeline.common包,在下文中一共展示了ImageDecodeOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onViewCreated
import com.facebook.imagepipeline.common.ImageDecodeOptions; //导入依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
SimpleDraweeView simpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view);
ImageDecodeOptions imageDecodeOptionsWithCustomDecoder = new ImageDecodeOptionsBuilder()
.setCustomImageDecoder(CUSTOM_COLOR_DECODER)
.build();
AbstractDraweeController controller = Fresco.newDraweeControllerBuilder()
.setImageRequest(
ImageRequestBuilder.newBuilderWithResourceId(R.raw.custom_color1)
.setImageDecodeOptions(imageDecodeOptionsWithCustomDecoder)
.build())
.build();
simpleDraweeView.setController(controller);
}
示例2: decodeGif
import com.facebook.imagepipeline.common.ImageDecodeOptions; //导入依赖的package包/类
/**
* 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);
}
}
示例3: decodeWebP
import com.facebook.imagepipeline.common.ImageDecodeOptions; //导入依赖的package包/类
/**
* 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);
}
}
示例4: BitmapMemoryCacheKey
import com.facebook.imagepipeline.common.ImageDecodeOptions; //导入依赖的package包/类
public BitmapMemoryCacheKey(
String sourceString,
@Nullable ResizeOptions resizeOptions,
RotationOptions rotationOptions,
ImageDecodeOptions imageDecodeOptions,
@Nullable CacheKey postprocessorCacheKey,
@Nullable String postprocessorName,
Object callerContext) {
mSourceString = Preconditions.checkNotNull(sourceString);
mResizeOptions = resizeOptions;
mRotationOptions = rotationOptions;
mImageDecodeOptions = imageDecodeOptions;
mPostprocessorCacheKey = postprocessorCacheKey;
mPostprocessorName = postprocessorName;
mHash = HashCodeUtil.hashCode(
sourceString.hashCode(),
(resizeOptions != null) ? resizeOptions.hashCode() : 0,
rotationOptions.hashCode(),
mImageDecodeOptions,
mPostprocessorCacheKey,
postprocessorName);
mCallerContext = callerContext;
mCacheTime = RealtimeSinceBootClock.get().now();
}
示例5: decode
import com.facebook.imagepipeline.common.ImageDecodeOptions; //导入依赖的package包/类
@Override
public CloseableImage decode(
EncodedImage encodedImage,
int length,
QualityInfo qualityInfo,
ImageDecodeOptions options) {
ImageFormat imageFormat = encodedImage.getImageFormat();
if (imageFormat == DefaultImageFormats.JPEG) {
return decodeJpeg(encodedImage, length, qualityInfo, options);
} else if (imageFormat == DefaultImageFormats.GIF) {
return decodeGif(encodedImage, length, qualityInfo, options);
} else if (imageFormat == DefaultImageFormats.WEBP_ANIMATED) {
return decodeAnimatedWebp(encodedImage, length, qualityInfo, options);
} else if (imageFormat == ImageFormat.UNKNOWN) {
throw new DecodeException("unknown image format", encodedImage);
}
return decodeStaticImage(encodedImage, options);
}
示例6: decodeGif
import com.facebook.imagepipeline.common.ImageDecodeOptions; //导入依赖的package包/类
/**
* Decodes gif into CloseableImage.
*
* @param encodedImage input image (encoded bytes plus meta data)
* @return a CloseableImage
*/
public CloseableImage decodeGif(
final EncodedImage encodedImage,
final int length,
final QualityInfo qualityInfo,
final ImageDecodeOptions options) {
InputStream is = encodedImage.getInputStream();
if (is == null) {
return null;
}
try {
if (!options.forceStaticImage
&& mAnimatedGifDecoder != null) {
return mAnimatedGifDecoder.decode(encodedImage, length, qualityInfo, options);
}
return decodeStaticImage(encodedImage, options);
} finally {
Closeables.closeQuietly(is);
}
}
示例7: decodeStaticImage
import com.facebook.imagepipeline.common.ImageDecodeOptions; //导入依赖的package包/类
/**
* @param encodedImage input image (encoded bytes plus meta data)
* @return a CloseableStaticBitmap
*/
public CloseableStaticBitmap decodeStaticImage(
final EncodedImage encodedImage,
ImageDecodeOptions options) {
CloseableReference<Bitmap> bitmapReference =
mPlatformDecoder.decodeFromEncodedImage(encodedImage, options.bitmapConfig, null);
try {
return new CloseableStaticBitmap(
bitmapReference,
ImmutableQualityInfo.FULL_QUALITY,
encodedImage.getRotationAngle(),
encodedImage.getExifOrientation());
} finally {
bitmapReference.close();
}
}
示例8: decodeJpeg
import com.facebook.imagepipeline.common.ImageDecodeOptions; //导入依赖的package包/类
/**
* Decodes a partial jpeg.
*
* @param encodedImage input image (encoded bytes plus meta data)
* @param length amount of currently available data in bytes
* @param qualityInfo quality info for the image
* @return a CloseableStaticBitmap
*/
public CloseableStaticBitmap decodeJpeg(
final EncodedImage encodedImage,
int length,
QualityInfo qualityInfo,
ImageDecodeOptions options) {
CloseableReference<Bitmap> bitmapReference =
mPlatformDecoder.decodeJPEGFromEncodedImage(
encodedImage, options.bitmapConfig, null, length);
try {
return new CloseableStaticBitmap(
bitmapReference,
qualityInfo,
encodedImage.getRotationAngle(),
encodedImage.getExifOrientation());
} finally {
bitmapReference.close();
}
}
示例9: decode
import com.facebook.imagepipeline.common.ImageDecodeOptions; //导入依赖的package包/类
@Override
public CloseableImage decode(
EncodedImage encodedImage,
int length,
QualityInfo qualityInfo,
ImageDecodeOptions options) {
InputStream encodedInputStream = null;
try {
encodedInputStream = encodedImage.getInputStream();
return new CloseableKeyframesImage(
KFImageDeserializer.deserialize(encodedInputStream));
} catch (IOException e) {
e.printStackTrace();
return null;
} finally {
Closeables.closeQuietly(encodedInputStream);
}
}
示例10: getGifDecoder
import com.facebook.imagepipeline.common.ImageDecodeOptions; //导入依赖的package包/类
@Override
public ImageDecoder getGifDecoder(final Bitmap.Config bitmapConfig) {
return new ImageDecoder() {
@Override
public CloseableImage decode(
EncodedImage encodedImage,
int length,
QualityInfo qualityInfo,
ImageDecodeOptions options) {
return getAnimatedImageFactory().decodeGif(encodedImage, options, bitmapConfig);
}
};
}
示例11: getWebPDecoder
import com.facebook.imagepipeline.common.ImageDecodeOptions; //导入依赖的package包/类
@Override
public ImageDecoder getWebPDecoder(final Bitmap.Config bitmapConfig) {
return new ImageDecoder() {
@Override
public CloseableImage decode(
EncodedImage encodedImage,
int length,
QualityInfo qualityInfo,
ImageDecodeOptions options) {
return getAnimatedImageFactory().decodeWebP(encodedImage, options, bitmapConfig);
}
};
}
示例12: getCloseableImage
import com.facebook.imagepipeline.common.ImageDecodeOptions; //导入依赖的package包/类
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);
}
}
示例13: testCreateDefaults
import com.facebook.imagepipeline.common.ImageDecodeOptions; //导入依赖的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);
}
示例14: testCreateDefaults
import com.facebook.imagepipeline.common.ImageDecodeOptions; //导入依赖的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);
}
示例15: decode
import com.facebook.imagepipeline.common.ImageDecodeOptions; //导入依赖的package包/类
@Override
public CloseableImage decode(
EncodedImage encodedImage,
int length,
QualityInfo qualityInfo,
ImageDecodeOptions options) {
try {
SVG svg = SVG.getFromInputStream(encodedImage.getInputStream());
return new CloseableSvgImage(svg);
} catch (SVGParseException e) {
e.printStackTrace();
}
return null;
}