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

[resizetizer] non-vector images should not resize by default #6419

Merged
merged 1 commit into from
Apr 22, 2022

Conversation

jonathanpeppers
Copy link
Member

Description of Change

On Android, the linked sample crashes with:

Java.Lang.RuntimeException: 'Canvas: trying to draw too large(485897280bytes) bitmap.

It appears like this image is simply too big:

  1. The image starts at 3008x5340

  2. MAUI's build upscales this to 21360x12032, see
    obj\Debug\net6.0-android\resizetizer\r\drawable-xxxhdpi

A workaround is to do:

<MauiImage Update="Resources\Images\large.jpg" Resize="false" />

Let's make %(Resize) of false be the default for non-vector
images. If users specify %(BaseSize) or %(Resize) themselves, then
we'll continue to use those settings.

I updated some tests around this scenario.

This has both app size and performance implications for all platforms
-- as usage of .png or .jpg file will no longer get upscaled to
enormous dimensions. Yay!

Issues Fixed

Fixes Android side of: #5938

Windows side is a separate issue about image rotation.

Fixes the Android side of:

dotnet#5938

On Android, the linked sample crashes with:

    Java.Lang.RuntimeException: 'Canvas: trying to draw too large(485897280bytes) bitmap.

It appears like this image is simply too big:

1. The image starts at 3008x5340

2. MAUI's build upscales this to 21360x12032, see
   `obj\Debug\net6.0-android\resizetizer\r\drawable-xxxhdpi`

A workaround is to do:

    <MauiImage Update="Resources\Images\large.jpg" Resize="false" />

Let's make `%(Resize)` of `false` be the default for non-vector
images. If users specify `%(BaseSize)` or `%(Resize)` themselves, then
we'll continue to use those settings.

I updated some tests around this scenario.

This has both app size and performance implications for all platforms
-- as usage of `.png` or `.jpg` file will no longer get upscaled to
enormous dimensions. Yay!
@mattleibow mattleibow merged commit e3c8b45 into dotnet:main Apr 22, 2022
@jonathanpeppers jonathanpeppers deleted the ResizetizerBaseSize branch April 22, 2022 19:36
@samhouts samhouts added area-image Image loading, sources, caching area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer area-controls-image Image control labels Jul 10, 2023
@ghost ghost added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Jul 10, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 22, 2023
@Eilon Eilon removed legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor area-image Image loading, sources, caching labels May 10, 2024
@samhouts samhouts added the fixed-in-6.0.300-rc.3 Look for this fix in 6.0.300-rc.3! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-image Image control area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer fixed-in-6.0.300-rc.3 Look for this fix in 6.0.300-rc.3!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants