Exemplo n.º 1
0
        //Gets the decompressed byte[]
        public static Bitmap DecodeBlock(byte[] data, uint Width, uint Height, SurfaceFormat Format)
        {
            Bitmap decomp;

            if (Format == SurfaceFormat.BC1_UNORM)
            {
                decomp = DDS_Decompress.DecompressBC1(data, (int)Width, (int)Height, false);
            }
            else if (Format == SurfaceFormat.BC1_SRGB)
            {
                decomp = DDS_Decompress.DecompressBC1(data, (int)Width, (int)Height, true);
            }
            else if (Format == SurfaceFormat.BC3_UNORM)
            {
                decomp = DDS_Decompress.DecompressBC3(data, (int)Width, (int)Height, false);
            }
            else if (Format == SurfaceFormat.BC3_SRGB)
            {
                decomp = DDS_Decompress.DecompressBC3(data, (int)Width, (int)Height, true);
            }
            else if (Format == SurfaceFormat.BC4_UNORM)
            {
                decomp = DDS_Decompress.DecompressBC4(data, (int)Width, (int)Height, false);
            }
            else if (Format == SurfaceFormat.BC4_SNORM)
            {
                decomp = DDS_Decompress.DecompressBC4(data, (int)Width, (int)Height, true);
            }
            else if (Format == SurfaceFormat.BC5_UNORM)
            {
                decomp = DDS_Decompress.DecompressBC5(data, (int)Width, (int)Height, false);
            }
            else if (Format == SurfaceFormat.BC5_SNORM)
            {
                decomp = DDS_Decompress.DecompressBC5(data, (int)Width, (int)Height, true);
            }
            else if (Format == SurfaceFormat.R8_UNORM)
            {
                decomp = DDS_PixelDecode.DecodeR8G8(data, (int)Width, (int)Height);
            }
            else if (Format == SurfaceFormat.R8_G8_B8_A8_SRGB)
            {
                decomp = DDS_PixelDecode.DecodeR8G8B8A8(data, (int)Width, (int)Height);
            }
            else if (Format == SurfaceFormat.R8_G8_B8_A8_UNORM)
            {
                decomp = DDS_PixelDecode.DecodeR8G8B8A8(data, (int)Width, (int)Height);
            }
            else
            {
                decomp = Properties.Resources.TextureError;
                Console.WriteLine($"Format {Format} not supported!");

                //     throw new Exception($"Format {Format} not supported!");
            }

            return(decomp);
        }
Exemplo n.º 2
0
        public static Bitmap DecodeBlock(byte[] data, uint Width, uint Height, int Format)
        {
            Bitmap decomp;

            switch (Format)
            {
            case ((int)GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC1_UNORM):
                decomp = DDS_Decompress.DecompressBC1(data, (int)Width, (int)Height, false); break;

            case ((int)GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC1_SRGB):
                decomp = DDS_Decompress.DecompressBC1(data, (int)Width, (int)Height, true); break;

            case ((int)GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC3_UNORM):
                decomp = DDS_Decompress.DecompressBC3(data, (int)Width, (int)Height, false); break;

            case ((int)GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC3_SRGB):
                decomp = DDS_Decompress.DecompressBC3(data, (int)Width, (int)Height, true); break;

            case ((int)GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC4_UNORM):
                decomp = DDS_Decompress.DecompressBC4(data, (int)Width, (int)Height, false); break;

            case ((int)GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC4_SNORM):
                decomp = DDS_Decompress.DecompressBC4(data, (int)Width, (int)Height, true); break;

            case ((int)GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC5_UNORM):
                decomp = DDS_Decompress.DecompressBC5(data, (int)Width, (int)Height, false); break;

            case ((int)GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_T_BC5_SNORM):
                decomp = DDS_Decompress.DecompressBC5(data, (int)Width, (int)Height, true); break;

            case ((int)GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_TC_R8_G8_B8_A8_SNORM):
                decomp = DDS_PixelDecode.DecodeR8G8B8A8(data, (int)Width, (int)Height); break;

            case ((int)GTX.GX2SurfaceFormat.GX2_SURFACE_FORMAT_TC_R8_G8_B8_A8_UINT):
                decomp = DDS_PixelDecode.DecodeR8G8B8A8(data, (int)Width, (int)Height); break;

            default:
                decomp = Properties.Resources.TextureError;
                Console.WriteLine($"Format {Format} not supported!");
                break;
            }
            return(decomp);
        }