Converting .dds to .png: is XNA really this convoluted?

前端 未结 2 767
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-20 06:35

I have a .dds file and I want a .png file. Although I already found out about the DevIL.NET library, the API design there of one static class does not parallelize, so I am h

2条回答
  •  感动是毒
    2020-12-20 07:18

    If you have a command line app that needs to create an XNA graphics device, the code in this answer should be of some assistance.

    In a nutshell, you need some of the classes from the WinForms sample to avoid having to mess around creating a graphics device services and so on (specifically the classes ServiceContainer and GraphicsDeviceService).

    Then you can do this:

    Form form = new Form(); // Dummy form for creating a graphics device
    GraphicsDeviceService gds = GraphicsDeviceService.AddRef(form.Handle,
            form.ClientSize.Width, form.ClientSize.Height);
    
    ServiceContainer services = new ServiceContainer();
    services.AddService(gds);
    content = new ContentManager(services, "Content");
    

    Tada - now you have a working ContentManager that you can use to load stuff. I believe you should be able to get the actual GraphicsDevice from the GraphicsDeviceService, too.

    The form you create is never displayed. Remember to reference System.Windows.Forms.dll in your project.

    Disclaimer: This was written for XNA 3.1. I haven't tested it in 4.0, but I suspect it will work with little or no modification.

提交回复
热议问题