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/