Exemplo n.º 1
0
 private void SelectImageButton_Click(object sender, EventArgs e)
 {
     if (OpenImageDialog.ShowDialog() == DialogResult.OK)
     {
         PathLabel.Text = OpenImageDialog.FileName;
     }
 }
Exemplo n.º 2
0
        private void OpenImageFile()
        {
            string strHeadImagePath;
            HImage image;

            OpenImageDialog.Title    = "Open Image file";
            OpenImageDialog.ShowHelp = true;
            OpenImageDialog.Filter   = "(*.gif)|*.gif|(*.jpg)|*.jpg|(*.JPEG)|*.JPEG|(*.bmp)|*.bmp|(*.png)|*.png|All files (*.*)|*.*";
            DialogResult result = OpenImageDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                try
                {
                    strHeadImagePath = OpenImageDialog.FileName;
                    image            = new HImage(strHeadImagePath);
                    myHalcon.myImage = image;
                    hWndCtrl.ClearResult();
                    hWndCtrl.addIconicVar(image);
                    hWndCtrl.repaint();
                }
                catch
                {
                    MessageBox.Show("format not correct");
                }
            }
        }
        private void LoadImageBtn_Click(object sender, EventArgs e)
        {
            if (OpenImageDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    using (var stream = OpenImageDialog.OpenFile())
                        image = new Bitmap(stream);

                    imageName = Path.GetFileNameWithoutExtension(OpenImageDialog.FileName)?.Trim();

                    Properties.Settings.Default.LastImage = OpenImageDialog.FileName;
                }
                catch (ArgumentException)
                {
                    MessageBox.Show(this, @"The selected file was not a valid image.", @"Invalid image file",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    image     = null;
                    imageName = null;
                }
                finally
                {
                    isChanged = true; // force update
                    RedrawTimer.Stop();
                    RedrawTimer.Start();
                }
            }
        }
Exemplo n.º 4
0
 private void SignaturePicture_Click(object sender, EventArgs e)
 {
     if (OpenImageDialog.ShowDialog() != DialogResult.OK)
     {
         return;
     }
     SignaturePicture.Load(OpenImageDialog.FileName);
 }
 private void SearchBackgroundImagePath_Click(object sender, EventArgs e)
 {
     OpenImageDialog.FileName = BackgroundImagePath.Text;
     if (OpenImageDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         BackgroundImagePath.Text = OpenImageDialog.FileName;
     }
 }
Exemplo n.º 6
0
 private void BrowseTileLogo(ref MetroTextBox textBox)
 {
     OpenImageDialog.InitialDirectory = CurrentMenuItem.TargetDirectory;
     OpenImageDialog.FileName         = textBox.Text;
     if (OpenImageDialog.ShowDialog() == DialogResult.OK)
     {
         textBox.Text = PathUtils.GetRelativePath(OpenImageDialog.FileName, CurrentMenuItem.TargetDirectory);
     }
 }
Exemplo n.º 7
0
 private void Download_bt_Click(object sender, EventArgs e)
 {
     if (OpenImageDialog.ShowDialog() == DialogResult.OK)
     {
         string filePath = OpenImageDialog.FileName;
         imageEditor.LoadImage(filePath);
         imageField.Refresh();
     }
 }
