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

Comments

2 participants
@VictorAlbertos
Copy link

VictorAlbertos commented Feb 18, 2019

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

This comment has been minimized.

Copy link
Collaborator

JakeWharton commented Feb 18, 2019

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

@JakeWharton

This comment has been minimized.

Copy link
Collaborator

JakeWharton commented Feb 18, 2019

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

@VictorAlbertos

This comment has been minimized.

Copy link
Author

VictorAlbertos commented Feb 18, 2019

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
You can’t perform that action at this time.