Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            invertFormAcces();
            labelSimulationStatus.Visible = true;
            int[] thresholds      = { 15 };
            int[] dictionarySizes = { 1024, 2048, 4096, 8192, 16384, 32768, 65536 };


            if (OriginalFile != null)
            {
                List <SimulationResult> simulations = new List <SimulationResult>(thresholds.Length * dictionarySizes.Length);

                string   delimiter = ",";
                string[] parts     = OriginalFile.Split('\\');
                string   imageName = parts[parts.Length - 1].Split('.')[0];

                foreach (int threshold in thresholds)
                {
                    StringBuilder sb = new StringBuilder();

                    sb.Append("Marime dictionar" + delimiter);
                    sb.Append("Prag" + delimiter);
                    sb.Append("Timp de executie compresie" + delimiter);
                    sb.Append("Timp de executie decompresie" + delimiter);
                    sb.Append("Numar de blocuri" + delimiter);
                    sb.Append("Marime fisier comprimat" + delimiter);
                    sb.Append("Marime fisier decomprimat" + delimiter);
                    sb.AppendLine("PSNR" + delimiter);

                    foreach (int dictionarySize in dictionarySizes)
                    {
                        AvqCompression = new AVQ(OriginalFile);
                        simulations.Add(AvqCompression.StartSimulation(threshold, dictionarySize));
                        labelSimulationStatus.Text = "Simulation D_" + dictionarySize + " P_" + threshold + " finished";
                        labelSimulationStatus.Refresh();
                    }

                    string filePath = @"D:\Facultate\Licenta\Img\" + imageName + "_P_" + threshold + ".csv";

                    foreach (SimulationResult result in simulations)
                    {
                        sb.Append(result.DictionarySize + delimiter);
                        sb.Append(result.Threshold + delimiter);
                        sb.Append(result.CompressionTime + delimiter);
                        sb.Append(result.DeompressionTime + delimiter);
                        sb.Append(result.BlocksNumber.ToString() + delimiter);
                        sb.Append(result.CompressedFileSize.ToString() + delimiter);
                        sb.Append(result.DecompressedFileSize.ToString() + delimiter);
                        sb.AppendLine(result.PSNR.ToString() + delimiter);
                    }

                    File.WriteAllText(filePath, sb.ToString());
                }
            }
            else
            {
                MessageBox.Show("You need to choose an image!");
            }



            labelSimulationStatus.Visible = false;
            invertFormAcces();
            MessageBox.Show("Simulation finished!");
        }