0

I wanted to test my application on the computer of a friend to check, if my work on runs on other peoples' machine. (Do I have included all libraries? Etc.)

However, my application crashes when I load *.dds textures. I use them in the 2D background of my scene. Here is the code I am using to load a DDS texture and convert them to Bitmaps:

using (SharpDX.WIC.BitmapDecoder bitmapDecoder = new SharpDX.WIC.BitmapDecoder(ImagingFactory, new MemoryStream(iconInfo.Data, false), SharpDX.WIC.DecodeOptions.CacheOnDemand))
{
    using (SharpDX.WIC.FormatConverter formatConverter = new SharpDX.WIC.FormatConverter(ImagingFactory))
    {
        formatConverter.Initialize(bitmapDecoder.GetFrame(0), SharpDX.WIC.PixelFormat.Format32bppPRGBA, SharpDX.WIC.BitmapDitherType.None, null, 0.0, SharpDX.WIC.BitmapPaletteType.Custom);

        SharpDX.DataStream dataStream = new SharpDX.DataStream(formatConverter.Size.Height * formatConverter.Size.Width * 4, true, true);
        formatConverter.CopyPixels(formatConverter.Size.Width * 4, dataStream);

        _icons.Add(iconInfo.Name, new SharpDX.Direct2D1.Bitmap(renderTarget, new SharpDX.Size2(formatConverter.Size.Width, formatConverter.Size.Height), dataStream,
            formatConverter.Size.Width * 4, bitmapProperties));
    }
}

"iconInfo.Data" are the data bytes of a DDS texture.

The thrown exception is

SharpDX.SharpDXException: HRESULT: [0x88982F50], Module: [SharpDX.WIC], ApiCode: [WINCODEC_ERR_COMPONENTNOTFOUND/Componentnotfound], Message: Unknown
   at SharpDX.Result.CheckError()
   at SharpDX.WIC.ImagingFactory.CreateDecoderFromStream_(IntPtr streamRef, Nullable`1 guidVendorRef, DecodeOptions metadataOptions, BitmapDecoder decoderOut)
   at SharpDX.WIC.BitmapDecoder..ctor(ImagingFactory factory, Stream streamRef, DecodeOptions metadataOptions)

Do you have any idea what's causing the problems?

GameDevAlien
  • 195
  • 1
  • 17
  • No ideas? No one? :'-( – GameDevAlien May 12 '17 at 14:10
  • WINCODEC_ERR_COMPONENTNOTFOUND means you've tried to decode an image and there is no suitable codec installed. Which version of Windows are you testing on? And can you open the DDS files in the Windows Photo Viewer? – saucecontrol May 16 '17 at 03:16
  • On my machine (Win10 incl. all updates) everything's fine. My friend tested my game on his computer using "Microsoft Windows 7 Home Premium , 64-Bit, Version 6.1.7601". – GameDevAlien May 16 '17 at 22:03

1 Answers1

0

The WIC-codec for DDS files has a number of important limitations. First, it's only included with Windows 8.1 or later. Second, it only supports BC1/BC2/BC3 (a.k.a. DXT1-DXT5) formats. See MSDN

Generally speaking, you are better off using a specialized DDS texture loader.

Chuck Walbourn
  • 38,259
  • 2
  • 58
  • 81
  • I converted all my textures with a tool called Compressonator from *.png into *.dds BC3. I got a speed-up of 95% when loading textures after this change. I wrote a DDS-Importer for model textures, but I used this approach for UI textures. Can you recommend a loader? – GameDevAlien May 16 '17 at 22:05