Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extracting Local Resource Image from Winforms Form/Button/Image Property

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

like image 278
jenisysJohn Avatar asked Feb 01 '11 16:02

jenisysJohn


2 Answers

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

like image 138
Dan Bechard Avatar answered Sep 26 '22 02:09

Dan Bechard


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).

like image 24
Sebastian Edelmeier Avatar answered Sep 24 '22 02:09

Sebastian Edelmeier