Example #1
0
        public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
        {
            if (image.Is3DS)
            {
                PlatformSwizzle = PlatformSwizzle.Platform_3DS;
                return(ImageData);
            }
            else
            {
                uint bpp = GetBytesPerPixel(Format);

                GX2.GX2Surface surf = new GX2.GX2Surface();
                surf.bpp       = bpp;
                surf.height    = image.Height;
                surf.width     = image.Width;
                surf.aa        = (uint)GX2.GX2AAMode.GX2_AA_MODE_1X;
                surf.alignment = image.Alignment;
                surf.depth     = 1;
                surf.dim       = (uint)GX2.GX2SurfaceDimension.DIM_2D;
                surf.format    = (uint)FTEX.ConvertToGx2Format(Format);
                surf.use       = (uint)GX2.GX2SurfaceUse.USE_COLOR_BUFFER;
                surf.pitch     = 0;
                surf.data      = ImageData;
                surf.numMips   = 1;
                surf.mipOffset = new uint[0];
                surf.mipData   = ImageData;
                surf.tileMode  = (uint)GX2.GX2TileMode.MODE_2D_TILED_THIN1;
                surf.swizzle   = image.Swizzle;
                surf.numArray  = 1;

                return(GX2.Decode(surf, ArrayLevel, MipLevel));
            }
        }
Example #2
0
            public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0, int DepthLevel = 0)
            {
                RedChannel   = SetChannel(surface.compSel[0]);
                GreenChannel = SetChannel(surface.compSel[1]);
                BlueChannel  = SetChannel(surface.compSel[2]);
                AlphaChannel = SetChannel(surface.compSel[3]);


                Console.WriteLine("");
                Console.WriteLine("// ----- GX2Surface Info ----- ");
                Console.WriteLine("  dim             = " + surface.dim);
                Console.WriteLine("  width           = " + surface.width);
                Console.WriteLine("  height          = " + surface.height);
                Console.WriteLine("  depth           = " + surface.depth);
                Console.WriteLine("  numMips         = " + surface.numMips);
                Console.WriteLine("  format          = " + surface.format);
                Console.WriteLine("  aa              = " + surface.aa);
                Console.WriteLine("  use             = " + surface.use);
                Console.WriteLine("  imageSize       = " + surface.imageSize);
                Console.WriteLine("  mipSize         = " + surface.mipSize);
                Console.WriteLine("  tileMode        = " + surface.tileMode);
                Console.WriteLine("  swizzle         = " + surface.swizzle);
                Console.WriteLine("  alignment       = " + surface.alignment);
                Console.WriteLine("  pitch           = " + surface.pitch);
                Console.WriteLine("  bits per pixel  = " + (surface.bpp << 3));
                Console.WriteLine("  bytes per pixel = " + surface.bpp);
                Console.WriteLine("  data size       = " + surface.data.Length);
                Console.WriteLine("  mip size        = " + surface.mipData.Length);
                Console.WriteLine("  realSize        = " + surface.imageSize);

                return(GX2.Decode(surface, ArrayLevel, MipLevel));
            }
Example #3
0
        public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
        {
            uint bpp = GetBytesPerPixel(Format);

            GX2.GX2Surface surf = new GX2.GX2Surface();
            surf.bpp       = bpp;
            surf.height    = Height;
            surf.width     = Width;
            surf.aa        = (uint)GX2.GX2AAMode.GX2_AA_MODE_1X;
            surf.alignment = 0;
            surf.depth     = 1;
            surf.dim       = (uint)GX2.GX2SurfaceDimension.DIM_2D;
            surf.format    = (uint)Bfres.Structs.FTEX.ConvertToGx2Format(Format);
            surf.use       = (uint)GX2.GX2SurfaceUse.USE_COLOR_BUFFER;
            surf.pitch     = 0;
            surf.data      = TextureTGLP.SheetDataList[SheetIndex];
            surf.numMips   = 1;
            surf.mipOffset = new uint[0];
            surf.mipData   = null;
            surf.tileMode  = (uint)GX2.GX2TileMode.MODE_2D_TILED_THIN1;
            surf.swizzle   = Swizzle;
            surf.numArray  = 1;

            var surfaces = GX2.Decode(surf);

            return(surfaces[ArrayLevel][MipLevel]);
        }
