-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
CreateScaledBitmap fails on some android devices and emulators #17923
Comments
First of all if it only seem to happen for specific configuration. So we need to know which config exactly. Also would be good to see a minimum sample to see how you use it. However, community support in OSS is done when it's done. If you need priority support, we offer that as well but it's not free. |
Does this work? |
Yes, using SkiaBitmap.Resize instead of CreateScaledBitmap does the trick. It's odd that CreateScaledBitmap does not work correctly since as far as I know, it uses Skia under the hood? |
Avalonia does use Skia (although I am not sure about the specifics of that method). But there are sometimes weird SkiaSharp bugs that show up for no obvious reason. They can take awhile to fix. EG a few years ago scaling some PNG files was completely broken. Others worked fine. However older versions of SkiaSharp (and by extension Avalonia) worked fine. Anyway, that code I linked seems to work around 99% of all Skia related bitmap bugs in my experience. Probably because it does a proper resize and encode rather than trying to decode it as a specific size. If you want to make it slightly more efficient (which might be worthwhile depending on what you are doing), you can create your own custom bitmap type that is directly coupled to Skia. |
Describe the bug
When creating a bitmap using CreateScaledBitmap, the bitmap displays correctly on windows, but on some (not all) android devices and emulators it produces an empty bitmap that does not display. No exception is thrown either.
Upon inspecting the code, CreateScaledBitmap ends up calling methods that seem to be declared as obsolete, but CreateScaledBitmap itself has not been declared obsolete, which is somewhat misleading.
To Reproduce
load a bitmap, scale it with CreateScaledBitmap and set it as source of Image and run on Android device and emulator.... and it may happen.
Expected behavior
the bitmap should be displayed correctly.
Avalonia version
11.2.3
OS
Android
Additional context
If CreateScaledBitmap is not going to be supported anymore I would be tempted to suggest to mark it as obsolete too.
But the method is so critically important that not supporting some way of scaling bitmaps is unthinkable to me... so I would ask to provide a temporary solution, even if it involves a slow by-software scaling... at least until the backend APIs is stable again.
The text was updated successfully, but these errors were encountered: