How to add PNG resource in Visual Studio 2010?

半城伤御伤魂 提交于 2019-12-17 18:48:25

问题


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:

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

Except I want to add a PNG.

Otherwise my 1MB application becomes 8MB:

]=== 1MB file size ==>
]=== 8MB file size ==============================================================================================================================================>

回答1:


  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




回答2:


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.



来源:https://stackoverflow.com/questions/9316549/how-to-add-png-resource-in-visual-studio-2010

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!