Example #4
0
            public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0, int DepthLevel = 0)
            {
                if (ContainerParent.Platform == GT1Platform.WiiU)
                {
                    uint bpp = GetBytesPerPixel(Format);

                    GX2.GX2Surface surf = new GX2.GX2Surface();
                    surf.bpp       = bpp;
                    surf.height    = Height;
                    surf.width     = Width;
                    surf.aa        = (uint)GX2.GX2AAMode.GX2_AA_MODE_1X;
                    surf.alignment = 0;
                    surf.depth     = 1;
                    surf.dim       = (uint)GX2.GX2SurfaceDimension.DIM_2D;
                    surf.format    = (uint)Bfres.Structs.FTEX.ConvertToGx2Format(Format);
                    surf.use       = (uint)GX2.GX2SurfaceUse.USE_COLOR_BUFFER;
                    surf.pitch     = 0;
                    surf.data      = ImageData;
                    surf.numMips   = MipCount;
                    surf.mipOffset = new uint[0];
                    surf.mipData   = ImageData;
                    surf.tileMode  = (uint)GX2.GX2TileMode.MODE_2D_TILED_THIN1;

                    //  surf.tileMode = (uint)GX2.GX2TileMode.MODE_2D_TILED_THIN1;
                    surf.swizzle  = 0;
                    surf.numArray = 1;

                    return(GX2.Decode(surf, ArrayLevel, MipLevel));
                }
                else
                {
                    return(ImageData);
                }
            }
Example #5
0
            public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
            {
                if (Gx2HeaderData != null)
                {
                    var surfaces = GX2.Decode(Gx2HeaderData);
                    return(surfaces[ArrayLevel][MipLevel]);
                }
                else
                {
                    uint DataOffset = 0;
                    for (byte arrayLevel = 0; arrayLevel < ArrayCount; ++arrayLevel)
                    {
                        for (byte mipLevel = 0; mipLevel < MipCount; ++mipLevel)
                        {
                            if (ArrayLevel == arrayLevel && MipLevel == mipLevel)
                            {
                                return(Utils.SubArray(Data, DataOffset, ImageSizes[mipLevel]));
                            }
                            else
                            {
                                DataOffset += ImageSizes[mipLevel];
                            }
                        }
                    }

                    return(null);
                }
            }
Example #6
0
            public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
            {
                int  swizzle = (int)Swizzle;
                int  pitch   = (int)0;
                uint bpp     = GX2.surfaceGetBitsPerPixel(GX2Format) >> 3;

                GX2.GX2Surface surf = new GX2.GX2Surface();
                surf.bpp       = bpp;
                surf.height    = Height;
                surf.width     = Width;
                surf.aa        = (uint)0;
                surf.alignment = Alignment;
                surf.depth     = Depth;
                surf.dim       = 0x1;
                surf.format    = GX2Format;
                surf.use       = 0x1;
                surf.pitch     = 0;
                surf.data      = data;
                surf.mipData   = data;
                surf.numMips   = MipCount;
                surf.tileMode  = TileMode;
                surf.swizzle   = Swizzle;
                surf.imageSize = ImageSize;

                // GX2.GenerateMipSurfaceData(surf);

                return(GX2.Decode(surf, ArrayLevel, MipLevel));
            }
Example #7
0
        public byte[] DecodeImage(STGenericTexture texture, byte[] data, uint width, uint height, int array, int mip)
        {
            uint bpp = TextureFormatHelper.GetBytesPerPixel(OutputFormat);

            GX2.GX2Surface surf = new GX2.GX2Surface();
            surf.bpp       = bpp;
            surf.height    = texture.Height;
            surf.width     = texture.Width;
            surf.depth     = texture.ArrayCount;
            surf.alignment = Alignment;
            surf.aa        = (uint)AAMode;
            surf.dim       = (uint)SurfaceDimension;
            surf.format    = (uint)Format;
            surf.use       = (uint)SurfaceUse;
            surf.pitch     = Pitch;
            surf.data      = data;
            surf.mipData   = MipData != null ? MipData : data;
            surf.mipOffset = MipOffsets != null ? MipOffsets : new uint[0];
            surf.numMips   = texture.MipCount;
            surf.numArray  = texture.ArrayCount;
            surf.tileMode  = (uint)TileMode;
            surf.swizzle   = Swizzle;

            Console.WriteLine("WII U DECODE");

            return(GX2.Decode(surf, array, mip));
        }
        public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
        {
            format = (int)texture.Format;
            int  swizzle = (int)texture.Swizzle;
            int  pitch   = (int)texture.Pitch;
            uint bpp     = GX2.surfaceGetBitsPerPixel((uint)format) >> 3;

            RedChannel   = GX2ChanneToGeneric(texture.CompSelR);
            GreenChannel = GX2ChanneToGeneric(texture.CompSelG);
            BlueChannel  = GX2ChanneToGeneric(texture.CompSelB);
            AlphaChannel = GX2ChanneToGeneric(texture.CompSelA);

            UpdateMipMaps();

            GX2.GX2Surface surf = new GX2.GX2Surface();
            surf.bpp       = bpp;
            surf.height    = texture.Height;
            surf.width     = texture.Width;
            surf.aa        = (uint)texture.AAMode;
            surf.alignment = texture.Alignment;
            surf.depth     = texture.Depth;
            surf.dim       = (uint)texture.Dim;
            surf.format    = (uint)texture.Format;
            surf.use       = (uint)texture.Use;
            surf.pitch     = texture.Pitch;
            surf.data      = texture.Data;
            surf.numMips   = MipCount;
            surf.mipOffset = texture.MipOffsets;
            surf.mipData   = texture.MipData;
            surf.tileMode  = (uint)texture.TileMode;
            surf.swizzle   = texture.Swizzle;
            surf.numArray  = texture.ArrayLength;



            if (Tex2Swizzle != 0)
            {
                surf.mip_swizzle = Tex2Swizzle;
            }

            if (surf.mipData == null)
            {
                surf.numMips = 1;
            }

            var surfaces = GX2.Decode(surf);

            if (ArrayLevel >= surfaces.Count)
            {
                throw new Exception("Invalid amount of surfaces decoded!");
            }
            if (surfaces.Count == 0)
            {
                throw new Exception("Surfaces came out empty!");
            }

            return(surfaces[ArrayLevel][MipLevel]);
        }
