4

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

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

Reinier Torenbeek
  • 16,669
  • 7
  • 46
  • 69
Ivan Prodanov
  • 34,634
  • 78
  • 176
  • 248

3 Answers3

7

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)

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

Brian Webster
  • 30,033
  • 48
  • 152
  • 225
  • It's worth noting that his library doesn't parallelize well; using `Parallel.ForEach` gives various memory access exceptions and `null` return values for the `LoadBitmap` call. Still, this saves a lot of work... – Domenic Oct 03 '10 at 08:04
4

I think the short answer is that you don't. The documentation says that the supported formats are BMP, GIF, EXIG, JPG, PNG and 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.FromFile method 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...

Fredrik Mörk
  • 155,851
  • 29
  • 291
  • 343
1

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

Wayne Hartman
  • 18,369
  • 7
  • 84
  • 116