示例#1
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();
            }
        }
示例#2
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);
        }
示例#3
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();
                }
            }