C# 如何将 .dds 文件加载到图片框中?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/865413/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 04:45:30  来源:igfitidea点击:

How to load .dds files into a picturebox?

c#imagedirectdrawdds-format

提问by Ivan Prodanov

How do I load .dds texture files as an Image in C#? There's nothing useful on google that I could find.

如何在 C# 中将 .dds 纹理文件作为图像加载?我在谷歌上找不到任何有用的东西。

The more information with samples you give me,the better it will be for me to understand it.

你给我的样品信息越多,我就越容易理解。

采纳答案by Fredrik M?rk

I think the short answer is that you don't. The documentationsays that the supported formats are BMP, GIF, EXIG, JPG, PNG and TIFF.

我认为简短的回答是你没有。文档说支持的格式是 BMP、GIF、EXIG、JPG、PNG 和 TIFF。

Update: there seem to be a number of converters to be found through Google, that might help you out. Also, as Wayne suggests, look at XNA (if you didn't already). The Texture2D.FromFilemethod seems to handle the .dds files, but I never used it myself so I can't say if it is what you are looking for or not...

更新:似乎可以通过 Google 找到许多转换器,这可能会对您有所帮助。另外,正如韦恩所建议的,看看 XNA(如果你还没有的话)。该Texture2D.FromFile方法似乎处理的.dds文件,但我从来没有使用过自己,所以我不能说,如果它是你在找什么或不...

回答by Wayne Hartman

You might want to take a look at the Microsoft's XNA Game Studio SDKto load the textures in memory and possibly capture the images in a System.Drawing.Graphics usable way.

您可能想查看 Microsoft 的XNA Game Studio SDK以在内存中加载纹理,并可能以 System.Drawing.Graphics 可用方式捕获图像。

回答by Brian Webster

I had the same issue. Here is a good solution.

我遇到过同样的问题。这是一个很好的解决方案。

  1. Source: http://www.mastropaolo.com/devildotnet/
  2. Download Version 1.3 from that link (bottom of page)
  3. Add the Devil.NET.dll as a reference to your application
  4. Use the code that I have supplied below.

    PictureBox1.Image = DevIL.DevIL.LoadBitmap(DDS_File_Path)

  1. 来源:http: //www.mastropaolo.com/devildotnet/
  2. 从该链接下载 1.3 版(页面底部)
  3. 添加 Devil.NET.dll 作为对您的应用程序的引用
  4. 使用我在下面提供的代码。

    PictureBox1.Image = DevIL.DevIL.LoadBitmap(DDS_File_Path)

It's really that easy. We owe the DevIL .NET Wrapper creator a beer.

这真的很容易。我们欠 DevIL .NET Wrapper 创建者一杯啤酒。