Java 类com.bumptech.glide.load.resource.bitmap.CenterCrop 实例源码

项目:StatusStories    文件:StatusStoriesActivity.java   
@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);
}
项目:StatusStories    文件:StatusStoriesActivity.java   
@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);
}
项目:RetrofitSample    文件:DataBindingAdapter.java   
@BindingAdapter(value = {"imageUrl", "defaultImg", "radius"}, requireAll = false)
public static void setImage(ImageView imageView, String imageUrl, Drawable defaultImg, int radius) {
    DrawableRequestBuilder drawableTypeRequest = Glide.with(imageView.getContext()).load(imageUrl).crossFade();
    if (defaultImg != null) {
        drawableTypeRequest.placeholder(defaultImg).error(defaultImg);
    } else {
        drawableTypeRequest.placeholder(R.drawable.bg_defautl_imageview).error(R.drawable.bg_defautl_imageview);
    }
    if (radius > 0) {
        drawableTypeRequest.bitmapTransform(new CenterCrop(imageView.getContext()),
                new RoundedCornersTransformation(imageView.getContext(), PixelUtil.dp2px(radius), 0));
    } else {
        drawableTypeRequest.bitmapTransform(new CenterCrop(imageView.getContext()));
    }
    drawableTypeRequest.into(imageView);
}
项目:titanium-android-imagepicker    文件:ImageViewerActivity.java   
@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);
}
项目:titanium-android-imagepicker    文件:ImagePickerActivity.java   
@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);
   }
项目:CXJPadProject    文件:CXPImageLoaderUtil.java   
/**
 * 异步加载圆角图片, 使用 Glide 内置的圆角裁剪 —— bitmapTransform.
 *
 * 注意: bitmapTransform 与 外在的裁剪不兼容。即: https://github.com/wasabeef/glide-transformations/issues/54
 *
 *      1. 此时的 imageView 不能是自定义的圆角View.
 *      2. scaleType 也不能设。
 *
 * 否则重复裁剪, 会有 bug.
 *
 * @param url 图片路径
 * @param drawableId 占位图
 * @param radiusPixels 圆角像素值
 */
public static void loadRoundImage(ImageView imageView, String url, int drawableId, int radiusPixels) {
    if(imageView == null) {
        Log.e(TAG, "loadRoundImage() -> imageView is null");
        return;
    }

    Context context = imageView.getContext();
    if(!isValid(context))
        return ;

    Glide.with(context)
            .load(url)
            .placeholder(drawableId)
            .error(drawableId)
            .bitmapTransform(
                    new CenterCrop(context),
                    new RoundedCornersTransformation(context, radiusPixels, 0)
            )
            .crossFade()
            .into(imageView);
}
项目:glide-support    文件:TestFragment.java   
@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)
    ;
}
项目:GitHub    文件:RequestOptionsTest.java   
@Test
@SuppressWarnings({"unchecked", "varargs"})
public void testApplyMultiTransform() {
  options.transforms(new CircleCrop(), new CenterCrop());
  assertThat(options.isTransformationRequired()).isTrue();
  assertThat(options.getTransformations()).containsKey(Bitmap.class);
  assertThat(options.getTransformations().get(Bitmap.class))
    .isInstanceOf(MultiTransformation.class);
}
项目:aptoide-client-v8    文件:ImageLoader.java   
public void loadWithRoundCorners(String image, int radius, int margin, ImageView previewImage) {
  Context context = weakContext.get();
  if (context != null) {
    Glide.with(context)
        .load(image)
        .centerCrop()
        .bitmapTransform(new CenterCrop(context),
            new RoundedCornersTransform(context, radius, margin,
                RoundedCornersTransform.CornerType.LEFT))
        .into(previewImage);
  }
}
项目:glide-support    文件:TestFragment.java   
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)
    ;
}
项目:saarang-iosched    文件:ImageLoader.java   
/**
 * Construct a standard ImageLoader object.
 */
public ImageLoader(Context context) {
    VariableWidthImageLoader imageLoader = new VariableWidthImageLoader(context);
    mGlideModelRequest = Glide.with(context).using(imageLoader);
    mCenterCrop = new CenterCrop(Glide.get(context).getBitmapPool());
    mNone = Transformation.NONE;
}
项目:AppDevFestSudeste2015    文件:ImageLoader.java   
/**
 * Construct a standard ImageLoader object.
 */
public ImageLoader(Context context) {
    VariableWidthImageLoader imageLoader = new VariableWidthImageLoader(context);
    mGlideModelRequest = Glide.with(context).using(imageLoader);
    mCenterCrop = new CenterCrop(Glide.get(context).getBitmapPool());
    mNone = Transformation.NONE;
}
项目:gankmaku    文件:FuliAdapter.java   
@Override public void onBindViewHolder(ViewHolder vh, int i) {
  Glide.with(mContext).load(mResponse.getResults().get(i).getUrl()).bitmapTransform(
      new CenterCrop(mPool), new RoundedCornersTransformation(mPool, 8, 0))
      //.crossFade()
      .listener(
          GlidePalette.with(mResponse.getResults().get(i).getUrl()).intoCallBack(palette -> {
                if (mPaletteCallback != null) mPaletteCallback.onPaletteReady(i, palette);
              })).diskCacheStrategy(DiskCacheStrategy.ALL).into(vh.meiZi);
}
项目:devfestnorte-app    文件:ImageLoader.java   
/**
 * Construct a standard ImageLoader object.
 */
