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

Deferred custom Transformation #2067

Open
VictorAlbertos opened this issue Feb 18, 2019 · 3 comments
Open

Deferred custom Transformation #2067

VictorAlbertos opened this issue Feb 18, 2019 · 3 comments

Comments

@VictorAlbertos
Copy link

I need to know view's dimensions in order to apply a custom Transformation (cropping based on a machine learning model). But I'm not able to find a way of delaying the computation until view has been measured using Picasso's api. Is there a way to delay the Transformation.transform call until the target view has been measured?

As this transformation plans to be part of a library I want to ship this feature as a custom Transformation to play nicely with any other potential transformations.

Thanks.

@JakeWharton
Copy link
Member

The .fit() call will do this automatically for you.

@JakeWharton
Copy link
Member

It waits for view measure and adds the size as if you called resize with them.

@VictorAlbertos
Copy link
Author

The problem with using fit() is that if I don't add any built-in Picasso transformation the bitmap is stretched when it reaches Transformation.transform of my custom Transformation. If I apply centerCrop() it defeats the purpose of my custom transformation for making its own cropping, and if I use centerInside() the bitmap is rescaled in a way that is not optimal for the incoming crop -min(width, height). But if I don't use fit then I get the original bitmap with its entire size loaded into memory being that way exposed to potential OMM.

Glide offers BitmapTransformation which supplies to its clients a bitmap optimized for to the target view, downscaling the original bitmap but taking the greater dimension of the target view - max(width, height). Is there something similar in Picasso?

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

2 participants