Exemplo n.º 8
0
        private void ImageButtonClick(object Sender, EventArgs e)
        {
            OpenImageDialog.Title = ImageDialogTitles[Sender];
            if (OpenImageDialog.ShowDialog() == DialogResult.OK)
            {
                try {
                    var LoadedImage = Image.FromFile(OpenImageDialog.FileName);

                    var       Width      = LoadedImage.Width;
                    var       Height     = LoadedImage.Height;
                    const int BorderSize = 2;
                    if (Width >= Height)
                    {
                        if (Width > ((PictureBox)Sender).Width - BorderSize)
                        {
                            Height = Height * (((PictureBox)Sender).Width - BorderSize) / Width;
                            Width  = ((PictureBox)Sender).Width - BorderSize;
                        }
                    }
                    else
                    {
                        if (Height > ((PictureBox)Sender).Height - BorderSize)
                        {
                            Width  = Width * (((PictureBox)Sender).Height - BorderSize) / Height;
                            Height = ((PictureBox)Sender).Height - BorderSize;
                        }
                    }

                    if (Width != LoadedImage.Width || Height != LoadedImage.Height)
                    {
                        var ScaledBitmap = new Bitmap(Width, Height);
                        ScaledBitmap.SetResolution(LoadedImage.HorizontalResolution, LoadedImage.VerticalResolution);

                        using (var GraphicsCanvas = Graphics.FromImage(ScaledBitmap)){
                            GraphicsCanvas.CompositingMode    = CompositingMode.SourceCopy;
                            GraphicsCanvas.CompositingQuality = CompositingQuality.HighQuality;
                            GraphicsCanvas.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                            GraphicsCanvas.SmoothingMode      = SmoothingMode.HighQuality;
                            GraphicsCanvas.PixelOffsetMode    = PixelOffsetMode.HighQuality;

                            using (var Attributes = new ImageAttributes()){
                                Attributes.SetWrapMode(WrapMode.TileFlipXY);

                                GraphicsCanvas.DrawImage(LoadedImage, new Rectangle(0, 0, Width, Height),
                                                         0, 0, LoadedImage.Width, LoadedImage.Height,
                                                         GraphicsUnit.Pixel, Attributes);
                            }
                        }
                        LoadedImage = ScaledBitmap;
                    }
                    ((PictureBox)Sender).Image = LoadedImage;
                }catch (Exception ex) {
                    Log.Error(ex);
                    MessageBox.Show("Could not load image: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 9
0
 private void OpenImage_Click(object sender, EventArgs e)
 {
     if (OpenImageDialog.ShowDialog() == DialogResult.OK)
     {
         //Открываем исходное изображение
         SourceImage src = new SourceImage();
         src.ImagePath       = OpenImageDialog.FileName;
         MethodCanny.Visible = true;
     }
 }
Exemplo n.º 10
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (OpenImageDialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            SelectImage.Text = OpenImageDialog.FileName;
            FileStream file = File.Open(SelectImage.Text, FileMode.Open);

            pictureBox1.Image = Image.FromStream(file);
            file.Close();
        }
Exemplo n.º 11
0
 // Load image from file
 // Called from Form control
 private void LoadImageForm_Load(object sender, EventArgs e)
 {
     if (OpenImageDialog.ShowDialog() == DialogResult.OK)
     {
         ImagePanel.img        = Image.FromFile(OpenImageDialog.FileName);
         ImageScaleInput.Value = (decimal)ImagePanel.img.Height / ImagePanel.img.Width;
     }
     else
     {
         Close();
     }
 }
        private void LoadImageButton_Click(object sender, EventArgs e)
        {
            if (OpenImageDialog.ShowDialog() == DialogResult.OK)
            {
                Image selectedImage = Image.FromFile(OpenImageDialog.FileName);

                secretImage          = new Bitmap(selectedImage, plaintextSize);
                SecretImageBox.Image = secretImage as Image;

                CalculateAndShowStats();
            }
        }
Exemplo n.º 13
0
 private void PathButton_Click(object sender, EventArgs e)
 {
     if (OpenImageDialog.ShowDialog() == DialogResult.OK)
     {
         PathTextBox.Text       = OpenImageDialog.FileName;
         InputBitmap            = new Bitmap(PathTextBox.Text);
         OriginalImageBox.Image = InputBitmap;
         width     = InputBitmap.Size.Width;
         height    = InputBitmap.Size.Height;
         PB2.Value = 0;
     }
     ResizeButton.Enabled = true;
     restoreb.Enabled     = false;
 }
Exemplo n.º 14
0
        private async void FileOpenMenuItem_Click(object sender, EventArgs e)
        {
            if (OpenImageDialog.ShowDialog() == DialogResult.OK)
            {
                using (var originalBitmap = Bitmap.FromFile(OpenImageDialog.FileName) as Bitmap)
                {
                    OriginalImage.Image = originalBitmap.Clone() as Bitmap;

                    Stopwatch timer = new Stopwatch();

                    BitmapPixelsGrayscaleImage.Image = await Task.Run(() =>
                    {
                        timer.Start();

                        Bitmap grayscaleBitmap = originalBitmap.Clone() as Bitmap;

                        using (BitmapPixels grayscaleBitmapPixels = new BitmapPixels(grayscaleBitmap))
                        {
                            grayscaleBitmapPixels.Lock();

                            MakeGrayscal(grayscaleBitmapPixels);

                            timer.Stop();

                            return(grayscaleBitmap);
                        }
                    });

                    BitmapPixelsConvertTimeLabel.Text = $"{timer.ElapsedMilliseconds} milliseconds";

                    timer.Reset();

                    SetPixelsGrayscaleImage.Image = await Task.Run(() =>
                    {
                        timer.Start();

                        Bitmap grayscaleBitmap = originalBitmap.Clone() as Bitmap;

                        MakeGrayscal(grayscaleBitmap);

                        timer.Stop();

                        return(grayscaleBitmap);
                    });

                    SetPixelConvertTimeLabel.Text = $"{timer.ElapsedMilliseconds} milliseconds";
                }
            }
        }
Exemplo n.º 15
0
        private void OpenImage()
        {
            if (OpenImageDialog.ShowDialog() == DialogResult.OK)
            {
                String path       = OpenImageDialog.FileName;
                Image  inputImage = Image.FromFile(path);
                PlainText_Image.Image = inputImage;

                if (inputImage != null)
                {
                    PlainText_Image.Image = inputImage;

                    PlaintextCorrelationButton.Enabled = true;
                    PlaintextHistogramButton.Enabled   = true;
                    PlaintextSpectraButton.Enabled     = true;
                    PlaintextFeaturesButton.Enabled    = true;

                    BioEncryptButton.Enabled = true;
                    CAEncryptButton.Enabled  = true;
                    FDEncryptButton.Enabled  = true;
                }
            }
        }
Exemplo n.º 16
0
        private void open(object sender, EventArgs e)
        {
            OpenImageDialog dialog = new OpenImageDialog();
            DialogResult    result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                SchetsWin s;

                if (dialog.FileName.EndsWith(".schets"))
                {
                    s = new SchetsWin(File.ReadAllText(dialog.FileName));
                }
                else
                {
                    Image  img = Image.FromFile(dialog.FileName);
                    Bitmap bmp = new Bitmap(img);
                    s = new SchetsWin(bmp);
                }

                s.MdiParent = this;
                s.Show();
            }
        }
Exemplo n.º 17
0
        private void MLoadImgBtn_Click(object sender, EventArgs e)
        {
            string strHeadImagePath;
            HImage image;

            OpenImageDialog.Title    = "Open Image file";
            OpenImageDialog.ShowHelp = true;
            OpenImageDialog.Filter   = "(*.gif)|*.gif|(*.jpg)|*.jpg|(*.JPEG)|*.JPEG|(*.bmp)|*.bmp|(*.png)|*.png|All files (*.*)|*.*";
            DialogResult result = OpenImageDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                try
                {
                    strHeadImagePath = OpenImageDialog.FileName;
                    image            = new HImage(strHeadImagePath);
                    camera3.myImage  = image;
                }
                catch
                {
                    MessageBox.Show("format not correct");
                }
            }
        }
Exemplo n.º 18
0
 private void MenuItemOpen_Click(object sender, EventArgs e)
 {
     var result = OpenImageDialog.ShowDialog();
 }