Example #9
0
            public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0, int DepthLevel = 0)
            {
                if (GX2Surface != null)
                {
                    GX2Surface.data    = ImageData;
                    GX2Surface.mipData = ImageData;

                    return(GX2.Decode(GX2Surface, ArrayLevel, MipLevel));
                }
                else
                {
                    return(ImageData);
                }
            }
Example #10
0
        public byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0, int DepthLevel = 0)
        {
            format = (int)texture.Format;
            int  swizzle = (int)texture.Swizzle;
            int  pitch   = (int)texture.Pitch;
            uint bpp     = GX2.surfaceGetBitsPerPixel((uint)format) >> 3;

            RedChannel   = GX2ChanneToGeneric(texture.CompSelR);
            GreenChannel = GX2ChanneToGeneric(texture.CompSelG);
            BlueChannel  = GX2ChanneToGeneric(texture.CompSelB);
            AlphaChannel = GX2ChanneToGeneric(texture.CompSelA);

            UpdateMipMaps();

            GX2.GX2Surface surf = new GX2.GX2Surface();
            surf.bpp       = bpp;
            surf.height    = texture.Height;
            surf.width     = texture.Width;
            surf.aa        = (uint)texture.AAMode;
            surf.alignment = texture.Alignment;
            surf.depth     = texture.Depth;
            surf.dim       = (uint)texture.Dim;
            surf.format    = (uint)texture.Format;
            surf.use       = (uint)texture.Use;
            surf.pitch     = texture.Pitch;
            surf.data      = texture.Data;
            surf.numMips   = MipCount;
            surf.mipOffset = texture.MipOffsets;
            surf.mipData   = texture.MipData;
            surf.tileMode  = (uint)texture.TileMode;
            surf.swizzle   = texture.Swizzle;
            surf.numArray  = texture.ArrayLength;

            if (Tex2Swizzle != 0)
            {
                surf.mip_swizzle = Tex2Swizzle;
            }

            if (surf.mipData == null)
            {
                surf.numMips = 1;
            }


            return(GX2.Decode(surf, ArrayLevel, MipLevel));
        }
            public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
            {
                int  swizzle = (int)Swizzle;
                int  pitch   = (int)0;
                uint bpp     = GX2.surfaceGetBitsPerPixel(GX2Format) >> 3;

                GX2.GX2Surface surf = new GX2.GX2Surface();
                surf.bpp       = bpp;
                surf.height    = Height;
                surf.width     = Width;
                surf.aa        = (uint)0;
                surf.alignment = Alignment;
                surf.depth     = Depth;
                surf.dim       = 0x1;
                surf.format    = GX2Format;
                surf.use       = 0x1;
                surf.pitch     = 0;
                surf.data      = data;
                surf.numMips   = MipCount;
                surf.mipOffset = new uint[MipCount];
                surf.mipData   = null;
                surf.tileMode  = TileMode;
                surf.swizzle   = Swizzle;
                surf.imageSize = ImageSize;

                // GX2.GenerateMipSurfaceData(surf);

                foreach (var mipoffset in surf.mipOffset)
                {
                    Console.WriteLine($"mipoffset {mipoffset}");
                }

                var surfaces = GX2.Decode(surf);

                return(surfaces[ArrayLevel][MipLevel]);
            }
