Exemple #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));
            }
        }
Exemple #2
0
        public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
        {
            uint bpp = GetBytesPerPixel(Format);

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

            var surfaces = GTX.Decode(surf);

            return(surfaces[ArrayLevel][MipLevel]);
        }
        public void LoadDDS(string FileName, byte[] FileData = null)
        {
            TexName = STGenericTexture.SetNameFromPath(FileName);

            DDS dds = new DDS();

            if (FileData != null)
            {
                dds.Load(new FileReader(new MemoryStream(FileData)));
            }
            else
            {
                dds.Load(new FileReader(FileName));
            }
            MipCount    = dds.header.mipmapCount;
            TexWidth    = dds.header.width;
            TexHeight   = dds.header.height;
            arrayLength = 1;
            if (dds.header.caps2 == (uint)DDS.DDSCAPS2.CUBEMAP_ALLFACES)
            {
                arrayLength = 6;
            }
            DataBlockOutput.Add(dds.bdata);

            RedComp   = dds.RedChannel;
            GreenComp = dds.GreenChannel;
            BlueComp  = dds.BlueChannel;
            AlphaComp = dds.AlphaChannel;

            Format = (GX2.GX2SurfaceFormat)FTEX.ConvertToGx2Format(dds.Format);;
        }
        public void LoadBitMap(Image Image, string FileName)
        {
            DecompressedData.Clear();

            TexName = Path.GetFileNameWithoutExtension(FileName);
            Format  = (GTX.GX2SurfaceFormat)FTEX.ConvertToGx2Format(Runtime.PreferredTexFormat);

            GenerateMipmaps = true;
            LoadImage(new Bitmap(Image));
        }
Exemple #5
0
            public override void SetImageData(Bitmap bitmap, int ArrayLevel)
            {
                if (bitmap == null)
                {
                    return; //Image is likely disposed and not needed to be applied
                }
                RedChannel   = SetChannel(surface.compSel[0]);
                GreenChannel = SetChannel(surface.compSel[1]);
                BlueChannel  = SetChannel(surface.compSel[2]);
                AlphaChannel = SetChannel(surface.compSel[3]);

                surface.format = (uint)FTEX.ConvertToGx2Format(Format);
                surface.width  = (uint)bitmap.Width;
                surface.height = (uint)bitmap.Height;

                if (MipCount != 1)
                {
                    MipCount = GenerateMipCount(bitmap.Width, bitmap.Height);
                    if (MipCount == 0)
                    {
                        MipCount = 1;
                    }
                }

                surface.numMips   = MipCount;
                surface.mipOffset = new uint[MipCount];

                try
                {
                    //Create image block from bitmap first
                    var data = GenerateMipsAndCompress(bitmap, MipCount, Format);

                    //Swizzle and create surface
                    var NewSurface = GX2.CreateGx2Texture(data, Text,
                                                          (uint)surface.tileMode,
                                                          (uint)surface.aa,
                                                          (uint)surface.width,
                                                          (uint)surface.height,
                                                          (uint)surface.depth,
                                                          (uint)surface.format,
                                                          (uint)surface.swizzle,
                                                          (uint)surface.dim,
                                                          (uint)surface.numMips
                                                          );

                    ApplySurface(NewSurface);
                    IsEdited = true;
                    LoadOpenGLTexture();
                    LibraryGUI.Instance.UpdateViewport();
                }
                catch (Exception ex)
                {
                    STErrorDialog.Show("Failed to swizzle and compress image " + Text, "Error", ex.ToString());
                }
            }
Exemple #6
0
        public override void SetImageData(System.Drawing.Bitmap bitmap, int ArrayLevel)
        {
            if (bitmap == null || image == null)
            {
                return; //Image is likely disposed and not needed to be applied
            }
            MipCount = 1;
            var Gx2Format = FTEX.ConvertToGx2Format(Format);

            uint swizzle = (image.Swizzle >> 8) & 7;

            try
            {
                //Create image block from bitmap first
                var data = GenerateMipsAndCompress(bitmap, MipCount, Format);

                //Swizzle and create surface
                var surface = GX2.CreateGx2Texture(data, Text,
                                                   (uint)image.TileMode,
                                                   (uint)0,
                                                   (uint)image.Width,
                                                   (uint)image.Height,
                                                   (uint)1,
                                                   (uint)Gx2Format,
                                                   (uint)swizzle,
                                                   (uint)1,
                                                   (uint)MipCount
                                                   );

                image.Swizzle     = surface.swizzle;
                image.BflimFormat = FormatsWiiU.FirstOrDefault(x => x.Value == Format).Key;
                image.Height      = (ushort)surface.height;
                image.Width       = (ushort)surface.width;

                Width  = image.Width;
                Height = image.Height;

                ImageData = surface.data;

                IsEdited = true;
                LoadOpenGLTexture();
                LibraryGUI.UpdateViewport();
            }
            catch (Exception ex)
            {
                STErrorDialog.Show("Failed to swizzle and compress image " + Text, "Error", ex.ToString());
            }
        }
        public void LoadSupportedFormats(TEX_FORMAT[] Formats)
        {
            formatComboBox.Items.Clear();
            foreach (TEX_FORMAT format in Formats)
            {
                var Gx2Format = (GX2.GX2SurfaceFormat)FTEX.ConvertToGx2Format(format);
                formatComboBox.Items.Add(Gx2Format);
            }

            var Gx2DefaultFormat = (GX2.GX2SurfaceFormat)FTEX.ConvertToGx2Format(Runtime.PreferredTexFormat);

            if (formatComboBox.Items.Contains(Gx2DefaultFormat))
            {
                formatComboBox.SelectedItem = Gx2DefaultFormat;
            }
        }
        public void LoadBitMap(string FileName)
        {
            DecompressedData.Clear();

            TexName = Path.GetFileNameWithoutExtension(FileName);

            Format          = (GTX.GX2SurfaceFormat)FTEX.ConvertToGx2Format(Runtime.PreferredTexFormat);
            GenerateMipmaps = true;

            //If a texture is .tga, we need to convert it
            Bitmap Image = null;

            if (Utils.GetExtension(FileName) == ".tga")
            {
                Image = Paloma.TargaImage.LoadTargaImage(FileName);
            }
            else
            {
                Image = new Bitmap(FileName);
            }

            LoadImage(Image);
        }