Universal Windows Platform (UWP)
A Microsoft platform for building and publishing apps for Windows desktop devices.
3,004 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have the following code
cs
private static async Task<BitmapSource> LoadBitmapSourceUsingWIC(Folders folder, string path)
{
StorageFile file = await GetStorageFileAsync(folder, path);
BitmapSource bmSource;
unsafe
{
IWICImagingFactory* wicImagingFactory = CoreGraphics.WicImagingFactory.GetPtr();
IWICBitmapDecoder* bmDecoder;
IWICBitmapFrameDecode* bmFrame = null;
IntPtr fileNameIntPtr = Marshal.StringToHGlobalAnsi(file.Path);
HRESULT hr = wicImagingFactory->CreateDecoderFromFilename(
(ushort*)fileNameIntPtr,
null,
GENERIC_READ,
WICDecodeOptions.WICDecodeMetadataCacheOnDemand,
&bmDecoder);
But it's throwing a FileNotFoundException. The file (StorageFile) is valid.
I had to use this instead...
IntPtr fileNameIntPtr = Marshal.StringToHGlobalUni(file.Path);
There is so much inconsistency in Windows API's with strings. Why not just fix up the API's across Windows and between languages and make a collection of API's that are really easy to use together?