Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add PNG resource in Visual Studio 2010?

I have a PNG (i.e. a compressed image) that I'd like to include in my assembly (i.e. application).

How to do it?

Additional information:

I tried adding a PNG resource to my assembly in Visual Studio 2010:

enter image description here

But that didn't work, as Visual Studio converts it to an uncompressed bitmap:

enter image description here

Except I want to add a PNG.

Otherwise my 1MB application becomes 8MB:

]=== 1MB file size ==>
]=== 8MB file size ==============================================================================================================================================>
like image 803
Ian Boyd Avatar asked Feb 16 '12 18:02

Ian Boyd


People also ask

How do I add a resource to Visual Studio?

In Visual Studio, open a SharePoint solution. In Solution Explorer, choose a SharePoint project node, and then, on the menu bar, choose Project > Add New Item. In the Add New Item dialog box, choose the Global Resources File template, and then choose the Add button.

How do I import an image into Visual Studio?

Click on the Project in Visual Studio and then click on the button titled "Show all files" on the Solution Explorer toolbar. That will show files that aren't in the project. Now you'll see that image, right click in it, and select "Include in project" and that will add the image to the project!

How do I add resources to winform?

On the Tools menu, click Resource Files. In the Resource Files dialog box, click Add. In the Add File dialog box, select the file that you updated, and then click OK.


2 Answers

  1. Go to the project menu -> properties.
  2. Select the resources tab
  3. Make sure Images is selected first.
  4. Click the arrow beside 'add resource'
  5. New Image (Select from Image File Types)
  6. Find the PNG

enter image description here

like image 55
Jeff Avatar answered Oct 17 '22 03:10

Jeff


The only way I could make this work, is by removing the file extension from the PNGs. That way Visual Studio doesn't recognize the files as images, and leaves them untouched.

like image 1
Daniel Avatar answered Oct 17 '22 02:10

Daniel