类com.bumptech.glide.load.resource.bitmap.StreamBitmapDecoder源码实例Demo

下面列出了怎么用com.bumptech.glide.load.resource.bitmap.StreamBitmapDecoder的API类实例代码及写法,或者点击链接到github查看源代码。


@Override
public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) {
  AttachmentSecret attachmentSecret = AttachmentSecretProvider.getInstance(context).getOrCreateAttachmentSecret();
  byte[]           secret           = attachmentSecret.getModernKey();

  registry.prepend(File.class, File.class, UnitModelLoader.Factory.getInstance());
  registry.prepend(InputStream.class, new EncryptedCacheEncoder(secret, glide.getArrayPool()));
  registry.prepend(File.class, Bitmap.class, new EncryptedBitmapCacheDecoder(secret, new StreamBitmapDecoder(new Downsampler(registry.getImageHeaderParsers(), context.getResources().getDisplayMetrics(), glide.getBitmapPool(), glide.getArrayPool()), glide.getArrayPool())));
  registry.prepend(File.class, GifDrawable.class, new EncryptedGifCacheDecoder(secret, new StreamGifDecoder(registry.getImageHeaderParsers(), new ByteBufferGifDecoder(context, registry.getImageHeaderParsers(), glide.getBitmapPool(), glide.getArrayPool()), glide.getArrayPool())));

  registry.prepend(BlurHash.class, Bitmap.class, new BlurHashResourceDecoder());

  registry.prepend(Bitmap.class, new EncryptedBitmapResourceEncoder(secret));
  registry.prepend(GifDrawable.class, new EncryptedGifDrawableResourceEncoder(secret));

  registry.append(ContactPhoto.class, InputStream.class, new ContactPhotoLoader.Factory(context));
  registry.append(DecryptableUri.class, InputStream.class, new DecryptableStreamUriLoader.Factory(context));
  registry.append(AttachmentModel.class, InputStream.class, new AttachmentStreamUriLoader.Factory());
  registry.append(ChunkedImageUrl.class, InputStream.class, new ChunkedImageUrlLoader.Factory());
  registry.append(StickerRemoteUri.class, InputStream.class, new StickerRemoteUriLoader.Factory());
  registry.append(BlurHash.class, BlurHash.class, new BlurHashModelLoader.Factory());
  registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory());
}
 
源代码2 项目: giffun   文件: BitmapRequestBuilder.java

BitmapRequestBuilder(LoadProvider<ModelType, ImageVideoWrapper, Bitmap, TranscodeType> loadProvider,
        Class<TranscodeType> transcodeClass, GenericRequestBuilder<ModelType, ?, ?, ?> other) {
    super(loadProvider, transcodeClass, other);
    this.bitmapPool = other.glide.getBitmapPool();
    this.decodeFormat =  other.glide.getDecodeFormat();

    imageDecoder = new StreamBitmapDecoder(bitmapPool, decodeFormat);
    videoDecoder = new FileDescriptorBitmapDecoder(bitmapPool, decodeFormat);
}
 

public EncryptedBitmapCacheDecoder(@NonNull byte[] secret, @NonNull StreamBitmapDecoder streamBitmapDecoder) {
  this.secret              = secret;
  this.streamBitmapDecoder = streamBitmapDecoder;
}
 
源代码4 项目: giffun   文件: BitmapRequestBuilder.java

/**
 * Load images using the given {@link Downsampler}. Replaces any existing image decoder. Defaults to
 * {@link Downsampler#AT_LEAST}. Will be ignored if the data represented by the model is a video. This replaces any
 * previous calls to {@link #imageDecoder(ResourceDecoder)}  and {@link #decoder(ResourceDecoder)} with default
 * decoders with the appropriate options set.
 *
 * @see #imageDecoder
 *
 * @param downsampler The downsampler.
 * @return This request builder.
 */
private BitmapRequestBuilder<ModelType, TranscodeType> downsample(Downsampler downsampler) {
    this.downsampler = downsampler;
    imageDecoder = new StreamBitmapDecoder(downsampler, bitmapPool, decodeFormat);
    super.decoder(new ImageVideoBitmapDecoder(imageDecoder, videoDecoder));
    return this;
}
 
 类所在包
 同包方法