microsoft / DirectXTex

DirectXTex texture processing library
https://walbourn.github.io/directxtex/
MIT License
1.79k stars 438 forks source link

Are there any pre-compiled versions of this library? #17

Closed MattFiler closed 8 years ago

MattFiler commented 8 years ago

Are there any pre-compiled versions of DirectXTex online that I can use? I'm desperately trying to find a way to convert an image to the DX10 DDS format but I'm struggling to get DirectXTex to work in its GitHub form. Being able to drag and drop my file onto a .exe file to convert it, or use a .bat file to convert it would be very appreciated! Thanks.

walbourn commented 8 years ago

Just download texconv.exe and use the command-line instructions.

If you want to convert TO the "DX10" FourCC, use the command-line switch -dx10.

MattFiler commented 8 years ago

That's awesome, thanks!

MattFiler commented 8 years ago

Just a quick follow-up question, I'm trying to call the exe in C# but I'm having real issues, could you take a look at this code to see what's wrong? Thanks! Process.Start("texconv.exe", @"-dx10 -ft jpg -f BC7_UNORM -o \" + Path.GetDirectoryName(outFilePath) + @"\ " + outFilePath + ".dds"); Where "outFilePath" is a file name and folder location from the current directory.

walbourn commented 8 years ago

First, you are assuming that texconv.exe is in the 'current working directory'. You might want to use System.Diagnostics.ProcessStartInfo.

Second, you are telling the tool to write the result as a JPEG but are using BC7_UNORM which is not a form that JPEG can store. You should remove -ft jpg.

MattFiler commented 8 years ago

Ah, I should have explained the context a bit better...

I've got my application and texconv.exe in a folder together, in my application I am exporting DDS files from a game with varying formats (including DXGI_FORMAT_BC7_UNORM and others). I want texconv.exe to convert the textures to .JPG as soon as they are exported so that I can allow the user to view them within my app, and the way I'm doing this is to export the DDS to the working directory, call the Process.Start command above, delete the DDS and then continue with the other files. I don't want the new JPG files to also be in the working directory though, they've got their own file structure which is why I'm trying to use -o to set the output directory.

The issue I'm having is that by pausing my loop after just one texture export and running a .bat file manually in the working directory I can export the textures fine, but running the same code through Process.Start (with my full loop and by pausing my loop) it just won't work and I've tried so many combinations I really can't figure out why. I can sometimes manage to get them to convert to JPG into the working directory, but using -o just seems to mess it all up (but only via the Process.Start). The .bat file I tested and the application that is running Process.Start are both in the same folder so I don't know why it would be a location-based issue.

To also explain my parameters, I'm inputting a DX10 BC7_UNORM texture in that example and trying to output it to JPG in its correct folder. I presumed you'd need the -f parameter for converting from DDS as well as to it?

Thanks!

walbourn commented 8 years ago

You don't control the input format with the command-line. It's whatever the source file contains. The switch controls the desired output format. Since you are trying to write a JPEG, you should use -ft jpg -f R8G8B8A8_UNORM.

Another option would be to use interop and write a little C++ wrapper that uses the DirectXTex library to do the conversion.