コード例 #1
0
        private void BuildDXT(object sender, System.EventArgs e)
        {
            DDSTool dds = new DDSTool();

            LevelInfo id = SelectedImageData();

            LoadDDS(dds.Execute(1, id.TextureSize, id.Format));
            //id.Refresh();
        }
コード例 #2
0
        public bool Parse(List <string> argv)
        {
            int i = ArgParser.Parse(argv, "-txtr");

            if (i < 0)
            {
                return(false);
            }

            //get Parameters
            string filename    = "";
            string output      = "";
            string texturename = "";
            string num         = "";
            int    levels      = 9;

            System.Drawing.Size sz = new System.Drawing.Size(512, 512);
            SimPe.Plugin.ImageLoader.TxtrFormats format = SimPe.Plugin.ImageLoader.TxtrFormats.DXT1Format;

            while (argv.Count > i)
            {
                if (ArgParser.Parse(argv, i, "-image", ref filename))
                {
                    continue;
                }
                if (ArgParser.Parse(argv, i, "-out", ref output))
                {
                    continue;
                }
                if (ArgParser.Parse(argv, i, "-name", ref texturename))
                {
                    continue;
                }
                if (ArgParser.Parse(argv, i, "-levels", ref num))
                {
                    levels = Convert.ToInt32(num); continue;
                }
                if (ArgParser.Parse(argv, i, "-width", ref num))
                {
                    sz.Width = Convert.ToInt32(num); continue;
                }
                if (ArgParser.Parse(argv, i, "-height", ref num))
                {
                    sz.Height = Convert.ToInt32(num); continue;
                }
                if (ArgParser.Parse(argv, i, "-format", ref num))
                {
                    switch (num)
                    {
                    case "dxt1": format = SimPe.Plugin.ImageLoader.TxtrFormats.DXT1Format; break;

                    case "dxt3": format = SimPe.Plugin.ImageLoader.TxtrFormats.DXT3Format; break;

                    case "dxt5": format = SimPe.Plugin.ImageLoader.TxtrFormats.DXT5Format; break;

                    case "raw24": format = SimPe.Plugin.ImageLoader.TxtrFormats.Raw24Bit; break;

                    case "raw32": format = SimPe.Plugin.ImageLoader.TxtrFormats.Raw32Bit; break;

                    case "raw8": format = SimPe.Plugin.ImageLoader.TxtrFormats.Raw8Bit; break;
                    }
                    continue;
                }
                SimPe.Message.Show(Help()[0]);
                return(true);
            }

            //check if the File exists
            if (!System.IO.File.Exists(filename))
            {
                SimPe.Message.Show(filename + " was not found.");
                return(true);
            }
            if (output.Trim() == "")
            {
                SimPe.Message.Show("Please specify an output file using -out");
                return(true);
            }

            //build TXTR File
            ImageData id = new SimPe.Plugin.ImageData(null);

            if ((System.IO.File.Exists(PathProvider.Global.NvidiaDDSTool)) && ((format == ImageLoader.TxtrFormats.DXT1Format) || (format == ImageLoader.TxtrFormats.DXT3Format) || (format == ImageLoader.TxtrFormats.DXT5Format)))
            {
                LoadDDS(id, DDSTool.BuildDDS(filename, levels, format, "-sharpenMethod Smoothen"));
            }
            else
            {
                LoadTXTR(id, filename, sz, levels, format);
            }

            Rcol rcol = new GenericRcol(null, false);

            rcol.FileName       = texturename;
            rcol.FileDescriptor = new SimPe.Packages.PackedFileDescriptor();
            rcol.Blocks         = new IRcolBlock[1];
            rcol.Blocks[0]      = id;

            rcol.SynchronizeUserData();
            System.IO.FileStream   fs = System.IO.File.Create(output);
            System.IO.BinaryWriter bw = new System.IO.BinaryWriter(fs);
            bw.Write(rcol.FileDescriptor.UserData);
            bw.Close();
            bw = null;
            fs.Close();
            fs.Dispose();
            fs = null;

            return(true);
        }