-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
Relax SizeDeterminer to handle only one dimension being WRAP_CONTENT #135
Comments
1 - I totally agree, should use the view class rather than ImageView. 2 - I agree in principle, my main objection is that passing along wrap_content as a width or height would require not just the decoder, but also every transformation and transcoder to add a special case (or cases) for wrap content. For fit center and similar transformations that don't change the aspect ratio of the image, wrap_content can make sense, but for others that don't maintain the aspect ratio, like most kinds of crops, it makes less sense. What happens if you try to center crop the image in the example you gave? One option I suppose would be allowing transformations to simply throw if they can't handle wrap_content, but since users of the library can define their own transformations, it might be hard to make that consistent. I'm not at all against what you propose, I just struggle to come up with a neat way to handle these cases that would actually produce a result a user would expect. 3 - Padding is an interesting point, we probably should take that into account when determining the size of the image to load. |
It looks like this works as I tried in #835. However the handling of |
I think we've addressed this to the best of my ability in #2431. |
This has been bugging me since I first tried Glide:
First:
"Trying to load image into ImageView using..."
should be"Trying to load image into " + view.getClass() + " using..."
since this is theViewTarget
classSecond:
I'm really against hard-coding any numbers in the UI code, or if I have to I'm trying to do it really flexibly.
Would it be possible to relax
ViewTarget.isUsingWrapContent
by replacing thator
with anand
? I give the point to you when both areWRAP_CONTENT
there's nothing you can do to downsample. But if only one of them isWRAP_CONTENT
the other one can still be fixed orMATCH_PARENT
in which case one dimension is known and the aspect ratio is clear from the loaded Bitmap.Say I want to load a
100x96
image into (list_item.xml
):in this case it's clear that you can downsample to:
50x48
regardlesswrap_content
being there andSizeDeterminer
could still read one dimension when rendered, the other one could be -1 or 0?This should be a biggie If it's well documented in
com.bumptech.glide.load.ResourceDecoder#decode
that the sizes are not necessarily always valid numbers and try to load with keeping aspect ratio anyway.Also it may worth to take
padding
into account whenisViewSizeValid
.The text was updated successfully, but these errors were encountered: