예제 #1
0
            public override void Replace(string FileName)
            {
                int size = data.Length;

                FTEX ftex = new FTEX();

                ftex.ReplaceTexture(FileName, Format, MipCount, 0, SupportedFormats, true, true, true);
                if (ftex.texture != null)
                {
                    byte[] ImageData = ftex.texture.Data;


                    if (ftex.texture.MipData != null)
                    {
                        ImageData = Utils.CombineByteArray(ftex.texture.Data, ftex.texture.MipData);
                    }

                    //  if (ImageData.Length != size)
                    // MessageBox.Show($"Image size does not match! Make sure mip map count, format, height and width are all the same! Original Size {size} Import {ImageData.Length}", );

                    Swizzle = (byte)ftex.texture.Swizzle;

                    byte[] NewData = new byte[size];
                    Array.Copy(ImageData, 0, NewData, 0, size);

                    data = NewData;

                    UpdateEditor();
                }
            }
예제 #2
0
        private void Replace(object sender, EventArgs args)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Supported Formats|*.dds; *.png;*.tga;*.jpg;*.tiff|" +
                         "Microsoft DDS |*.dds|" +
                         "Portable Network Graphics |*.png|" +
                         "Joint Photographic Experts Group |*.jpg|" +
                         "Bitmap Image |*.bmp|" +
                         "Tagged Image File Format |*.tiff|" +
                         "All files(*.*)|*.*";

            ofd.Multiselect = false;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                FTEX ftex = new FTEX();
                ftex.ReplaceTexture(ofd.FileName, Format, 1, 0, SupportedFormats, true, true, false);
                if (ftex.texture != null)
                {
                    image.BCLIMFormat = ConvertFormatGenericToBflim(ftex.Format);
                    image.Height      = (ushort)ftex.texture.Height;
                    image.Width       = (ushort)ftex.texture.Width;

                    Format = GetFormat(image.BCLIMFormat);
                    Width  = image.Width;
                    Height = image.Height;

                    ImageData = ftex.texture.Data;

                    UpdateForm();
                }
            }
        }
예제 #3
0
        public override void Replace(string FileName)
        {
            uint swizzle = (image.Swizzle >> 8) & 7;

            FTEX ftex = new FTEX();

            ftex.ReplaceTexture(FileName, Format, 1, swizzle, SupportedFormats, true, true, true, false);
            if (ftex.texture != null)
            {
                image.Swizzle     = ftex.texture.Swizzle;
                image.BflimFormat = FormatsWiiU.FirstOrDefault(x => x.Value == ftex.Format).Key;
                image.Height      = (ushort)ftex.texture.Height;
                image.Width       = (ushort)ftex.texture.Width;

                if (ftex.UseBc4Alpha)
                {
                    image.BflimFormat = 16;
                }

                Format = FormatsWiiU[image.BflimFormat];
                Width  = image.Width;
                Height = image.Height;

                ImageData = ftex.texture.Data;

                LoadComponents(Format, ftex.UseBc4Alpha);

                UpdateForm();
            }
        }
예제 #4
0
            public override void Replace(string FileName)
            {
                FTEX ftex = new FTEX();

                ftex.ReplaceTexture(FileName, Format);
                if (ftex.texture != null)
                {
                    surface.swizzle    = ftex.texture.Swizzle;
                    surface.tileMode   = (uint)ftex.texture.TileMode;
                    surface.format     = (uint)ftex.texture.Format;
                    surface.aa         = (uint)ftex.texture.AAMode;
                    surface.use        = (uint)ftex.texture.Use;
                    surface.alignment  = (uint)ftex.texture.Alignment;
                    surface.dim        = (uint)ftex.texture.Dim;
                    surface.width      = (uint)ftex.texture.Width;
                    surface.height     = (uint)ftex.texture.Height;
                    surface.depth      = (uint)ftex.texture.Depth;
                    surface.numMips    = (uint)ftex.texture.MipCount;
                    surface.imageSize  = (uint)ftex.texture.Data.Length;
                    surface.mipSize    = (uint)ftex.texture.MipData.Length;
                    surface.data       = ftex.texture.Data;
                    surface.mipData    = ftex.texture.MipData;
                    surface.mipOffset  = ftex.texture.MipOffsets;
                    surface.firstMip   = ftex.texture.ViewMipFirst;
                    surface.firstSlice = 0;
                    surface.numSlices  = ftex.texture.ArrayLength;
                    surface.imageCount = ftex.texture.MipCount;
                    surface.pitch      = ftex.texture.Pitch;
                    surface.texRegs    = GX2.CreateRegisters(surface);

                    SetChannelComponents();

                    Format     = FTEX.ConvertFromGx2Format((Syroot.NintenTools.Bfres.GX2.GX2SurfaceFormat)surface.format);
                    Width      = surface.width;
                    Height     = surface.height;
                    MipCount   = surface.numMips;
                    ArrayCount = surface.depth;

                    ImageEditorBase editor = (ImageEditorBase)LibraryGUI.GetActiveContent(typeof(ImageEditorBase));

                    if (editor != null)
                    {
                        UpdateEditor();
                    }
                }
            }
