com.bumptech.glide.load.resource.bitmap.CenterCrop Java Examples
The following examples show how to use
com.bumptech.glide.load.resource.bitmap.CenterCrop.
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: GlideHelper.java From hipda with GNU General Public License v2.0 | 6 votes |
public static void loadAvatar(RequestManager glide, ImageView view, String avatarUrl) { avatarUrl = Utils.nullToText(avatarUrl); String cacheKey = AVATAR_CACHE_KEYS.get(avatarUrl); if (cacheKey == null) { cacheKey = avatarUrl; } if (HiSettingsHelper.getInstance().isCircleAvatar()) { glide.load(new AvatarModel(avatarUrl)) .signature(new ObjectKey(cacheKey)) .diskCacheStrategy(DiskCacheStrategy.NONE) .circleCrop() .error(DEFAULT_USER_ICON) .transition(DrawableTransitionOptions.withCrossFade()) .into(view); } else { glide.load(new AvatarModel(avatarUrl)) .signature(new ObjectKey(cacheKey)) .diskCacheStrategy(DiskCacheStrategy.NONE) .transform(new CenterCrop(), new RoundedCorners(Utils.dpToPx(4))) .error(DEFAULT_USER_ICON) .transition(DrawableTransitionOptions.withCrossFade()) .into(view); } }
Example #2
Source File: ImageViewerActivity.java From titanium-imagepicker with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private void setupGlideOptions() { options = new RequestOptions(); if (isShapeCircle) { if (Defaults.CIRCLE_RADIUS > 0) { options.transforms(new CenterCrop(), new RoundedCorners(Defaults.CIRCLE_RADIUS)); } else { options.circleCrop(); } } options.override(Defaults.IMAGE_HEIGHT, Defaults.IMAGE_HEIGHT); options.placeholder(placeholder_image); options.priority(Priority.HIGH); }
Example #3
Source File: ImagePickerActivity.java From titanium-imagepicker with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private void setupGlideOptions() { options = new RequestOptions(); int size; if (isShapeCircle) { if (Defaults.CIRCLE_RADIUS > 0) { size = (int) (0.65 * Defaults.IMAGE_HEIGHT); options.transforms(new CenterCrop(), new RoundedCorners(Defaults.CIRCLE_RADIUS)); } else { size = Defaults.IMAGE_HEIGHT; options.circleCrop(); } } else { size = (int) (0.65 * Defaults.IMAGE_HEIGHT); } options.override(size, size); options.error(error_image); options.priority(Priority.HIGH); }
Example #4
Source File: ImageViewerActivity.java From titanium-imagepicker with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private void setupGlideOptions() { options = new RequestOptions(); if (isShapeCircle) { if (Defaults.CIRCLE_RADIUS > 0) { options.transforms(new CenterCrop(), new RoundedCorners(Defaults.CIRCLE_RADIUS)); } else { options.circleCrop(); } } options.override(Defaults.IMAGE_HEIGHT, Defaults.IMAGE_HEIGHT); options.placeholder(placeholder_image); options.priority(Priority.HIGH); }
Example #5
Source File: ImagePickerActivity.java From titanium-imagepicker with Apache License 2.0 | 6 votes |
@SuppressWarnings({ "unchecked", "deprecation" }) private void setupGlideOptions() { options = new RequestOptions(); int size; if (isShapeCircle) { if (Defaults.CIRCLE_RADIUS > 0) { size = (int) (0.65 * Defaults.IMAGE_HEIGHT); options.transforms(new CenterCrop(), new RoundedCorners(Defaults.CIRCLE_RADIUS)); } else { size = Defaults.IMAGE_HEIGHT; options.circleCrop(); } } else { size = (int) (0.65 * Defaults.IMAGE_HEIGHT); } options.override(size, size); options.error(error_image); options.priority(Priority.HIGH); }
Example #6
Source File: StatusStoriesActivity.java From StatusStories with Apache License 2.0 | 6 votes |
@Override public void onNext() { storyStatusView.pause(); ++counter; target.setModel(statusResources[counter]); Glide.with(image.getContext()) .load(target.getModel()) .asBitmap() .crossFade() .centerCrop() .skipMemoryCache(!isCaching) .diskCacheStrategy(isCaching ? DiskCacheStrategy.ALL : DiskCacheStrategy.NONE) .transform(new CenterCrop(image.getContext()), new DelayBitmapTransformation(1000)) .listener(new LoggingListener<String, Bitmap>()) .into(target); }
Example #7
Source File: StatusStoriesActivity.java From StatusStories with Apache License 2.0 | 6 votes |
@Override public void onPrev() { if (counter - 1 < 0) return; storyStatusView.pause(); --counter; target.setModel(statusResources[counter]); Glide.with(image.getContext()) .load(target.getModel()) .asBitmap() .centerCrop() .crossFade() .skipMemoryCache(!isCaching) .diskCacheStrategy(isCaching ? DiskCacheStrategy.ALL : DiskCacheStrategy.NONE) .transform(new CenterCrop(image.getContext()), new DelayBitmapTransformation(1000)) .listener(new LoggingListener<String, Bitmap>()) .into(target); }
Example #8
Source File: ScheduleNewAdapter.java From AcgClub with MIT License | 6 votes |
@Override protected void convert(BaseViewHolder helper, ScheduleNewItem item) { helper.setText(R.id.schedule_new_title, item.getTitle()) .setText(R.id.schedule_new_spot, item.getSpot()) .setText(R.id.schedule_new_type, item.getType()) .setText(R.id.schedule_new_desc, item.getDesc()); mImageLoader.loadImage(getContext(), GlideImageConfig .builder() .url(item.getImgUrl()) .transformation( new MultiTransformation<>(new CenterCrop(), new RoundedCornersTransformation(DimenUtils.dpToPx(getContext(), 4), 0))) .imageView((ImageView) helper.getView(R.id.schedule_new_img)) .build() ); }
Example #9
Source File: ImageLoader.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
public Target<Drawable> loadWithColorPlaceholderRoundCorners(String image, int radius, ImageView previewImage, @AttrRes int colorResource, RequestListener<Drawable> requestListener) { Context context = weakContext.get(); if (context != null) { return Glide.with(context) .load(image) .apply(getRequestOptions().centerCrop() .placeholder(new ColorDrawable(getAttrColor(colorResource))) .transforms(new CenterCrop(), new RoundedCorners(radius))) .listener(requestListener) .transition(DrawableTransitionOptions.withCrossFade()) .into(previewImage); } return null; }
Example #10
Source File: TestFragment.java From glide-support with The Unlicense | 6 votes |
@Override protected void load(Context context) throws Exception { String url = "http://placehold.it/3000x2000/AAFF00/000000&text=IMAGE"; int[] requestedSize = new int[] {540, 540}; Glide .with(this) .load(url) .override(requestedSize[0], requestedSize[1]) .transform(new DelayBitmapTransformation(3000), new CenterCrop(context)) .skipMemoryCache(true) .diskCacheStrategy(NONE) .listener(new LoggingListener<String, GlideDrawable>()) .thumbnail(Glide .with(this) .load(url) .override(512, 384) .transform(new DelayBitmapTransformation(1000), new CenterCrop(context)) .skipMemoryCache(true) .diskCacheStrategy(NONE) .listener(new LoggingListener<String, GlideDrawable>()) ) .into(imageView) ; }
Example #11
Source File: ThumbnailView.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
public ListenableFuture<Boolean> setImageResource(@NonNull GlideRequests glideRequests, @NonNull Uri uri, int width, int height) { SettableFuture<Boolean> future = new SettableFuture<>(); if (transferControls.isPresent()) getTransferControls().setVisibility(View.GONE); GlideRequest request = glideRequests.load(new DecryptableUri(uri)) .diskCacheStrategy(DiskCacheStrategy.NONE) .transition(withCrossFade()); if (width > 0 && height > 0) { request = request.override(width, height); } if (radius > 0) { request = request.transforms(new CenterCrop(), new RoundedCorners(radius)); } else { request = request.transforms(new CenterCrop()); } request.into(new GlideDrawableListeningTarget(image, future)); blurhash.setImageDrawable(null); return future; }
Example #12
Source File: ThumbnailView.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
public ThumbnailView(final Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); inflate(context, R.layout.thumbnail_view, this); this.image = findViewById(R.id.thumbnail_image); this.blurhash = findViewById(R.id.thumbnail_blurhash); this.playOverlay = findViewById(R.id.play_overlay); this.captionIcon = findViewById(R.id.thumbnail_caption_icon); super.setOnClickListener(new ThumbnailClickDispatcher()); if (attrs != null) { TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ThumbnailView, 0, 0); bounds[MIN_WIDTH] = typedArray.getDimensionPixelSize(R.styleable.ThumbnailView_minWidth, 0); bounds[MAX_WIDTH] = typedArray.getDimensionPixelSize(R.styleable.ThumbnailView_maxWidth, 0); bounds[MIN_HEIGHT] = typedArray.getDimensionPixelSize(R.styleable.ThumbnailView_minHeight, 0); bounds[MAX_HEIGHT] = typedArray.getDimensionPixelSize(R.styleable.ThumbnailView_maxHeight, 0); radius = typedArray.getDimensionPixelSize(R.styleable.ThumbnailView_thumbnail_radius, getResources().getDimensionPixelSize(R.dimen.thumbnail_default_radius)); fit = typedArray.getInt(R.styleable.ThumbnailView_thumbnail_fit, 0) == 1 ? new FitCenter() : new CenterCrop(); typedArray.recycle(); } else { radius = getResources().getDimensionPixelSize(R.dimen.message_corner_collapse_radius); } }
Example #13
Source File: ImageLoader.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
public Target<Drawable> loadWithRoundCorners(String image, int radius, ImageView previewImage, @AttrRes int placeHolderDrawableId, RequestListener<Drawable> requestListener) { Context context = weakContext.get(); if (context != null) { return Glide.with(context) .load(image) .apply(getRequestOptions().centerCrop() .placeholder(getAttrDrawable(placeHolderDrawableId)) .transforms(new CenterCrop(), new RoundedCorners(radius))) .listener(requestListener) .transition(DrawableTransitionOptions.withCrossFade()) .into(previewImage); } return null; }
Example #14
Source File: GlideLoader.java From XDroidMvp with MIT License | 5 votes |
@Override public void loadCorner(String url, final ImageView target, int radius, Options options) { RequestOptions requestOptions = wrapScaleType(options); //设置图片圆角角度 MultiTransformation multiTransformation = new MultiTransformation<Bitmap>(new CenterCrop(), new RoundedCorners(radius)); requestOptions.transform(multiTransformation); getRequestManager(target.getContext()) .load(url) .apply(requestOptions) .transition(withCrossFade()) .into(target); }
Example #15
Source File: TestFragment.java From glide-support with The Unlicense | 5 votes |
void bind(String url) { target.setModel(url); // update target's cache Glide .with(image.getContext()) .load(url) .asBitmap() .placeholder(R.drawable.github_232_progress) .centerCrop() // needs explicit transformation, because we're using a custom target .transform(new CenterCrop(image.getContext()), new DelayBitmapTransformation(1000)) .listener(new LoggingListener<String, Bitmap>()) .into(target) ; }
Example #16
Source File: GlideUtil.java From Android-IM with Apache License 2.0 | 5 votes |
/** * 加载自定义封面带圆角 * * @param context 上下文 * @param imgUrl 图片链接 * @param cornerRadius 圆角弧度 * @param imageView view */ public static void loadCornerPicture(Context context, String imgUrl, int cornerRadius, ImageView imageView) { Glide.with(context) .load(imgUrl) .apply(new RequestOptions().error(R.drawable.icon_user)) .apply(RequestOptions.bitmapTransform(new MultiTransformation<Bitmap>(new CenterCrop(), new RoundedCornersTransformation(ConvertUtils.dp2px(cornerRadius), 0)))) .into(imageView); }
Example #17
Source File: GlideUtil.java From Android-IM with Apache License 2.0 | 5 votes |
public static void loadCornerPicture(Context context, String imgUrl, int cornerRadius, int errorResourceId, ImageView imageView) { Glide.with(context) .load(imgUrl) .apply(new RequestOptions().error(errorResourceId)) .apply(RequestOptions.bitmapTransform(new MultiTransformation<Bitmap>(new CenterCrop(), new RoundedCornersTransformation(ConvertUtils.dp2px(cornerRadius), 0)))) .into(imageView); }
Example #18
Source File: GlideUtil.java From Android-IM with Apache License 2.0 | 5 votes |
public static void loadCornerPicture(Context context, String imgUrl, ImageView imageView, int resourceId) { Glide.with(context) .load(imgUrl) .apply(new RequestOptions().error(resourceId)) .apply(RequestOptions.bitmapTransform(new MultiTransformation<Bitmap>(new CenterCrop(), new RoundedCornersTransformation(ConvertUtils.dp2px(4), 0)))) .into(imageView); }
Example #19
Source File: GlideUtil.java From Android-IM with Apache License 2.0 | 5 votes |
/** * 加载圆角封面,默认4dp */ public static void loadCornerPicture(Context context, String imgUrl, ImageView imageView) { Glide.with(context) .load(imgUrl) .apply(new RequestOptions().error(R.drawable.icon_user)) .apply(RequestOptions.bitmapTransform(new MultiTransformation<Bitmap>(new CenterCrop(), new RoundedCornersTransformation(ConvertUtils.dp2px(4), 0)))) .into(imageView); }
Example #20
Source File: PickerLoader.java From VMLibrary with Apache License 2.0 | 5 votes |
/** * 通过上下文对象加载图片 * * @param context 上下文对象 * @param options 加载配置 * @param imageView 目标控件 */ @Override public void load(Context context, Options options, ImageView imageView) { RequestOptions requestOptions = new RequestOptions(); if (options.isCircle) { requestOptions.circleCrop(); } else if (options.isRadius) { requestOptions.transform(new MultiTransformation<>(new CenterCrop(), new RoundedCorners(options.radiusSize))); } GlideApp.with(context).load(options.url).apply(requestOptions).into(imageView); }
Example #21
Source File: ThumbnailView.java From deltachat-android with GNU General Public License v3.0 | 5 votes |
public ListenableFuture<Boolean> setImageResource(@NonNull GlideRequests glideRequests, @NonNull Uri uri) { SettableFuture<Boolean> future = new SettableFuture<>(); glideRequests.load(new DecryptableUri(uri)) .diskCacheStrategy(DiskCacheStrategy.NONE) .transforms(new CenterCrop(), new RoundedCorners(radius)) .transition(withCrossFade()) .into(new GlideDrawableListeningTarget(image, future)); return future; }
Example #22
Source File: GlideImageLoader.java From NIM_Android_UIKit with MIT License | 5 votes |
@Override public void displayImage(Context context, String path, ImageView imageView, int width, int height) { RequestOptions options = new RequestOptions() .placeholder(R.drawable.nim_placeholder_normal_impl) //设置占位图片 .error(R.drawable.nim_placeholder_normal_impl) //设置错误图片 .diskCacheStrategy(DiskCacheStrategy.ALL) .transforms(new CenterCrop(), new RoundedCorners(ScreenUtil.dip2px(4))) .override(width, height) .dontAnimate(); //缓存全尺寸 Glide.with(context) //配置上下文 .asDrawable() .apply(options) .load(Uri.fromFile(new File(path))) //设置图片路径(fix #8,文件名包含%符号 无法识别和显示) .into(imageView); }
Example #23
Source File: GlideImageLoader.java From NIM_Android_UIKit with MIT License | 5 votes |
private static void displayAlbum(ImageView imageView, String path, Transformation<Bitmap> transformation, int placeHoder) { Context context = imageView.getContext(); RequestOptions options = new RequestOptions().error(placeHoder).placeholder(placeHoder).diskCacheStrategy( DiskCacheStrategy.RESOURCE); if (transformation != null) { options = options.transforms(new CenterCrop(), transformation); } else { options = options.transform(new CenterCrop()); } Glide.with(context).asDrawable().apply(options).load(Uri.fromFile(new File(path))).into(imageView); }
Example #24
Source File: ImageLoadUtils.java From Tok-Android with GNU General Public License v3.0 | 5 votes |
public static void loadMask(Context context, String path, ImageView imgView, int maskResId) { LogUtil.i(TAG, "loadMask path:" + path); Glide.with(context) .setDefaultRequestOptions(getOptions()) .load(path) .apply(RequestOptions.bitmapTransform( new MultiTransformation<>(new CenterCrop(), new MaskTransformation(maskResId)))) .thumbnail(THUMB_NAIL) .into(imgView); }
Example #25
Source File: NewsGlideModule.java From NewsApp with GNU General Public License v3.0 | 5 votes |
@NonNull @GlideOption public static RequestOptions roundedCornerImage(RequestOptions options, @NonNull Context context, int radius) { if (radius > 0) { int px = Math.round(radius * (context.getResources().getDisplayMetrics().xdpi / DisplayMetrics.DENSITY_DEFAULT)); return options.transforms(new CenterCrop(), new RoundedCorners(px)); } return options.transforms(new CenterCrop()); }
Example #26
Source File: ProfileUtils.java From imsdk-android with MIT License | 5 votes |
public static void displayGravatarByImageSrc(final Activity context, final String imageSrc, final ImageView headView, final int w, final int h){ if(context == null){ return; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { if(context.isDestroyed()){ return; } } if(TextUtils.isEmpty(imageSrc) || headView == null){ return; } context.runOnUiThread(new Runnable() { @Override public void run() { //glide Glide.with(context) // .load(imageSrc)//配置上下文 .load(new MyGlideUrl(imageSrc)) //设置图片路径(fix #8,文件名包含%符号 无法识别和显示) .asBitmap() // .error(defaultRes) .centerCrop() .thumbnail(0.1f) .transform(new CenterCrop(context) ,new GlideCircleTransform(context)) .placeholder(defaultRes) .override(w > 0 ? w + 5 : Target.SIZE_ORIGINAL, h > 0 ? h + 5 : Target.SIZE_ORIGINAL) .diskCacheStrategy(DiskCacheStrategy.SOURCE)//缓存全尺寸 .dontAnimate() .into(headView); } }); }
Example #27
Source File: ThumbnailView.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private RequestBuilder buildPlaceholderGlideRequest(@NonNull GlideRequests glideRequests, @NonNull Slide slide) { GlideRequest<Bitmap> bitmap = glideRequests.asBitmap(); BlurHash placeholderBlur = slide.getPlaceholderBlur(); if (placeholderBlur != null) { bitmap = bitmap.load(placeholderBlur); } else { bitmap = bitmap.load(slide.getPlaceholderRes(getContext().getTheme())); } return applySizing(bitmap.diskCacheStrategy(DiskCacheStrategy.NONE), new CenterCrop()); }
Example #28
Source File: ScheduleRecommandAdapter.java From AcgClub with MIT License | 5 votes |
@Override protected void convert(BaseViewHolder helper, ScheduleRecommend item) { helper.setText(R.id.tv_schedule_recommand, item.getName()); mImageLoader.loadImage(getContext(), GlideImageConfig .builder() .url(item.getImgUrl()) .transformation( new MultiTransformation<>(new CenterCrop(), new RoundedCornersTransformation(20, 0))) .imageView((ImageView) helper.getView(R.id.img_schedule_recommand)) .build() ); }
Example #29
Source File: ScheduleCollectionAdapter.java From AcgClub with MIT License | 5 votes |
@Override protected void convert(BaseViewHolder helper, ScheduleCache item) { helper.setText(R.id.tv_schedule_collection_name, item.getName()); mImageLoader.loadImage(getContext(), GlideImageConfig .builder() .url(item.getImgUrl()) .transformation( new MultiTransformation<>(new CenterCrop(), new RoundedCornersTransformation(DimenUtils.dpToPx(getContext(), 4), 0))) .imageView((ImageView) helper.getView(R.id.img_schedule_collection)) .build() ); }
Example #30
Source File: Camera1Fragment.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private void onCaptureClicked() { orderEnforcer.reset(); Stopwatch fastCaptureTimer = new Stopwatch("Capture"); camera.capture((jpegData, frontFacing) -> { fastCaptureTimer.split("captured"); Transformation<Bitmap> transformation = frontFacing ? new MultiTransformation<>(new CenterCrop(), new FlipTransformation()) : new CenterCrop(); GlideApp.with(this) .asBitmap() .load(jpegData) .transform(transformation) .override(cameraPreview.getWidth(), cameraPreview.getHeight()) .into(new SimpleTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { fastCaptureTimer.split("transform"); ByteArrayOutputStream stream = new ByteArrayOutputStream(); resource.compress(Bitmap.CompressFormat.JPEG, 80, stream); fastCaptureTimer.split("compressed"); byte[] data = stream.toByteArray(); fastCaptureTimer.split("bytes"); fastCaptureTimer.stop(TAG); controller.onImageCaptured(data, resource.getWidth(), resource.getHeight()); } @Override public void onLoadFailed(@Nullable Drawable errorDrawable) { controller.onCameraError(); } }); }); }