public static Bitmap GetBitmap(Texture texture, int ArrayLevel = 0, int MipLevel = 0, int DepthLevel = 0)
        {
            int width  = (int)Math.Max(1, texture.Width >> MipLevel);
            int height = (int)Math.Max(1, texture.Height >> MipLevel);
            TextureFormatInfo formatInfo = TextureFormatInfo.FormatTable[texture.Format];
            Memory <byte>     data       = GetImageData(texture, ArrayLevel, MipLevel, DepthLevel);

            if (AstcDecoder.CanHandle(texture))
            {
                if (AstcDecoder.TryDecodeToRgba8(data, (int)formatInfo.BlockWidth, (int)formatInfo.BlockHeight, width, height, 1, 1, out var decoded))
                {
                    return(GetBitmapFromBytes(ConvertBgraToRgba(decoded), width, height, PixelFormat.Format32bppArgb));
                }
            }
            else if (DDSDecoder.CanHandle(texture))
            {
                return(DDSDecoder.Decompress(data.Span, width, height, texture.Format));
            }
            else if (RgbaDecoder.CanHandle(texture))
            {
                return(RgbaDecoder.Decode(data.Span, width, height, texture.Format));
            }

            return(null);
        }
Exemplo n.º 2
0
        private static bool IsTextureDecodable(Texture texture)
        {
            if (AstcDecoder.CanHandle(texture))
            {
                return(true);
            }
            if (DDSDecoder.CanHandle(texture))
            {
                return(true);
            }
            if (RgbaDecoder.CanHandle(texture))
            {
                return(true);
            }

            return(false);
        }