public ImageLoader(Context context) {
    VariableWidthImageLoader imageLoader = new VariableWidthImageLoader(context);
    mGlideModelRequest = Glide.with(context).using(imageLoader);
    mCenterCrop = new CenterCrop(Glide.get(context).getBitmapPool());
    mNone = Transformation.NONE;
}
项目:saarang-iosched    文件:ImageLoader.java   
/**
 * Construct a standard ImageLoader object.
 */
public ImageLoader(Context context) {
    VariableWidthImageLoader imageLoader = new VariableWidthImageLoader(context);
    mGlideModelRequest = Glide.with(context).using(imageLoader);
    mCenterCrop = new CenterCrop(Glide.get(context).getBitmapPool());
    mNone = Transformation.NONE;
}
项目:RetrofitSample    文件:GlideUtil.java   
public static void loadAvatarUrlWithRadius(String imgUrl, ImageView imageView) {
    loadAvatarUrlToReqBuilder(imgUrl, imageView)
            .bitmapTransform(new CenterCrop(imageView.getContext()),
                    new RoundedCornersTransformation(imageView.getContext(), 8, 0))
            .into(imageView);
}
项目:RetrofitSample    文件:GlideUtil.java   
public static void loadAvatarUrlWithRadius(String imgUrl, ImageView imageView, @DrawableRes int drawableRes) {
    loadAvatarUrlToReqBuilder(imgUrl, imageView, drawableRes)
            .bitmapTransform(new CenterCrop(imageView.getContext()),
                    new RoundedCornersTransformation(imageView.getContext(), 8, 0))
            .into(imageView);
}
项目:Plamber-Android    文件:Utils.java   
public void initBackgroundImage(ImageView background) {
    Glide.with(context).load(R.drawable.main_background)
            .apply(new RequestOptions().transform(new CenterCrop())).into(background);
}
项目:Plamber-Android    文件:BaseDrawerActivity.java   
private void setHeaderBackground() {
    ImageView headerImage = (ImageView) mNavigationView.getHeaderView(0).findViewById(R.id.nav_header_image);
    Glide.with(getApplicationContext()).load(R.drawable.main_background).apply(new RequestOptions().transform(new CenterCrop())).into(headerImage);
}
项目:Plamber-Android    文件:BookReaderActivity.java   
private void setHeaderBackground() {
    ImageView headerImage = (ImageView) mNavigationView.getHeaderView(0).findViewById(R.id.nav_reader_header_image);
    Glide.with(getApplicationContext()).load(R.drawable.main_background).apply(new RequestOptions().transform(new CenterCrop())).into(headerImage);
}
项目:iosched-reader    文件:ImageLoader.java   
/**
 * Construct a standard ImageLoader object.
 */
public ImageLoader(Context context) {
    VariableWidthImageLoader imageLoader = new VariableWidthImageLoader(context);
    mGlideModelRequest = Glide.with(context).using(imageLoader).from(String.class).asBitmap();
    mCenterCrop = new CenterCrop(Glide.get(context).getBitmapPool());
}
项目:smconf-android    文件:ImageLoader.java   
/**
 * Construct a standard ImageLoader object.
 */
public ImageLoader(Context context) {
    VariableWidthImageLoader imageLoader = new VariableWidthImageLoader(context);
    mGlideModelRequest = Glide.with(context).using(imageLoader).from(String.class).asBitmap();
    mCenterCrop = new CenterCrop(Glide.get(context).getBitmapPool());
}
项目:RetailStore    文件:ImageLoader.java   
/**
 * Construct a standard ImageLoader object.
 */
public ImageLoader(Context context) {
    VariableWidthImageLoader imageLoader = new VariableWidthImageLoader(context);
    mGlideModelRequest = Glide.with(context).using(imageLoader).from(String.class).asBitmap();
    mCenterCrop = new CenterCrop(Glide.get(context).getBitmapPool());
}
项目:2015-Google-I-O-app    文件:ImageLoader.java   
/**
 * Construct a standard ImageLoader object.
 */
public ImageLoader(Context context) {
    VariableWidthImageLoader imageLoader = new VariableWidthImageLoader(context);
    mGlideModelRequest = Glide.with(context).using(imageLoader).from(String.class).asBitmap();
    mCenterCrop = new CenterCrop(Glide.get(context).getBitmapPool());
}
项目:FMTech    文件:ImageLoader.java   
/**
 * Construct a standard ImageLoader object.
 */
public ImageLoader(Context context) {
    VariableWidthImageLoader imageLoader = new VariableWidthImageLoader(context);
    mGlideModelRequest = Glide.with(context).using(imageLoader).from(String.class).asBitmap();
    mCenterCrop = new CenterCrop(Glide.get(context).getBitmapPool());
}
项目:ship-android-fast    文件:GlideImageLoader.java   
@Inject
GlideImageLoader(Context context) {
  this.glideModelRequest = Glide.with(context).from(String.class).asBitmap();
  this.centerCrop = new CenterCrop(Glide.get(context).getBitmapPool());
}
项目:saarang-iosched    文件:DrawableRequestBuilder.java   
public DrawableRequestBuilder<ModelType> centerCrop() {
    return bitmapTransform(new CenterCrop(glide.getBitmapPool()));
}
项目:AppDevFestSudeste2015    文件:DrawableRequestBuilder.java   
public DrawableRequestBuilder<ModelType> centerCrop() {
    return bitmapTransform(new CenterCrop(glide.getBitmapPool()));
}
项目:JJCamera    文件:ImageLoader.java   
/**
 * Construct a standard ImageLoader object.
 */
public ImageLoader(Context context) {
    VariableWidthImageLoader imageLoader = new VariableWidthImageLoader(context);
    mGlideModelRequest = Glide.with(context).using(imageLoader).from(String.class).asBitmap();
    mCenterCrop = new CenterCrop(Glide.get(context).getBitmapPool());
}
项目:gankmaku    文件:FuliAdapter.java   
@Override public GenericRequestBuilder getPreloadRequestBuilder(Entry item) {
  return Glide.with(mContext).load(item.getUrl()).bitmapTransform(new CenterCrop(mPool),
      new RoundedCornersTransformation(mPool, 8, 0))
      //.crossFade()
      .diskCacheStrategy(DiskCacheStrategy.ALL);
}
项目:iosched    文件:ImageLoader.java   
/**
 * Construct a standard ImageLoader object.
 */
public ImageLoader(Context context) {
    VariableWidthImageLoader imageLoader = new VariableWidthImageLoader(context);
    mGlideModelRequest = Glide.with(context).using(imageLoader).from(String.class).asBitmap();
    mCenterCrop = new CenterCrop(Glide.get(context).getBitmapPool());
}
项目:devfestnorte-app    文件:DrawableRequestBuilder.java   
public DrawableRequestBuilder<ModelType> centerCrop() {
    return bitmapTransform(new CenterCrop(glide.getBitmapPool()));
}
项目:saarang-iosched    文件:DrawableRequestBuilder.java   
public DrawableRequestBuilder<ModelType> centerCrop() {
    return bitmapTransform(new CenterCrop(glide.getBitmapPool()));
}
项目:v2ex    文件:ImageLoader.java   
/**
 * 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());
}
项目:utilsLibrary    文件:ImageLoader.java   
/**
 * 加载圆角图
 *
 * @param context
 * @param imgUrl
 * @param placeholder
 * @param imageView
 * @param radiusDp
 */
public static void loadRound(Context context, String imgUrl, @DrawableRes int placeholder, ImageView imageView, int radiusDp) {
    Glide.with(context)
            .load(imgUrl)
            .placeholder(placeholder)
            .error(placeholder)
            .transform(new CenterCrop(context), new GlideRoundTransform(context, radiusDp))
            .into(imageView);
}
项目:GitHub    文件:RequestOptions.java   
/**
 * Applies {@link com.bumptech.glide.load.resource.bitmap.CenterCrop} to all default types, and
 * ignores unknown types.
 *
 * <p>This will override previous calls to {@link #dontTransform()}.
 *
 * @see #optionalTransform(Class, Transformation)
 * @see #centerCrop()
 */
public RequestOptions optionalCenterCrop() {
  return optionalTransform(DownsampleStrategy.CENTER_OUTSIDE, new CenterCrop());
}
项目:GitHub    文件:RequestOptions.java   
/**
 * Applies {@link CenterCrop} 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 #optionalCenterCrop()
 */
public RequestOptions centerCrop() {
  return transform(DownsampleStrategy.CENTER_OUTSIDE, new CenterCrop());
}
项目:GitHub    文件:RequestOptions.java   
/**
 * Applies {@link com.bumptech.glide.load.resource.bitmap.CenterCrop} to all default types, and
 * ignores unknown types.
 *
 * <p>This will override previous calls to {@link #dontTransform()}.
 *
 * @see #optionalTransform(Class, Transformation)
 * @see #centerCrop()
 */
@CheckResult
public RequestOptions optionalCenterCrop() {
  return optionalTransform(DownsampleStrategy.CENTER_OUTSIDE, new CenterCrop());
}
项目:GitHub    文件:RequestOptions.java   
/**
 * Applies {@link CenterCrop} 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 #optionalCenterCrop()
 */
@CheckResult
public RequestOptions centerCrop() {
  return transform(DownsampleStrategy.CENTER_OUTSIDE, new CenterCrop());
}
项目:saarang-iosched    文件:BitmapRequestBuilder.java   
/**
 * Transform images using {@link CenterCrop}.
 *
 * @return This RequestBuilder
 */
public BitmapRequestBuilder<ModelType, TranscodeType> centerCrop() {
    return transform(new CenterCrop(bitmapPool));
}