Example #1
0
        private void btnOpenOriginal_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Title = "Select an image file.";
            ofd.Filter = "Png Images(*.png)|*.png|Jpeg Images(*.jpg)|*.jpg";
            ofd.Filter += "|Bitmap Images(*.bmp)|*.bmp";

            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                StreamReader streamReader = new StreamReader(ofd.FileName);
                originalBitmap = (Bitmap)Bitmap.FromStream(streamReader.BaseStream);
                streamReader.Close();

                previewBitmap = originalBitmap.CopyToSquareCanvas(picPreview.Width);
                picPreview.Image = previewBitmap;

                ApplyFilter(true);
            }
        }
Example #2
0
 /// <summary>
 /// Open image button calls CopyToSquareCanvas() method  and loads the image in pictureBox
 /// </summary>
 /// <param name="sender">is given which couses the event</param>
 /// <param name="e">is given event</param>
 private void btnOpenOriginal_Click(object sender, EventArgs e)
 {
     OpenFileDialog ofd = new OpenFileDialog();
     ofd.Title = "Select an image file.";
     ofd.Filter = "Jpeg Images(*.jpg)|*.jpg|Png Images(*.png)|*.png |Bitmap Images(*.bmp)|*.bmp";
     try
     {
         if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             pictureName = ofd.FileName;
             StreamReader streamReader = new StreamReader(pictureName);
             originalBitmap = (Bitmap)Bitmap.FromStream(streamReader.BaseStream);
             streamReader.Close();
             previewBitmap = originalBitmap.CopyToSquareCanvas(picPreview.Width);
             picPreview.Image = previewBitmap;
             ApplyFilter(true);
         }
     }
     catch (ArgumentException)
     {
         MessageBox.Show("The file is corrupt. Please choose another file");
     }
 }