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

Add circle crop transformation #57

Closed
wants to merge 1 commit into from

Conversation

jschweitzer
Copy link

No description provided.

* @param height The height of the final Bitmap
* @return The resized Bitmap (will be recycled if recycled is not null)
*/
public static Bitmap circleCrop(Bitmap recycled, Bitmap toCrop, int width, int height) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like most of this comes from http://stackoverflow.com/questions/18229358/bitmap-in-imageview-with-rounded-corners. If I'm right it would be great to include a link so we can look back at the original source. It also looks like it's possible to do this a bit more efficiently using a BitmapShader. Check out Romain guy's blog post on how to do this: http://www.curious-creature.org/2012/12/11/android-recipe-1-image-with-rounded-corners/

@sjudd
Copy link
Collaborator

sjudd commented Jan 29, 2014

Sorry for the delay in reviewing this and thanks for putting up the code, I really appreciate the contribution. One general comment: It looks like this doesn't make any attempt to scale the image down to near the target width and height before performing the crop?

If so thats a break with the centerCrop method (https://github.com/bumptech/glide/blob/master/library/src/com/bumptech/glide/resize/load/ImageResizer.java#L199). It may imply that we should have a separate transformation that does the scaling, but for now it would probably be best to add that same scaling functionality here or at least document that this method doesn't scale first.

Without the scale you could end up cropping a large portion of your image out, which probably isn't quite what you want.

@lalith-b
Copy link

I have a sample class which does this without actually changing code from Glide and simply use a custom ImageView class find my gist here. https://gist.github.com/deathlord87/9778209

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

Successfully merging this pull request may close these issues.

4 participants