Skip to main content
 首页 » 编程设计

c#之在 Windows 运行时从位图创建流

2024年02月13日13thcjp

我想从位图创建一个流。首先我用 :

Stream imgStream = typeof(Main).GetTypeInfo().Assembly.GetManifestResourceStream("ApplicationBlockBase.Assets.testimage.jpg"); 

但现在我需要从本地镜像创建流。你有什么想法吗?

谢谢你的时间,问候。

请您参考如下方法:

让我知道这是否有效。

StorageFile imageFile = await (await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Assets")).GetFileAsync("testimage.jpg"); 
Stream imgStream = await imageFile.OpenStreamForReadAsync();