private void DecompressionToolStripMenuItem_Click(object sender, EventArgs e) { try { decompression.Decompress(); Image im = decompression.GetImage(); ResultForm resultForm = new ResultForm(); resultForm.label1.Image = im; resultForm.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка декомпрессии"); } }
private void CompressionToolStripMenuItem_Click(object sender, EventArgs e) { try { saveFileDialog1.Filter = "Архивы (*.frc)|*.frc"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { ComprSettingsForm comprSettingsForm = new ComprSettingsForm(); if (comprSettingsForm.ShowDialog() != DialogResult.OK) { return; } compression.doCmp2x2 = comprSettingsForm.checkBox1.Checked; compression.doCmp4x4 = comprSettingsForm.checkBox2.Checked; compression.doCmp8x8 = comprSettingsForm.checkBox3.Checked; compression.SetImage(image); if (comprSettingsForm.radioButton1.Checked == true) { compression.linearCriterion = false; } else { compression.linearCriterion = true; } ProgressForm progressForm = new ProgressForm(compression, decompression); progressForm.ShowDialog(); FileStream stream = new FileStream(saveFileDialog1.FileName, FileMode.Create, FileAccess.Write); BinaryWriter writer = new BinaryWriter(stream, Encoding.ASCII); compression.WriteToFile(writer); stream.Close(); decompression.IterFuncSys = compression.IterFuncSys; decompression.Decompress(); Image im = decompression.GetImage(); ResultForm resultForm = new ResultForm(); resultForm.label1.Image = im; resultForm.Show(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка компресии"); } }