Esempio n. 1
0
        private byte[] DecodeWithoutOpenGLDecoder(byte[] ImageData, uint width, uint height, STGenericTexture GenericTexture)
        {
            if (!UseOpenGLDecoder)
            {
                return(STGenericTexture.ConvertBgraToRgba(
                           STGenericTexture.DecodeBlock(ImageData,
                                                        width,
                                                        height,
                                                        GenericTexture.Format,
                                                        GenericTexture.GetPaletteData(),
                                                        GenericTexture.Parameters,
                                                        GenericTexture.PaletteFormat,
                                                        GenericTexture.PlatformSwizzle)));
            }

            switch (GenericTexture.Format)
            {
            case TEX_FORMAT.BC1_UNORM:
            case TEX_FORMAT.BC1_UNORM_SRGB:
            case TEX_FORMAT.BC2_UNORM:
            case TEX_FORMAT.BC2_UNORM_SRGB:
            case TEX_FORMAT.BC3_UNORM:
            case TEX_FORMAT.BC3_UNORM_SRGB:
            case TEX_FORMAT.BC5_UNORM:
            case TEX_FORMAT.BC6H_SF16:
            case TEX_FORMAT.BC6H_UF16:
            case TEX_FORMAT.BC7_UNORM:
            case TEX_FORMAT.BC7_UNORM_SRGB:
            case TEX_FORMAT.R8G8B8A8_UNORM:
            case TEX_FORMAT.R8G8B8A8_UNORM_SRGB:
                return(ImageData);

            case TEX_FORMAT.BC5_SNORM:
                return(DDSCompressor.DecompressBC5(ImageData,
                                                   (int)width, (int)height, true, true));

            default:
                if (Runtime.UseDirectXTexDecoder)
                {
                    return(STGenericTexture.ConvertBgraToRgba(
                               STGenericTexture.DecodeBlock(ImageData,
                                                            width,
                                                            height,
                                                            GenericTexture.Format,
                                                            GenericTexture.GetPaletteData(),
                                                            GenericTexture.Parameters,
                                                            GenericTexture.PaletteFormat,
                                                            GenericTexture.PlatformSwizzle)));
                }
                else
                {
                    return(ImageData);
                }
            }
        }