com.bumptech.glide.load.resource.transcode.BitmapToGlideDrawableTranscoder Java Examples

The following examples show how to use com.bumptech.glide.load.resource.transcode.BitmapToGlideDrawableTranscoder. 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: GlideFilmstripManager.java    From Camera2 with Apache License 2.0 6 votes vote down vote up
public GlideFilmstripManager(Context context)
{
    Glide glide = Glide.get(context);
    BitmapEncoder bitmapEncoder = new BitmapEncoder(Bitmap.CompressFormat.JPEG,
            JPEG_COMPRESS_QUALITY);
    GifBitmapWrapperResourceEncoder drawableEncoder = new GifBitmapWrapperResourceEncoder(
            bitmapEncoder,
            new GifResourceEncoder(glide.getBitmapPool()));
    RequestManager request = Glide.with(context);

    mTinyImageBuilder = request
            .fromMediaStore()
            .asBitmap() // This prevents gifs from animating at tiny sizes.
            .transcode(new BitmapToGlideDrawableTranscoder(context), GlideDrawable.class)
            .fitCenter()
            .placeholder(DEFAULT_PLACEHOLDER_RESOURCE)
            .dontAnimate();

    mLargeImageBuilder = request
            .fromMediaStore()
            .encoder(drawableEncoder)
            .fitCenter()
            .placeholder(DEFAULT_PLACEHOLDER_RESOURCE)
            .dontAnimate();
}
 
Example #2
Source File: FullHintActivity.java    From hintcase with Apache License 2.0 6 votes vote down vote up
@NonNull
private ImageView getGifLoadedUsingGlide() {
    ImageView animatedImageView = new ImageView(getActivity());
    animatedImageView.setMaxHeight(900);
    Glide.with(getActivity())
            .load(R.drawable.animated_image)
            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .thumbnail(Glide.with(getActivity())
                    .load(R.drawable.animated_image)
                    .asBitmap()
                    .transcode(new BitmapToGlideDrawableTranscoder(getActivity()), GlideDrawable.class)
                    .diskCacheStrategy(DiskCacheStrategy.ALL)
            )
            .into(animatedImageView);
    return animatedImageView;
}
 
Example #3
Source File: GeneratingAdapter.java    From glide-support with The Unlicense 6 votes vote down vote up
public GeneratingAdapter(final Context context) {
	generator = Glide // this part should be cleaner in Glide 4.0, but that's not released yet
	                  .with(context)
	                  .using(new GeneratePassthroughModelLoader(), GenerateParams.class)          // custom class
	                  .from(GenerateParams.class)
	                  .as(Bitmap.class)
	                  .transcode(new BitmapToGlideDrawableTranscoder(context), GlideDrawable.class)     // builtin
	                  .decoder(new GenerateBitmapResourceDecoder(context))                        // custom class
	                  .encoder(new BitmapEncoder(Bitmap.CompressFormat.PNG, 0/*ignored for lossless*/)) // builtin
	                  .cacheDecoder(new FileToStreamDecoder<Bitmap>(new StreamBitmapDecoder(context)))  // builtin
	//.placeholder(new ColorDrawable(Color.YELLOW)) // you can pre-set placeholder and error
	//.error(new ColorDrawable(Color.RED))          // so it's easier when binding
	//.diskCacheStrategy(DiskCacheStrategy.NONE)    // only for debugging to always regenerate
	//.skipMemoryCache(true)                        // only for debugging to always regenerate
	;
}
 
Example #4
Source File: GlideImageGetter.java    From glide-support with The Unlicense 5 votes vote down vote up
private GenericRequestBuilder<String, ?, ?, GlideDrawable> createGlideRequest(RequestManager glide,
		boolean animated) {
	GenericRequestBuilder<String, ?, ?, GlideDrawable> load;
	if (animated) {
		load = glide
				.fromString()
				//".asDrawable()" default loading handles animated GIFs and still images as well
				.diskCacheStrategy(DiskCacheStrategy.SOURCE) // animated GIFs need source cache
				// show full image when animating
				.fitCenter()
		;
	} else {
		load = glide
				.fromString()
				// force still images
				.asBitmap()
				// make compatible with target
				.transcode(new BitmapToGlideDrawableTranscoder(context), GlideDrawable.class)
				// cache resized images (RESULT), and re-use SOURCE cached GIFs if any
				.diskCacheStrategy(DiskCacheStrategy.ALL)
				// show part of the image when still
				.centerCrop()
		;
	}
	return load
			// common settings
			.listener(new LoggingListener<String, GlideDrawable>())
			;
}