Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RoundedCornersTransformation not working #16

Closed
leixinstar opened this issue Aug 13, 2015 · 15 comments
Closed

RoundedCornersTransformation not working #16

leixinstar opened this issue Aug 13, 2015 · 15 comments

Comments

@leixinstar
Copy link

when CenterCrop ,RoundedCornersTransformation not working

@wasabeef
Copy link
Owner

@leixinstar

Please tell me your source code.
the following code is sample.

Glide.with(mContext)
  .load(R.drawable.demo)
  .bitmapTransform(new CenterCrop(mContext), new RoundedCornersTransformation(mContext, 100, 0))
  .into(holder.image);

@leixinstar
Copy link
Author

your code can work ok。
my code is:
Glide.with(context)
.load(realUrl)
.centerCrop()
.placeholder(R.drawable.default_avatar)
.error(R.drawable.default_avatar)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.bitmapTransform(new RoundedCornersTransformation(context,8,0))
.into(imageView);

@squeeish
Copy link
Contributor

@wasabeef from what I understand, we cannot use Glide's centerCrop() if we use bitmapTransform?

@wasabeef
Copy link
Owner

@leixinstar
@squeeish

Yeah..

It can't be used centerCrop if you use the bitmapTransform

@leixinstar
Copy link
Author

RoundedCornersTransformation and CropTransformation(mContext, 300, 100, CropTransformation.CropType.TOP),how can this two work together?

@balavishnu
Copy link

Removing centerCrop fixed the issue for me. Thanks

@TWiStErRob
Copy link

TWiStErRob commented Mar 8, 2016

Check the code of centerCrop/fitCenter/dontTransfrom/bitmapTransform they all call transform. To combine two transformations you need to use the varargs version and forget about the convenience methods:

.transform(new CenterCrop(context), new RoundedTransformation(...))

@wasabeef I think you should update https://github.com/wasabeef/glide-transformations#advanced-step-3 with the information that .centerCrop() in a combined usage becomes new CenterCrop(context) (similar for fitCenter.

@felipecsl
Copy link

@TWiStErRob that doesn't work either, same results

@felipecsl
Copy link

OK I was able to make it work by tweaking RoundedCornersTransformation. In the transform() method, you should use outWidth and outHeight instead of the source bitmap width/height

felipecsl added a commit to felipecsl/glide-transformations that referenced this issue May 10, 2016
It should be using the output width/height, not the source Bitmap
dimensions. This allows this transformation to play nicely with others.
Fixes wasabeef#16
@TWiStErRob
Copy link

Sorry, I was wrong about .transform(...) I always forget that @wasabeef's transformations are Transformation<Bitmap> and not BitmapTransformation, using .bitmapTransform(...) works as expected, see #40 (comment).

@qibin0506
Copy link

In Adapter, sometime it is ok, but sometime, not, my code :

 if(opts.getRadius() != 0) {
            builder.bitmapTransform(new FitCenter(imageView.getContext()),
                    new RoundedCornersTransformation(imageView.getContext(),
                            opts.getRadius(), 0));
        }else {
            builder.bitmapTransform(new FitCenter(imageView.getContext()));
        }

@myrao
Copy link

myrao commented Oct 25, 2017

I missed the scaleType of ImageVIew was set centerCrop in xml, and when I used Glide.load.transformation not working... It's take too much time... OMG

@MichaelJokAr
Copy link

how to slove this in V4 generate code?

@arayaryoma
Copy link

arayaryoma commented Jan 28, 2018

It works probably... (I'm writing in Kotlin)

class Utils {
    companion object {
        fun dip2px(context: Context, dp: Float): Int {
            val scale = context.resources.displayMetrics.density
            return (dp * scale + 0.5f).toInt()
        }
    }
}
val width = Utils.dip2px(ctx, 200.0f)
val height = Utils.dip2px(ctx, 200.0f)
Glide.with(ctx).load(imageUrl)
                .apply(overrideOf(width, height))
                .apply(bitmapTransform(MultiTransformation(CenterCrop(),
                        RoundedCornersTransformation(45, 0,
                                RoundedCornersTransformation.CornerType.ALL))))
                .into(imageView)

@KrackensCorp
Copy link

            .apply(bitmapTransform(MultiTransformation(CenterCrop(), RoundedCorners(16,))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests