当前位置: 首页>>代码示例>>Java>>正文


Java ImageDecodeOptions类代码示例

本文整理汇总了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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:ImageFormatOverrideExample.java

示例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);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:AnimatedImageFactoryImpl.java

示例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);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:AnimatedImageFactoryImpl.java

示例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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:BitmapMemoryCacheKey.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:DefaultImageDecoder.java

示例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);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:DefaultImageDecoder.java

示例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();
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:DefaultImageDecoder.java

示例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();
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:DefaultImageDecoder.java

示例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);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:KeyframesDecoderExample.java

示例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);
    }
  };
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:AnimatedFactoryV2Impl.java

示例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);
    }
  };
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:AnimatedFactoryV2Impl.java

示例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);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:35,代码来源:AnimatedImageFactoryImpl.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:AnimatedImageFactoryWebPImplTest.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:AnimatedImageFactoryGifImplTest.java

示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:SvgDecoderExample.java


注:本文中的com.facebook.imagepipeline.common.ImageDecodeOptions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。