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

时间:2022-08-27 20:26:49

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

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

How to do it?

怎么做?

Additional information:

附加信息:

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

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

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

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

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

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

Except I want to add a PNG.

除了我想添加一个PNG。

Otherwise my 1MB application becomes 8MB:

否则我的1MB应用程序变为8MB:

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

2 个解决方案

#1


22  

  1. Go to the project menu -> properties.
  2. 转到项目菜单 - >属性。
  3. Select the resources tab
  4. 选择资源选项卡
  5. Make sure Images is selected first.
  6. 确保首先选择图像。
  7. Click the arrow beside 'add resource'
  8. 点击“添加资源”旁边的箭头
  9. Select add existing file
  10. 选择添加现有文件
  11. Find the PNG
  12. 找到PNG

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

#2


1  

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.

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

#1


22  

  1. Go to the project menu -> properties.
  2. 转到项目菜单 - >属性。
  3. Select the resources tab
  4. 选择资源选项卡
  5. Make sure Images is selected first.
  6. 确保首先选择图像。
  7. Click the arrow beside 'add resource'
  8. 点击“添加资源”旁边的箭头
  9. Select add existing file
  10. 选择添加现有文件
  11. Find the PNG
  12. 找到PNG

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

#2


1  

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.

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