如何在Visual Studio 2010中添加PNG资源?

时间:2012-02-16 18:02:52

标签: .net visual-studio visual-studio-2010 resources .net-assembly

我有一个PNG(即压缩图像),我想将其包含在我的程序集中(即应用程序)。

怎么做?

其他信息:

我尝试在Visual Studio 2010中向我的程序集添加PNG资源:

enter image description here

但是这不起作用,因为Visual Studio将其转换为未压缩的位图:

enter image description here

除了我想添加PNG。

否则my 1MB application becomes 8MB

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

2 个答案:

答案 0 :(得分:28)

  1. 转到项目菜单 - >属性。
  2. 选择资源标签
  3. 确保首先选择图像。
  4. 点击“添加资源”旁边的箭头
  5. 新图像(从图像文件类型中选择)
  6. 查找PNG
  7. enter image description here

答案 1 :(得分:1)

我能做到这一点的唯一方法是从PNG中删除文件扩展名。这样,Visual Studio就无法将文件识别为图像,并且不会使它们保持原状。