예제 #5
0
        public static BFLIM CreateNewFromImage()
        {
            BFLIM bflim = new BFLIM();

            bflim.CanSave   = true;
            bflim.IFileInfo = new IFileInfo();
            bflim.header    = new Header();

            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Multiselect = false;
            ofd.Filter      = FileFilters.GTX;
            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return(null);
            }

            FTEX ftex = new FTEX();

            ftex.ReplaceTexture(ofd.FileName, TEX_FORMAT.BC3_UNORM_SRGB, 1, 0, bflim.SupportedFormats, true, false, true, false);
            if (ftex.texture != null)
            {
                bflim.Text              = $"{Path.GetFileNameWithoutExtension(ofd.FileName)}.bflim";
                bflim.image             = new Image();
                bflim.image.Swizzle     = (byte)ftex.texture.Swizzle;
                bflim.image.BflimFormat = FormatsWiiU.FirstOrDefault(x => x.Value == ftex.Format).Key;
                if (ftex.UseBc4Alpha)
                {
                    bflim.image.BflimFormat = 16;
                }

                bflim.image.Height = (ushort)ftex.texture.Height;
                bflim.image.Width  = (ushort)ftex.texture.Width;

                bflim.Format    = FormatsWiiU[bflim.image.BflimFormat];
                bflim.Width     = bflim.image.Width;
                bflim.Height    = bflim.image.Height;
                bflim.ImageData = ftex.texture.Data;

                bflim.LoadComponents(bflim.Format, ftex.UseBc4Alpha);
            }

            return(bflim);
        }
예제 #6
0
        public override void Replace(string FileName)
        {
            FTEX ftex = new FTEX();

            ftex.ReplaceTexture(FileName, Format, 1, SupportedFormats, true, true, false);
            if (ftex.texture != null)
            {
                image.Swizzle     = (byte)ftex.texture.Swizzle;
                image.BflimFormat = ConvertFormatGenericToBflim(ftex.Format);
                image.Height      = (ushort)ftex.texture.Height;
                image.Width       = (ushort)ftex.texture.Width;

                Format = GetFormat(image.BflimFormat);
                Width  = image.Width;
                Height = image.Height;

                ImageData = ftex.texture.Data;

                UpdateForm();
            }
        }
예제 #7
0
            public void CreateNew(object sender, EventArgs args)
            {
                BFLIM bflim = new BFLIM();

                bflim.CanSave   = true;
                bflim.IFileInfo = new IFileInfo();
                bflim.header    = new Header();

                OpenFileDialog ofd = new OpenFileDialog();

                ofd.Multiselect = false;
                ofd.Filter      = FileFilters.GTX;
                if (ofd.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                FTEX ftex = new FTEX();

                ftex.ReplaceTexture(ofd.FileName, TEX_FORMAT.BC3_UNORM_SRGB, 1, 0, bflim.SupportedFormats, false, true, false);
                if (ftex.texture != null)
                {
                    bflim.Text              = ftex.texture.Name;
                    bflim.image             = new Image();
                    bflim.image.Swizzle     = (byte)ftex.texture.Swizzle;
                    bflim.image.BflimFormat = FormatsWiiU.FirstOrDefault(x => x.Value == ftex.Format).Key;
                    bflim.image.Height      = (ushort)ftex.texture.Height;
                    bflim.image.Width       = (ushort)ftex.texture.Width;

                    bflim.Format = FormatsWiiU[bflim.image.BflimFormat];
                    bflim.Width  = bflim.image.Width;
                    bflim.Height = bflim.image.Height;

                    bflim.ImageData = ftex.texture.Data;
                    var form = new GenericEditorForm(false, bflim.OpenForm());
                    LibraryGUI.CreateMdiWindow(form);

                    bflim.UpdateForm();
                }
            }