c# - 从 .NET 中的 native Win32 资源获取 PNG 图像

标签 c# .net vb.net image resources

DLL 文件包含 PNG 资源类型中的一些图像。

我可以在 Resource Hacker、Anolis Resourcer 和 Resource Tuner 等软件中查看 PNG 图片。查看 Anolis Resourcer 的屏幕截图以了解更多详细信息:

谁能告诉我如何获取 PNG 图像 no. 5220 从 DLL 文件并将其放入 PictureBox 中?我不认为像 LoadImage 或 LoadBitmap 这样的 API 会起作用。

最佳答案

// get the assembly containing the image
var assembly = Assembly.GetExecutingAssembly();

// set the picturebox image to read the embedded resource
pictureBox1.Image = Image.FromStream(
    assembly.GetManifestResourceStream("AssemblyName.test.png")
);

其中 AssemblyName.test.png 是程序集中嵌入资源的完全限定名称。


更新:

您似乎正试图从 native 程序集中提取资源。你可以看看 following article它说明了如何使用 P/Invoke 完成此操作。

关于c# - 从 .NET 中的 native Win32 资源获取 PNG 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7448097/

相关文章:

vb.net - 如何通过 Nlog 通过电子邮件发送整个日志文件

c# - 使用 EF Core 将 SQL 转换为 Linq

c# - 如何确保只有一个任务实例在运行?

c# - 为什么 C# 不允许将泛型类型用作泛型类中的属性?

c# - CLI C++ 派生自 C# 一次性类

.net - VB.NET中带有动态第二个参数(类型)的CType

c# - 是否可以将 .NET Core 与 .NET Framework 一起使用

.net - 哪里可以下载 'MySql.Data, Version=6.2.2.0'?

javascript - 在 Javascript/HTML 中使用 Web.config 应用程序数据

javascript - VB.NET 中的转义引号 (aspx.vb)