/// <summary>
        /// Gets a <see cref="Bitmap"/> given an array and mip index.
        /// </summary>
        /// <param name="ArrayIndex">The index of the surface/array. Cubemaps will have 6</param>
        /// <param name="MipLevel">The index of the mip level.</param>
        /// <returns></returns>
        public Bitmap GetBitmap(int ArrayLevel = 0, int MipLevel = 0, int DepthLevel = 0)
        {
            uint width  = Math.Max(1, Width >> MipLevel);
            uint height = Math.Max(1, Height >> MipLevel);

            byte[] data = GetImageData(ArrayLevel, MipLevel, DepthLevel);

            data = Platform.DecodeImage(this, data, width, height, ArrayLevel, MipLevel);

            if (Platform.OutputFormat != TexFormat.RGBA8_UNORM)
            {
                data = DecodeBlock(data, width, height, Platform.OutputFormat);
            }
            else if (Platform is DefaultSwizzle || Platform is SwitchSwizzle || Platform is WiiUSwizzle)
            {
                data = ImageUtility.ConvertBgraToRgba(data);
            }

            if (data.Length == 0)
            {
                LoadOpenGLTexture();
                return(RenderableTex.ToBitmap());
            }

            if (IsBCNCompressed())
            {
                width  = ((width + 3) / 4) * 4;
                height = ((height + 3) / 4) * 4;
            }

            return(BitmapExtension.CreateBitmap(data, (int)width, (int)height));
        }
예제 #2
0
        /// <summary>
        /// Gets a <see cref="Bitmap"/> given an array and mip index.
        /// </summary>
        /// <param name="ArrayIndex">The index of the surface/array. Cubemaps will have 6</param>
        /// <param name="MipLevel">The index of the mip level.</param>
        /// <returns></returns>
        public Bitmap GetBitmap(int ArrayLevel = 0, int MipLevel = 0, int DepthLevel = 0)
        {
            uint width  = Math.Max(1, Width >> MipLevel);
            uint height = Math.Max(1, Height >> MipLevel);

            byte[] data = GetImageData(ArrayLevel, MipLevel, DepthLevel);

            Console.WriteLine($"data {data.Length}");
            data = Platform.DecodeImage(this, data, width, height, ArrayLevel, MipLevel);
            Console.WriteLine($"data2 {data.Length}");

            Console.WriteLine($"OutputFormat {Platform.OutputFormat}");

            if (Platform.OutputFormat != TexFormat.RGBA8_UNORM)
            {
                data = DecodeBlock(data, width, height, Platform.OutputFormat);
            }
            else if (Platform is DefaultSwizzle || Platform is TegraX1Swizzle || Platform is WiiUSwizzle)
            {
                data = ImageUtility.ConvertBgraToRgba(data);
            }

            return(BitmapExtension.CreateBitmap(data, (int)width, (int)height));
        }