private void SelectSourceButton_Click(object sender, EventArgs e) { string fileName; using (var op = new OpenFileDialog { Filter = Consts.BitmapImportFilter }) { if (op.ShowDialog() != DialogResult.OK) { return; } fileName = op.FileName; } try { if (m_originalBitmap != null) { m_originalBitmap.Dispose(); } m_originalBitmap = BitmapProcessor.LoadBitmapFromFile(fileName); if (m_originalBitmap.Width > 2048 || m_originalBitmap.Height > 2048) { if (m_monochromeBitmap != null) { m_monochromeBitmap.Dispose(); m_monochromeBitmap = null; } SourceTextBox.Clear(); ResizeContainerPanel.Enabled = false; ConversionContainerPanel.Enabled = false; m_doNotUpdateMonochrome = true; NewWidthUpDown.Value = m_width = (int)NewWidthUpDown.Minimum; NewHeightUpDown.Value = m_height = (int)NewHeightUpDown.Minimum; m_doNotUpdateMonochrome = false; ImagePreviewSurface.Invalidate(); OkButton.Enabled = false; InfoBox.Show("Selected images is too big. Choose an image that has dimension lower than 2048x2048."); } else { SourceTextBox.Text = fileName; ConversionContainerPanel.Enabled = true; if (m_importMode) { NewWidthUpDown.Value = m_width = m_desireWidth; NewHeightUpDown.Value = m_height = m_desireHeight; } else { ResizeContainerPanel.Enabled = true; m_doNotUpdateMonochrome = true; NewWidthUpDown.Value = m_width = m_originalBitmap.Width; NewHeightUpDown.Value = m_height = m_originalBitmap.Height; m_doNotUpdateMonochrome = false; } CreateMonochromeBitmap(); ImagePreviewSurface.Invalidate(); OkButton.Enabled = true; } } catch (Exception ex) { InfoBox.Show("An error occured during opening image file!\n" + ex.Message); } }