从Winforms Form/Button/Image属性中提取本地资源图像

发布于 2024-10-15 02:10:40 字数 253 浏览 7 评论 0原文

我有一个现有的 Winforms 应用程序,其中有多个表单,每个表单的两个主按钮(“确定”和“取消”)上具有相同的按钮图像。通过将 Button 的 Image 属性设置为“本地资源”并导入所需的图像,在 VS 设计器中设置图像。

我无权访问原始图像文件。如何从以这种方式设置 Image 属性的 Button 控件的 Image 属性中提取图像?

屏幕截图

I have an existing Winforms app that has several forms with the same button images on the two primary buttons for each form (OK and Cancel). The images are set in the VS Designer by setting Image property of Button to "Local resource" and importing the desired image.

I do not have access to the original image files. How do I extract an image from the Image property of a Button control whose Image property has been set this way?

Screenshot

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

猫瑾少女 2024-10-22 02:10:40

我发现了一个比手动解码 Base64 更简单的方法。

假设您的表单名为 Form1:

  1. 在解决方案资源管理器中展开 Form1.cs。
  2. 双击 Form1.resx 打开资源设计器。
  3. 右键单击您要提取的图像。
  4. 选择“导出到文件...”。

这适用于持久性设置为“嵌入在 .resx 中”的资源。如果持久性是“在编译时链接”,则图像已作为文件存在于项目的资源目录中。

屏幕截图

I found a much easier method than manually decoding the Base64.

Assuming your form is called Form1:

  1. Expand Form1.cs in Solution Explorer.
  2. Double click Form1.resx to open the Resource designer.
  3. Right click on the image you'd like to extract.
  4. Choose "Export To File...".

This applies to resources with Persistence set to "Embedded in .resx". If Persistence is "Linked at compile time" the image already exists as a file in your project's Resources directory.

Screenshot

清君侧 2024-10-22 02:10:40

实际上,图像并不存储在文件系统中,而是作为 Base64 编码的序列化表示添加到表单的 resx 文件(例如 MainForm.resx)中。如果您知道如何操作,则可以对该字符串进行 Base64 解码,将结果保存在平面文件中并正确命名(您必须知道其图像类型)。

Actually the images are not stored in the filesystem, but rather added to the resx file of your Form (e.g. MainForm.resx) as a base64-encoded serialized representation. If you know how to, you could base64-decode that string, save the result in a flatfile and name it correctly (you must know the image type for that).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文