com.bumptech.glide.load.resource.bitmap.StreamBitmapDecoder Java Examples

The following examples show how to use com.bumptech.glide.load.resource.bitmap.StreamBitmapDecoder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SignalGlideModule.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
@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());
}
 
Example #2
Source File: BitmapRequestBuilder.java    From giffun with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #3
Source File: EncryptedBitmapCacheDecoder.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
public EncryptedBitmapCacheDecoder(@NonNull byte[] secret, @NonNull StreamBitmapDecoder streamBitmapDecoder) {
  this.secret              = secret;
  this.streamBitmapDecoder = streamBitmapDecoder;
}
 
Example #4
Source File: BitmapRequestBuilder.java    From giffun with Apache License 2.0 3 votes vote down vote up
/**
 * 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;
}