-
-
Notifications
You must be signed in to change notification settings - Fork 314
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
Canvas: trying to draw too large(143769912bytes) #329
Comments
Hello @stefan-niedermann , that is a pretty big image and |
We don't use the Glide integration yet (plan to do it in the future, have some trouble with our custom glide modules). Nevertheless: is it possible to catch the error and just display the alt text in this case? |
I think you should be able to use own instance of |
I've added in the latest snapshot version the |
The source code looks good 👍 🙂 Looking forward to test it with the next version. |
Why wait 😄 ? You can already test the snapshot and it is what snapshots really are - to gather data before releasing |
Well, you're right 😆 I will test if and report here as soon as i have time 🙂 |
@noties sorry for the question (i know it well and i hate it too 😆 ) but do you have any estimated date when |
Hello @stefan-niedermann , my estimate would be right about now 😄 I've released the |
@noties Sorry for reanimating this solved issue - but i tried to switch to |
Hello @stefan-niedermann , I think Glide should have a similar functionality. And DownsampleStrategy seems to be suitable for this kind of a feature |
True, though it seems not to be possible to do it with the |
@NonNull
@Override
public RequestBuilder<Drawable> load(@NonNull AsyncDrawable drawable) {
final String destination = drawable.getDestination();
return requestManager
.load(destination)
// the downsampling
.downsample(/**/)
// transform can also be used (according to the docs)
.transform(/**/);
} |
Ah, i see. I didn't know that one can pass an own However i am still facing the same exception when trying to render a huge image. I have tried each of the commented lines to apply the downsampling, all of them with the very same result. @NonNull
@Override
public RequestBuilder<Drawable> load(@NonNull AsyncDrawable drawable) {
return requestManager
.load(drawable.getDestination())
.downsample(DownsampleStrategy.AT_LEAST)
// .downsample(DownsampleStrategy.AT_MOST)
// .downsample(DownsampleStrategy.CENTER_OUTSIDE)
// .downsample(DownsampleStrategy.CENTER_INSIDE)
// .downsample(DownsampleStrategy.FIT_CENTER)
// .centerInside()
// .fitCenter()
// .transform(new CenterCrop())
// .apply(RequestOptions.downsampleOf(DownsampleStrategy.AT_LEAST))
.placeholder(R.drawable.ic_baseline_image_24)
.error(R.drawable.ic_baseline_broken_image_24);
} I also added an |
Hello @stefan-niedermann , this is one of the reasons I do no use Glide, it is very confusing and has a lot of moving parts. In your code snippet you do not limit the maximum size of loaded image. All the But you can create a custom class DownsampleWithMaxWidth extends DownsampleStrategy {
private final int maxWidth;
DownsampleWithMaxWidth(int maxWidth) {
this.maxWidth = maxWidth;
}
@Override
public float getScaleFactor(int sourceWidth, int sourceHeight, int requestedWidth, int requestedHeight) {
// do not scale down if fits requested dimension
if (sourceWidth < maxWidth) {
return 1F;
}
return (float) maxWidth / sourceWidth;
}
@Override
public SampleSizeRounding getSampleSizeRounding(int sourceWidth, int sourceHeight, int requestedWidth, int requestedHeight) {
// go figure
return SampleSizeRounding.MEMORY;
}
} Naturally, it is advisable to take into account maximum height also. And then use it in your return requestManager
.load(destination)
// value is for demonstration only, use a proper one
.downsample(new DownsampleWithMaxWidth(1024)); |
Awesome, i will try that! Thank you very much for your efforts. ❤️ While Glide has some drawbacks, it is still a good choice for my use case (for example we have to authenticate some requests with the Nextcloud Single-Sign-On API which work out of the box). |
Confirmed to work - thanks again! |
You are welcome 🙌 |
4.6.1
A user reported in my downstream app Nextcloud Notes an issue when rendering an image.
The following markdown leads reproducible to the below stacktrace:
I have the following information additionally from the users device:
Expected behavior is that the app does not crash but render the
alt
text instead if it ain't possible to render an image.The text was updated successfully, but these errors were encountered: