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

项目:GitHub    文件:RoundedCornersRegressionTest.java   
@Test
public void testRoundedCorners_usePool() throws ExecutionException, InterruptedException {
  canonicalBitmap = canonicalBitmap.scale(0.1f);

  Bitmap redRect =
      createRect(
          Color.RED,
          canonicalBitmap.getWidth(),
          canonicalBitmap.getHeight(),
          Bitmap.Config.ARGB_8888);

  Glide.get(context).getBitmapPool().put(redRect);

  Bitmap roundedRect = bitmapRegressionTester.test(
      GlideApp.with(context)
          .asBitmap()
          .load(canonicalBitmap.getBitmap())
          .override(canonicalBitmap.getWidth(), canonicalBitmap.getHeight())
          .transform(new RoundedCorners(5)));

  assertThat(roundedRect).isEqualTo(redRect);
}
项目: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);
   }
项目:GitHub    文件:NonBitmapDrawableResourcesTest.java   
@Test
public void load_withShapeDrawableResourceId_asDrawable_withTransformation_validSize_succeeds()
    throws ExecutionException, InterruptedException {
  Drawable drawable = Glide.with(context)
      .load(ResourceIds.drawable.shape_drawable)
      .apply(bitmapTransform(new RoundedCorners(10)))
      .submit(100, 200)
      .get();
  assertThat(drawable).isNotNull();
  assertThat(drawable.getIntrinsicWidth()).isEqualTo(100);
  assertThat(drawable.getIntrinsicHeight()).isEqualTo(200);
}
项目:GitHub    文件:RoundedCornersRegressionTest.java   
@Test
public void testRoundedCorners() throws ExecutionException, InterruptedException {
  bitmapRegressionTester.test(
      GlideApp.with(context)
          .asBitmap()
          .load(canonicalBitmap.getBitmap())
          .transform(new RoundedCorners(5)));
}
项目:GitHub    文件:RoundedCornersRegressionTest.java   
@Test
public void testRoundedCorners_overRounded() throws ExecutionException, InterruptedException {
  bitmapRegressionTester.test(
      GlideApp.with(context)
          .asBitmap()
          .load(canonicalBitmap.getBitmap())
          .transform(new RoundedCorners(20)));
}
项目:ViewPagerHelper    文件:GlideManager.java   
public GlideManager(Builder builder){
    RequestOptions options = new RequestOptions()
            .placeholder(builder.placeresid);

    if (builder.eroorresid != 0){
        options.error(builder.eroorresid);
    }


    switch (builder.type){
        case BITMAP_SCAN_CENTERN:
            options.centerCrop();
            break;
        case BITMAP_SCAN_FIT:
            options.fitCenter();
            break;
        default:
            break;
    }
    if (builder.setCircleCrop){
        options.circleCrop();
    }
    if (builder.radius != 0){
        options.transform(new RoundedCorners(builder.radius));
    }

    RequestBuilder requestBuilder = null;

    requestBuilder = Glide.with(builder.context).load(builder.source);

    if (builder.animtime > 0){
        requestBuilder.transition(new DrawableTransitionOptions().crossFade(builder.animtime));
    }

    requestBuilder.apply(options)
            .listener(new LoadListener())
            .into(builder.imageView);


}
项目:TitleBarView    文件:GlideManager.java   
/**
 * 加载圆角图片
 *
 * @param obj                 加载的图片资源
 * @param iv
 * @param dp                  圆角尺寸-dp
 * @param placeholderResource -占位图
 * @param isOfficial-是否官方模式圆角
 */
public static void loadRoundImg(Object obj, ImageView iv, float dp, int placeholderResource, boolean isOfficial) {
    Glide.with(iv.getContext()).load(obj).apply(getRequestOptions()
            .error(placeholderResource)
            .placeholder(placeholderResource)
            .fallback(placeholderResource)
            .dontAnimate()
            .transform(isOfficial ? new RoundedCorners(dp2px(dp)) : new GlideRoundTransform(iv.getContext(), dp2px(dp)))).into(iv);
}
项目:UIWidget    文件:GlideManager.java   
/**
 * 加载圆角图片
 *
 * @param obj                 加载的图片资源
 * @param iv
 * @param dp                  圆角尺寸-dp
 * @param placeholderResource -占位图
 * @param isOfficial-是否官方模式圆角
 */
public static void loadRoundImg(Object obj, ImageView iv, float dp, int placeholderResource, boolean isOfficial) {
    Glide.with(iv.getContext()).load(obj).apply(getRequestOptions()
            .error(placeholderResource)
            .placeholder(placeholderResource)
            .fallback(placeholderResource)
            .dontAnimate()
            .transform(isOfficial ? new RoundedCorners(dp2px(dp)) : new GlideRoundTransform(iv.getContext(), dp2px(dp)))).into(iv);
}
项目:FastLib    文件:GlideManager.java   
/**
 * 加载圆角图片
 *
 * @param obj                 加载的图片资源
 * @param iv
 * @param dp                  圆角尺寸-dp
 * @param placeholder         -占位图
 * @param isOfficial-是否官方模式圆角
 */
public static void loadRoundImg(Object obj, ImageView iv, float dp, Drawable placeholder, boolean isOfficial) {
    Glide.with(iv.getContext()).load(obj).apply(getRequestOptions()
            .error(placeholder)
            .placeholder(placeholder)
            .fallback(placeholder)
            .dontAnimate()
            .transform(isOfficial ? new RoundedCorners(dp2px(dp)) : new GlideRoundTransform(iv.getContext(), dp2px(dp)))).into(iv);
}