Example #12
0
            public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
            {
                uint GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC5_UNORM;

                switch (SurfFormat)
                {
                case SurfaceFormat.T_BC1_UNORM:
                    GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC1_UNORM;
                    Format    = TEX_FORMAT.BC1_UNORM;
                    break;

                case SurfaceFormat.T_BC1_SRGB:
                    GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC1_SRGB;
                    Format    = TEX_FORMAT.BC1_UNORM_SRGB;
                    break;

                case SurfaceFormat.T_BC2_UNORM:
                    GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC2_UNORM;
                    Format    = TEX_FORMAT.BC2_UNORM;
                    break;

                case SurfaceFormat.T_BC2_SRGB:
                    GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC2_SRGB;
                    Format    = TEX_FORMAT.BC2_UNORM_SRGB;
                    break;

                case SurfaceFormat.T_BC3_UNORM:
                    GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC3_UNORM;
                    Format    = TEX_FORMAT.BC3_UNORM;
                    break;

                case SurfaceFormat.T_BC3_SRGB:
                    GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC3_SRGB;
                    Format    = TEX_FORMAT.BC3_UNORM_SRGB;
                    break;

                case SurfaceFormat.T_BC4_UNORM:
                    GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC4_UNORM;
                    Format    = TEX_FORMAT.BC4_UNORM;
                    break;

                case SurfaceFormat.T_BC4_SNORM:
                    GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC4_SNORM;
                    Format    = TEX_FORMAT.BC4_SNORM;
                    break;

                case SurfaceFormat.T_BC5_UNORM:
                    GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC5_UNORM;
                    Format    = TEX_FORMAT.BC5_UNORM;
                    break;

                case SurfaceFormat.T_BC5_SNORM:
                    GX2Format = (uint)GX2.GX2SurfaceFormat.T_BC5_SNORM;
                    Format    = TEX_FORMAT.BC5_SNORM;
                    break;

                case SurfaceFormat.TC_R8_G8_UNORM:
                    GX2Format = (uint)GX2.GX2SurfaceFormat.TC_R8_G8_UNORM;
                    Format    = TEX_FORMAT.R8G8_UNORM;
                    break;

                case SurfaceFormat.TCS_R8_G8_B8_A8_UNORM:
                    GX2Format = (uint)GX2.GX2SurfaceFormat.TCS_R8_G8_B8_A8_UNORM;
                    Format    = TEX_FORMAT.R8G8B8A8_UNORM;
                    break;

                case SurfaceFormat.TCS_R8_G8_B8_A8:
                    GX2Format = (uint)GX2.GX2SurfaceFormat.TCS_R8_G8_B8_A8_UNORM;
                    Format    = TEX_FORMAT.R8G8B8A8_UNORM;
                    break;

                case SurfaceFormat.TC_R8_UNORM:
                    GX2Format = (uint)GX2.GX2SurfaceFormat.TC_R8_UNORM;
                    Format    = TEX_FORMAT.R8_UNORM;
                    break;

                case SurfaceFormat.TCS_R5_G6_B5_UNORM:
                    GX2Format = (uint)GX2.GX2SurfaceFormat.TCS_R5_G6_B5_UNORM;
                    Format    = TEX_FORMAT.B5G6R5_UNORM;
                    break;

                default:
                    throw new Exception("Format unsupported! " + SurfFormat);
                }


                int  swizzle = (int)Swizzle;
                int  pitch   = (int)0;
                uint bpp     = GX2.surfaceGetBitsPerPixel(GX2Format) >> 3;

                GX2.GX2Surface surf = new GX2.GX2Surface();
                surf.bpp       = bpp;
                surf.height    = Height;
                surf.width     = Width;
                surf.aa        = (uint)0;
                surf.alignment = 0;
                surf.depth     = Depth;
                surf.dim       = 0x1;
                surf.format    = GX2Format;
                surf.use       = 0x1;
                surf.pitch     = 0;
                surf.data      = data;
                surf.numMips   = 1;
                surf.mipOffset = new uint[0];
                surf.mipData   = null;
                surf.tileMode  = TileMode;
                surf.swizzle   = Swizzle;
                surf.imageSize = ImageSize;

                var surfaces = GX2.Decode(surf);

                return(surfaces[ArrayLevel][MipLevel]);
            }