private static <T> Bitmap createScaledBitmapInto(Context context, T model, int width, int height) throws BitmapDecodingException { final Bitmap rough = Downsampler.AT_LEAST.decode(getInputStreamForModel(context, model), Glide.get(context).getBitmapPool(), width, height, DecodeFormat.PREFER_RGB_565); final Resource<Bitmap> resource = BitmapResource.obtain(rough, Glide.get(context).getBitmapPool()); final Resource<Bitmap> result = new FitCenter(context).transform(resource, width, height); if (result == null) { throw new BitmapDecodingException("unable to transform Bitmap"); } return result.get(); }
private static <T> Bitmap createScaledBitmapInto(Context context, T model, int width, int height) throws BitmapDecodingException { final Bitmap rough = Downsampler.AT_LEAST .decode(getInputStreamForModel(context, model), Glide.get(context).getBitmapPool(), width, height, DecodeFormat.PREFER_RGB_565); final Resource<Bitmap> resource = BitmapResource .obtain(rough, Glide.get(context).getBitmapPool()); final Resource<Bitmap> result = new FitCenter(context).transform(resource, width, height); if (result == null) { throw new BitmapDecodingException("unable to transform Bitmap"); } return result.get(); }
@Override protected void convert(BaseBindHolder helper, WeatherDailyResponse.DailyResult.Daily item) { ViewDataBinding binding = helper.getBinding(); binding.setVariable(BR.daily, item); binding.executePendingBindings(); SuperTextView superTextView = helper.getView(R.id.super_item_daily); ArmsUtils.INSTANCE.obtainArmsComponent(mContext).imageLoader() .loadImage(mContext, ImageConfigImpl.builder() .url(String.format(Locale.CHINESE, Api.API_WEATHER_ICON_URL, item.getCodeDay())) .placeholder(R.mipmap.ic_placeholder) .errorPic(R.mipmap.weather_unknown) .transformation(new FitCenter()) .imageView(superTextView.getRightIconIV()) .build()); }
@Override protected void load(Context context) throws Exception { String urlString = "http://web.twisterrob.net/glide/1257_changing.php"; Glide .with(this) .load(new ForceLoadGlideUrl(urlString)) .fitCenter() .diskCacheStrategy(DiskCacheStrategy.NONE) .skipMemoryCache(true) //.placeholder(R.drawable.glide_placeholder) //.error(R.drawable.glide_error) .listener(new LoggingListener<GlideUrl, GlideDrawable>("full")) .thumbnail(Glide .with(this) .load(new CachedGlideUrl(urlString)) .diskCacheStrategy(DiskCacheStrategy.NONE) .skipMemoryCache(true) .listener(new LoggingListener<GlideUrl, GlideDrawable>("thumbnail")) .bitmapTransform(new FitCenter(context), new GrayscaleTransformation(context)) .sizeMultiplier(0.25f) ) .into(imageView); }
void bind(ChatMessage message) { nameView.setText(message.getUserName()); Context context = avatarView.getContext(); glide.load(message.getAvatarUrl()) .bitmapTransform(new FitCenter(context), new CropCircleTransformation(context)) .listener(new LoggingListener<String, GlideDrawable>()) .into(avatarView); bindEmoticonMessage(messageView, message.getMessage()); }
@Override protected void load(Context context) throws Exception { Glide .with(context) .load(R.drawable.glide) .diskCacheStrategy(DiskCacheStrategy.NONE) // necessary only because I'm loading an APK resource .skipMemoryCache(true) // remove in production, this is just there so it's reproducible quickly .placeholder(R.drawable.glide_placeholder) // delay to see what's going on, in normal usage replace this with .fitCenter() .transform(new FitCenter(context), new DelayBitmapTransformation(1000)) .animate(new PaddingAnimationFactory<>(new DrawableCrossFadeFactory<GlideDrawable>(2000))) .into(imageView) ; }
public DrawableRequestBuilder<ModelType> fitCenter() { return bitmapTransform(new FitCenter(glide.getBitmapPool())); }
/** * Construct a standard ImageLoader object. */ public ImageLoader(Context context) { requestManager = Glide.with(context); mCenterCrop = new CenterCrop(Glide.get(context).getBitmapPool()); mFitCenter = new FitCenter(Glide.get(context).getBitmapPool()); }
/** * Applies {@link com.bumptech.glide.load.resource.bitmap.FitCenter} to all default types, and * ignores unknown types. * * <p>This will override previous calls to {@link #dontTransform()}. * * @see #optionalTransform(Class, Transformation) * @see #fitCenter() */ public RequestOptions optionalFitCenter() { return optionalTransform(DownsampleStrategy.FIT_CENTER, new FitCenter()); }
/** * Applies {@link FitCenter} to all default types and * throws an exception if asked to transform an unknown type. * * <p>This will override previous calls to {@link #dontTransform()}. * * @see #transform(Class, Transformation) * @see #optionalFitCenter() */ public RequestOptions fitCenter() { return transform(DownsampleStrategy.FIT_CENTER, new FitCenter()); }
/** * * Applies {@link FitCenter} and to all default types, {@link DownsampleStrategy#FIT_CENTER} to * image types, and ignores unknown types. * * <p>This will override previous calls to {@link #dontTransform()} and previous calls to * {@link #downsample(DownsampleStrategy)}. * * @see #optionalTransform(Class, Transformation) * @see #fitCenter() */ @CheckResult public RequestOptions optionalFitCenter() { return optionalScaleOnlyTransform(DownsampleStrategy.FIT_CENTER, new FitCenter()); }
/** * Applies {@link FitCenter} and to all default types, {@link DownsampleStrategy#FIT_CENTER} to * image types, and throws an exception if asked to transform an unknown * type. * * <p>This will override previous calls to {@link #dontTransform()} and previous calls to * {@link #downsample(DownsampleStrategy)}. * * @see #transform(Class, Transformation) * @see #optionalFitCenter() */ @CheckResult public RequestOptions fitCenter() { return scaleOnlyTransform(DownsampleStrategy.FIT_CENTER, new FitCenter()); }
/** * Transform images using {@link FitCenter}. * * @return This RequestBuilder */ public BitmapRequestBuilder<ModelType, TranscodeType> fitCenter() { return transform(new FitCenter(bitmapPool)); }