-
Notifications
You must be signed in to change notification settings - Fork 62
IImageLoadingService cannot load image on Windows #422
Comments
Verified repro on VS 17.3.0 Preview 1.0 [32427.505.main]. Repro project: |
Are there any workarounds possible for this? Perhaps an alternative implementation of |
@limefrogyank tag some MAUI people to receive any info on this |
I found a workaround. Put a dummy GraphicsView on the page somewhere where it loads first and handle the Loaded event with this:
I actually get a COM error the first time I try to load an image, but after the first one (handled via try...catch) it works fine. All of the images load. Maybe there's a timing issue still, but it works for me... at least to get to the next stage of working on my app. |
Is that a workaround only to display the image in UI or to allow loading it as |
This is just to load an stream into an My dummy GraphicsView is 1 pixel by 1 pixel and it's covered by other controls. The windows version of GraphicsView uses a CanvasControl internally. Somewhere later in my code, I'm doing this to load an image into an
Again, I do get an initial COM error when trying the above code, but it works eventually. (My app is loading several pages from a pdf file as images and displaying them. If it can't get the image, it tries again at the next draw call when the GraphicsView is Invalidated. So this works for me...) |
Building on previous suggestions, and after looking at the source for W2DGraphicsService, this is what I came up with, and it's working for me. You'd think that the getter on line 13 of
|
Duplicate of dotnet/maui#12370 |
Backported to net7 dotnet/maui#12690 |
This was backported to net7 7 months ago. What version are you on? |
Description
What I was trying to achieve:
Result:
IImage
Sample application:
MauiApp2 Android IImage resized image disposed exception.zip (yes, the same as for dotnet/maui#6909)
Description
Any attempt to load an image using
IImageLoadingService
on Windows results in this code being called:"No resource creator has been registered globally or for this thread."
How I am calling it:
imageLoadingService.FromStream
which isMicrosoft.Maui.Graphics.Win2D.SkiaImageLoadingService
which is the onlyIImageLoadingService
implementation which works for me for Windows (during compile-time).Win2DImage
cannot be called directly because it is an internal class.What I am doing in
MauiProgram.cs
:Steps to Reproduce
Inject
Microsoft.Maui.Graphics.Win2D.SkiaImageLoadingService
forIImageLoadingService
on Windows and try creating anIImage
from file/stream with it.Version with bug
Release Candidate 2 (current)
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
I don't know.
Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: