//----------------------------------------------------------------------------------------------------------------------- // Form Designer Methods -- ENCODER //----------------------------------------------------------------------------------------------------------------------- private void btnLoadBMP_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Bitmap|*.bmp"; if (ofd.ShowDialog() == DialogResult.OK) { inputFilePathEncoder = ofd.FileName; bmpObject = Helpers.ReadBmpFormat(inputFilePathEncoder); pictureBoxOriginalImage.Image = bmpObject.GetBmpImage(); // orig img/ header/ bmp -> global auxOriginalImage = bmpObject.GetBmpData(); Helpers.DrawHistogram(pictureBoxHistogram, Helpers.CreateHistogram(bmpObject.GetBmpData()), (float)numericUpDownHistogramScale.Value); } }
private void btnEncodeOriginalImage_Click(object sender, EventArgs e) { try { if (String.IsNullOrEmpty(inputFilePathEncoder)) { throw new NullReferenceException(); } userKMaxReconstructionError = (int)numericUpDownKValue.Value; switch (comboBoxPredictorSelection.SelectedIndex) { case 1: userPredictorSelection = 1; break; case 2: userPredictorSelection = 2; break; case 3: userPredictorSelection = 3; break; case 4: userPredictorSelection = 4; break; case 5: userPredictorSelection = 5; break; case 6: userPredictorSelection = 6; break; case 7: userPredictorSelection = 7; break; case 8: userPredictorSelection = 8; break; default: userPredictorSelection = 0; break; } nlEngine = new NearLosslessEngine(bmpObject.GetBmpData()); nlEngine.CompressImage(userPredictorSelection, userKMaxReconstructionError); MessageBox.Show("Image was encoded succesfully!"); isFileEncoded = true; } catch (NullReferenceException) { MessageBox.Show("Warning: You forgot to load Original Image!"); } }