[英]Xamarin Failed loading bitmap in skiasharp
I have a problem.我有个问题。 I am trying to load an image, so I use this code:我正在尝试加载图像,因此我使用以下代码:
string resourceID = "MyApp.Templates.Good_Question.png";
Assembly assembly = GetType().GetTypeInfo().Assembly;
using (Stream stream = assembly.GetManifestResourceStream(resourceID))
{
bitmap = SKBitmap.Decode(stream);
}
But it gives an error on stream, because stream is null.但它在流上出错,因为流为空。 Now I created a folder in the root of the app called Templates and placed an image called Good_Question.png in the folder.现在我在应用程序的根目录中创建了一个名为 Templates 的文件夹,并在该文件夹中放置了一个名为 Good_Question.png 的图像。
Why is my stream null?为什么我的流为空?
我找到了,我必须将 Build Action 设置为 Embedded Resource,而不是 Resource
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.