i run a simple sample using SkiaSharp (by NuGet) on UWP project.
I'm trying to load a png image using SKBitmap.Decode(filename)
but this error is thrown:
0x747219F2 (ucrtbase.dll)
An invalid parameter was passed to a function that considers invalid parameters fatal.
Same sample in Windows Forms runs without problems.
Because UWP runs in a sandbox, you can only access a limited number of locations in the file system without additional permissions. In this case, you the code cannot access an arbitrary bitmap by absolute file path.
You can access files in your application's install folder and in its ApplicationData
.
The easiest solution would be to add the bitmap to your UWP project as a Content
file, for example to the Assets
folder and then access it like this:
var packagePath = Package.Current.InstalledLocation;
var filename = Path.Combine( packagePath, "Assets/YourImage.png" );
SKBitmap.Decode(filename);
This should work as expected.