예제 #1
0
 static void Main(string[] args)
 {
    if(args.Contains("/import"))
    {
        List<string> largs = new List<string>(args);
        largs.Remove("/import");
        s4pi.Helpers.RunHelper.Run(typeof(Import), largs.ToArray());
    }
    else if(args.Contains("/export"))
    {
        using (FileStream fs = new FileStream(args[1], FileMode.Open))
        {
            using (SaveFileDialog save = new SaveFileDialog() { Filter = "DDS DXT5|*.dds" })
            {
                if (save.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    using (FileStream fs2 = new FileStream(save.FileName, FileMode.Create))
                    {
                        RLEResource r = new RLEResource(1, fs);
                        r.ToDDS().CopyTo(fs2);
                    }
                }
            }
        }
    }
 }
예제 #2
0
 static void Main(string[] args)
 {
     if (args.Contains("/import"))
     {
         List <string> largs = new List <string>(args);
         largs.Remove("/import");
         s4pi.Helpers.RunHelper.Run(typeof(Import), largs.ToArray());
     }
     else if (args.Contains("/export"))
     {
         using (FileStream fs = new FileStream(args[1], FileMode.Open))
         {
             using (SaveFileDialog save = new SaveFileDialog()
             {
                 Filter = "DDS DXT5|*.dds", FileName = Path.GetFileName(args[1]), Title = "Export to DDS"
             })
             {
                 if (save.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                 {
                     using (FileStream fs2 = new FileStream(save.FileName, FileMode.Create))
                     {
                         RLEResource r = new RLEResource(1, fs);
                         r.ToDDS().CopyTo(fs2);
                     }
                 }
             }
         }
     }
 }
예제 #3
0
        private void Import_Shown(object sender, EventArgs e)
        {
            if (this.filename != "")
            {
                using (FileStream fs = new FileStream(this.filename, FileMode.Open))
                {
                    RLEResource r = new RLEResource(1, null);
                    r.ImportToRLE(fs, RLEResource.RLEVersion.RLES);
                    this.Result = new byte[r.RawData.Length];
                    r.RawData.CopyTo(this.Result, 0);
                    Environment.ExitCode = 0;
                }
            }

            this.Close();
        }
예제 #4
0
 private void Import_Shown(object sender, EventArgs e)
 {
     if (this.filename != "")
     {
         using (FileStream fs = new FileStream(this.filename, FileMode.Open))
         {
             RLEResource r = new RLEResource(1, null);
             r.ImportToRLE(fs);
             this.Result = new byte[r.RawData.Length];
             r.RawData.CopyTo(this.Result, 0);
             Environment.ExitCode = 0;
         }
     }
     
     this.Close();
 }
예제 #5
0
        /// <summary>
        /// Load a RLE image from a <see cref="System.IO.Stream"/>;
        /// if <paramref name="supportHSV"/> is passed and true (default is false), the image will
        /// support HSV shift operations.
        /// </summary>
        /// <param name="stream">The <see cref="System.IO.Stream"/> containing the RLE image to display,<br/>
        /// - or -<br/>
        /// <c>null</c> to clear the image and free resources.</param>
        /// <param name="supportHSV">Optional; when true, HSV operations will be supported on the image.</param>
        public void RLELoad(Stream stream, bool supportHSV = false)
        {
            if (stream != null && stream.Length > 0)
            {
                try
                {
                    this.Enabled = false;
                    Application.UseWaitCursor = true;
                    Application.DoEvents();

                    RLEResource rle = new RLEResource(1, stream);
                    ddsFile.Load(rle.ToDDS(), supportHSV);

                    loaded = true;
                }
                finally { this.Enabled = true; Application.UseWaitCursor = false; Application.DoEvents(); }
                this.supportHSV = supportHSV;
                ckb_CheckedChanged(null, null);
            }
            else
            {
                Clear();
            }
        }
예제 #6
0
        /// <summary>
        /// Load a RLE image from a <see cref="System.IO.Stream"/>;
        /// if <paramref name="supportHSV"/> is passed and true (default is false), the image will
        /// support HSV shift operations.
        /// </summary>
        /// <param name="stream">The <see cref="System.IO.Stream"/> containing the RLE image to display,<br/>
        /// - or -<br/>
        /// <c>null</c> to clear the image and free resources.</param>
        /// <param name="supportHSV">Optional; when true, HSV operations will be supported on the image.</param>
        public void RLELoad(Stream stream, bool supportHSV = false)
        {
            if (stream != null && stream.Length > 0)
            {
                try
                {
                    this.Enabled = false;
                    Application.UseWaitCursor = true;
                    Application.DoEvents();

                    RLEResource rle = new RLEResource(1, stream);
                    ddsFile.Load(rle.ToDDS(), supportHSV);

                    loaded = true;
                }
                finally { this.Enabled = true; Application.UseWaitCursor = false; Application.DoEvents(); }
                this.supportHSV = supportHSV;
                ckb_CheckedChanged(null, null);
            }
            else
                Clear();
        }