コード例 #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);
                }
            }
        }
コード例 #2
0
        private void LoadImage(Bitmap Image)
        {
            Image = BitmapExtension.SwapBlueRedChannels(Image);

            TexWidth  = (uint)Image.Width;
            TexHeight = (uint)Image.Height;
            MipCount  = (uint)GetTotalMipCount();

            if (TexWidth != Image.Width || TexHeight != Image.Height)
            {
                Image = BitmapExtension.Resize(Image, TexWidth, TexHeight);
            }

            DecompressedData.Add(STGenericTexture.ConvertBgraToRgba(BitmapExtension.ImageToByte(Image)));

            Image.Dispose();
            if (DecompressedData.Count == 0)
            {
                throw new Exception("Failed to load " + Format);
            }
        }
コード例 #3
0
 public static System.Drawing.Bitmap DecodeBlockToBitmap(byte[] Input, int Width, int Height, PICASurfaceFormat picaFormat)
 {
     return(BitmapExtension.GetBitmap(STGenericTexture.ConvertBgraToRgba(DecodeBlock(Input, Width, Height, picaFormat)),
                                      Width, Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb));
 }