none
c# crop from picturebox image and give original size

    Question

  • Hi,

    I need your help to solve my problem,

    I need to crop image from picture box , and i want to save cropped are as per original image.

    eg. if image has 2448x3264 dimension and it is scaled in  picturebox size like 340x480 and picturebox.sizemode value is zoom.

    so when i am cropping the image from picturebox it is giving me small picture but i want to same cropped image from original picture so result will be big.

    Below is my code

            int cropX;
            int cropY;
            int cropWidth;
            int cropHeight;
            Pen cropPen = new Pen(Color.Yellow, 2);
            Bitmap  cropBitmap ;
            Bitmap  bm_dest ;
            Bitmap bm_source ;
            int i = 1;
            FolderBrowserDialog s_fold=new FolderBrowserDialog();
            FolderBrowserDialog d_fold = new FolderBrowserDialog();
    
            string[] files;
            int pheight;
            int pwidth;
    
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                pictureBox1.Size = new Size(pictureBox1.Width, Height-(Height*5/100));
                pheight = pictureBox1.Height;
                pwidth = pictureBox1.Width;
    
    
                
                //            pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                using (OpenFileDialog dlg = new OpenFileDialog())
                {
                    dlg.Title = "Open Image";
                    dlg.Filter = "Jpge files (*.jpg)|*.jpg";
    
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        //            PictureBox PictureBox1 = new PictureBox();
    
                        // Create a new Bitmap object from the picture file on disk,
                        // and assign that to the PictureBox.Image property
    
                        pictureBox1.Width = pwidth;
                        pictureBox1.Height = pheight;
    
                        pictureBox1.Image = new Bitmap(dlg.FileName);
                        Type pboxType = pictureBox1.GetType();
                             PropertyInfo irProperty = pboxType.GetProperty("ImageRectangle", BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Instance);
                        Rectangle rectangle = (Rectangle)irProperty.GetValue(pictureBox1, null);
    
                        pictureBox1.Height = rectangle.Height;
                        pictureBox1.Width = rectangle.Width;
        
    
                    }
                }
            }
    
            private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Left)
                {
                    cropX = e.X;
                    cropY = e.Y;
                    cropPen.DashStyle = DashStyle.Solid;
                    Cursor = Cursors.Cross;
                }
                pictureBox1.Refresh();
            }
    
    
    
            private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Left)
                {
                    if (pictureBox1.Image == null)
                        return;
    
                    pictureBox1.Refresh();
                    cropWidth = e.X - cropX;
                    cropHeight = e.Y - cropY;
                    Graphics g = pictureBox1.CreateGraphics();
                    g.DrawRectangle(cropPen, cropX, cropY, cropWidth, cropHeight);
    
               
    
    
                }
    
            }
    
            private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
            {
               try
                {
                    Cursor = Cursors.Default;
                   try
                    {
    
                        if (cropWidth < 1)
                            return;
    
                        Rectangle rect = new Rectangle(cropX, cropY, cropWidth, cropHeight);
                        Bitmap bit = new Bitmap(pictureBox1.Image, pictureBox1.Width, pictureBox1.Height);
    
                        cropBitmap = new Bitmap(cropWidth, cropHeight);
                        Graphics g = Graphics.FromImage(cropBitmap);
                        g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                        g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
                        g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                        g.DrawImage(bit, 0, 0, rect, GraphicsUnit.Pixel);
    
                      
    //                    try
      //                  {
                          //  cropBitmap.Save("d:\\chetan_.jpg");
        //                }
          //              catch (Exception ex) { MessageBox.Show(ex.Message); } 
                       
                            cropBitmap.Save("d:\\abc.jpg");
                    
    
                    }
                    catch { }
                }
                catch { }
            }
    
          
    

    Friday, May 03, 2013 7:16 AM

Answers

  • Hi,

    you already have got all data you need: The orig image's size, the size of the image in the picturebox. You now have to compute the factor for the "zoom" of the image - by dividing the Width of the imagerectangle (your variable "rectangle") by the orig image width. Cast both to type double prior to the division. Now you have a factor thats smaller than 1 (if the orig image is bigger than the picturebox). Use this factor to map the click/mousedown-coordinates to the real coordinates in the image (divide e.X and e.Y by the factor and dont forget to subtract the x and y values of the imagerrectangle, since the image may have a different shape as the picturebox)

    Regards,

      Thorsten


    Friday, May 03, 2013 7:55 AM
  • Hi,

    if the coordinates in the textboxes are coordinates that represent real in-image-locations, you dont need to remap them, if they have some mousedown/click coordinates from the picturebox you'd need to remap them with the ratio of the image-in-the-picturebox's width to the real-image's width -> means you have to use the code we showed yesterday (you already have it inside your button1.click code).

    Regards,

      Thorsten

    • Marked as answer by crs81 Friday, May 03, 2013 10:08 AM
    Friday, May 03, 2013 9:13 AM
  • ...

        public partial class Form1 : Form
        {
            private int _offsetX;
            private int _offsetY;
            private double _zoom = 1.0;
            private int _x;
            private int _y;
            private int _w;
            private int _h;
    
            public Form1()
            {
                InitializeComponent();
                Init();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                if (_x < 0)
                    _x = 0;
                if (_y < 0)
                    _y = 0;
                if (_w > 0 && _h > 0)
                {
                    Rectangle r = new Rectangle((int)(_x / _zoom), (int)(_y / _zoom), (int)(_w / _zoom), (int)(_h / _zoom));
                    if (r.X + r.Width > this.pictureBox1.Image.Width)
                        r = new Rectangle(r.X, r.Y, this.pictureBox1.Image.Width - r.X, r.Height); 
                    if (r.Y + r.Height > this.pictureBox1.Image.Height)
                        r = new Rectangle(r.X, r.Y, r.Width, this.pictureBox1.Image.Height - r.Y);
                    Bitmap bmpCropped = ((Bitmap)this.pictureBox1.Image).Clone(r, this.pictureBox1.Image.PixelFormat);
    
                    Image iOld = this.pictureBox2.Image;
                    this.pictureBox2.Image = bmpCropped;
    
                    if (iOld != null)
                        iOld.Dispose();
                }
            }
    
            private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Left)
                {
                    _x = e.X - _offsetX;
                    _y = e.Y - _offsetY;
                    textBox1.Text = _x.ToString();
                    textBox2.Text = _y.ToString();
                }
            }
    
            void pictureBox1_MouseMove(object sender, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Left)
                {
                    _w = e.X - _offsetX - _x;
                    _h = e.Y - _offsetY - _y;
                    textBox3.Text = _w.ToString();
                    textBox4.Text = _h.ToString();
    
                    this.pictureBox1.Invalidate();
                }
            }
    
            void pictureBox1_Paint(object sender, PaintEventArgs e)
            {
                Rectangle r = new Rectangle(_x + _offsetX, _y + _offsetY, _w, _h);
                if (r.Width > 0 && r.Height > 0)
                    e.Graphics.DrawRectangle(Pens.Red, r);
            }
    
            void button2_Click(object sender, EventArgs e)
            {
                if (this.openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    using (Image img = Image.FromFile(this.openFileDialog1.FileName))
                        this.pictureBox1.Image = new Bitmap(img);
    
                    Type pboxType = pictureBox1.GetType();
                    PropertyInfo irProperty = pboxType.GetProperty("ImageRectangle", BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Instance);
                    Rectangle rectangle = (Rectangle)irProperty.GetValue(pictureBox1, null);
    
                    _offsetX = rectangle.X;
                    _offsetY = rectangle.Y;
    
                    _zoom = (double)rectangle.Width / (double)this.pictureBox1.Image.Width;
                }
            }
    
            private void Init()
            {
                this.pictureBox1 = new System.Windows.Forms.PictureBox();
                this.pictureBox2 = new System.Windows.Forms.PictureBox();
                this.button1 = new System.Windows.Forms.Button();
                this.textBox1 = new System.Windows.Forms.TextBox();
                this.textBox2 = new System.Windows.Forms.TextBox();
                this.textBox3 = new System.Windows.Forms.TextBox();
                this.textBox4 = new System.Windows.Forms.TextBox();
                this.button2 = new System.Windows.Forms.Button();
                this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
                // 
                // button2
                // 
                this.button2.Location = new System.Drawing.Point(663, 330);
                this.button2.Name = "button2";
                this.button2.Size = new System.Drawing.Size(75, 23);
                this.button2.TabIndex = 0;
                this.button2.Text = "open";
                this.button2.UseVisualStyleBackColor = true;
                this.button2.Click += new EventHandler(button2_Click);
                // 
                // pictureBox1
                // 
                this.pictureBox1.Location = new System.Drawing.Point(41, 37);
                this.pictureBox1.Name = "pictureBox1";
                this.pictureBox1.Size = new System.Drawing.Size(300, 270);
                this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
                this.pictureBox1.TabIndex = 0;
                this.pictureBox1.TabStop = false;
                this.pictureBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown);
                this.pictureBox1.MouseMove += new MouseEventHandler(pictureBox1_MouseMove);
                this.pictureBox1.Paint += new PaintEventHandler(pictureBox1_Paint);
                // 
                // pictureBox2
                // 
                this.pictureBox2.Location = new System.Drawing.Point(358, 37);
                this.pictureBox2.Name = "pictureBox2";
                this.pictureBox2.Size = new System.Drawing.Size(300, 270);
                this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
                this.pictureBox2.TabIndex = 0;
                this.pictureBox2.TabStop = false;
                // 
                // button1
                // 
                this.button1.Location = new System.Drawing.Point(583, 330);
                this.button1.Name = "button1";
                this.button1.Size = new System.Drawing.Size(75, 23);
                this.button1.TabIndex = 1;
                this.button1.Text = "crop";
                this.button1.UseVisualStyleBackColor = true;
                this.button1.Click += new System.EventHandler(this.button1_Click);
                // 
                // textBox1
                // 
                this.textBox1.Location = new System.Drawing.Point(41, 332);
                this.textBox1.Name = "textBox1";
                this.textBox1.Size = new System.Drawing.Size(100, 20);
                this.textBox1.TabIndex = 2;
                // 
                // textBox2
                // 
                this.textBox2.Location = new System.Drawing.Point(166, 333);
                this.textBox2.Name = "textBox2";
                this.textBox2.Size = new System.Drawing.Size(100, 20);
                this.textBox2.TabIndex = 2;
                // 
                // textBox3
                // 
                this.textBox3.Location = new System.Drawing.Point(287, 332);
                this.textBox3.Name = "textBox3";
                this.textBox3.Size = new System.Drawing.Size(100, 20);
                this.textBox3.TabIndex = 2;
                // 
                // textBox4
                // 
                this.textBox4.Location = new System.Drawing.Point(411, 332);
                this.textBox4.Name = "textBox4";
                this.textBox4.Size = new System.Drawing.Size(100, 20);
                this.textBox4.TabIndex = 2;
                // 
                // openFileDialog1
                // 
                this.openFileDialog1.FileName = "openFileDialog1";
                this.openFileDialog1.Filter = "Images (*.bmp;*.jpg;*.png)|*.bmp;*.jpg;*.png";
                // 
                // Form1
                // 
                this.ClientSize = new System.Drawing.Size(757, 402);
                this.Controls.Add(this.textBox4);
                this.Controls.Add(this.textBox3);
                this.Controls.Add(this.textBox2);
                this.Controls.Add(this.textBox1);
                this.Controls.Add(this.button1);
                this.Controls.Add(this.pictureBox2);
                this.Controls.Add(this.pictureBox1);
                this.Controls.Add(this.button2);
                this.Name = "Form1";
                this.Text = "Form1";
                this.FormClosing += new FormClosingEventHandler(Form1_FormClosing);
            }
    
            void Form1_FormClosing(object sender, FormClosingEventArgs e)
            {
                if (this.pictureBox1.Image != null)
                    this.pictureBox1.Image.Dispose();  
                if (this.pictureBox2.Image != null)
                    this.pictureBox2.Image.Dispose();
            }
    
            private System.Windows.Forms.PictureBox pictureBox1;
            private System.Windows.Forms.PictureBox pictureBox2;
            private System.Windows.Forms.Button button1;
            private System.Windows.Forms.TextBox textBox1;
            private System.Windows.Forms.TextBox textBox2;
            private System.Windows.Forms.TextBox textBox3;
            private System.Windows.Forms.TextBox textBox4;
            private System.Windows.Forms.Button button2;
            private System.Windows.Forms.OpenFileDialog openFileDialog1;
        }


    Regards,

      Thorsten



    Friday, May 03, 2013 9:45 AM

All replies

  • Hi,

    you already have got all data you need: The orig image's size, the size of the image in the picturebox. You now have to compute the factor for the "zoom" of the image - by dividing the Width of the imagerectangle (your variable "rectangle") by the orig image width. Cast both to type double prior to the division. Now you have a factor thats smaller than 1 (if the orig image is bigger than the picturebox). Use this factor to map the click/mousedown-coordinates to the real coordinates in the image (divide e.X and e.Y by the factor and dont forget to subtract the x and y values of the imagerrectangle, since the image may have a different shape as the picturebox)

    Regards,

      Thorsten


    Friday, May 03, 2013 7:55 AM
  • Thanks again to reply.

    I have tried my best

    belows is my code

      private void button6_Click(object sender, EventArgs e)
            {
    
                double wper = 100*pictureBox1.Width / pictureBox1.Image.Width ;
                double hper = 100*pictureBox1.Height / pictureBox1.Image.Height;
    //          wper = 1;
      //         hper = 1;
    
                Rectangle rect = new Rectangle(Convert.ToInt32(Convert.ToInt32(textBox1.Text) ), Convert.ToInt32(Convert.ToInt32(textBox2.Text)), Convert.ToInt32(Convert.ToInt32(textBox5.Text)), Convert.ToInt32(Convert.ToInt32(textBox6.Text)));
                rect.Size = new Size(Convert.ToInt32(rect.Size.Width * wper), Convert.ToInt32(rect.Size.Height * hper));
    
                Bitmap bit = new Bitmap(pictureBox1.Image, pictureBox1.Image.Width, pictureBox1.Image.Height);
    
                Bitmap cropBitmap_batch = new Bitmap(Convert.ToInt32(Convert.ToInt32(textBox5.Text)*wper), Convert.ToInt32(Convert.ToInt32(textBox6.Text)*hper));
                Graphics g = Graphics.FromImage(cropBitmap_batch);
                g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
                g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                g.DrawImage(bit, 0, 0, rect, GraphicsUnit.Pixel);
    
    
                cropBitmap_batch.Save("d:\\ccc.jpg");
     
                
               
    
             
    
            }

    Textbox1,textbox2,texbox5,textbox6 have cropping values from picturebox when image being cropped.

    Friday, May 03, 2013 8:52 AM
  • In another way the begin of the reply from Thorsten

    var TheUncroppedBitmap = new Bitmap(dlg.FileName); 
    pictureBox1.Image = new Bitmap(TheUncroppedBitmap);


    Success
    Cor

    Friday, May 03, 2013 9:11 AM
  • Hi,

    if the coordinates in the textboxes are coordinates that represent real in-image-locations, you dont need to remap them, if they have some mousedown/click coordinates from the picturebox you'd need to remap them with the ratio of the image-in-the-picturebox's width to the real-image's width -> means you have to use the code we showed yesterday (you already have it inside your button1.click code).

    Regards,

      Thorsten

    • Marked as answer by crs81 Friday, May 03, 2013 10:08 AM
    Friday, May 03, 2013 9:13 AM
  • ...

        public partial class Form1 : Form
        {
            private int _offsetX;
            private int _offsetY;
            private double _zoom = 1.0;
            private int _x;
            private int _y;
            private int _w;
            private int _h;
    
            public Form1()
            {
                InitializeComponent();
                Init();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                if (_x < 0)
                    _x = 0;
                if (_y < 0)
                    _y = 0;
                if (_w > 0 && _h > 0)
                {
                    Rectangle r = new Rectangle((int)(_x / _zoom), (int)(_y / _zoom), (int)(_w / _zoom), (int)(_h / _zoom));
                    if (r.X + r.Width > this.pictureBox1.Image.Width)
                        r = new Rectangle(r.X, r.Y, this.pictureBox1.Image.Width - r.X, r.Height); 
                    if (r.Y + r.Height > this.pictureBox1.Image.Height)
                        r = new Rectangle(r.X, r.Y, r.Width, this.pictureBox1.Image.Height - r.Y);
                    Bitmap bmpCropped = ((Bitmap)this.pictureBox1.Image).Clone(r, this.pictureBox1.Image.PixelFormat);
    
                    Image iOld = this.pictureBox2.Image;
                    this.pictureBox2.Image = bmpCropped;
    
                    if (iOld != null)
                        iOld.Dispose();
                }
            }
    
            private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Left)
                {
                    _x = e.X - _offsetX;
                    _y = e.Y - _offsetY;
                    textBox1.Text = _x.ToString();
                    textBox2.Text = _y.ToString();
                }
            }
    
            void pictureBox1_MouseMove(object sender, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Left)
                {
                    _w = e.X - _offsetX - _x;
                    _h = e.Y - _offsetY - _y;
                    textBox3.Text = _w.ToString();
                    textBox4.Text = _h.ToString();
    
                    this.pictureBox1.Invalidate();
                }
            }
    
            void pictureBox1_Paint(object sender, PaintEventArgs e)
            {
                Rectangle r = new Rectangle(_x + _offsetX, _y + _offsetY, _w, _h);
                if (r.Width > 0 && r.Height > 0)
                    e.Graphics.DrawRectangle(Pens.Red, r);
            }
    
            void button2_Click(object sender, EventArgs e)
            {
                if (this.openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    using (Image img = Image.FromFile(this.openFileDialog1.FileName))
                        this.pictureBox1.Image = new Bitmap(img);
    
                    Type pboxType = pictureBox1.GetType();
                    PropertyInfo irProperty = pboxType.GetProperty("ImageRectangle", BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Instance);
                    Rectangle rectangle = (Rectangle)irProperty.GetValue(pictureBox1, null);
    
                    _offsetX = rectangle.X;
                    _offsetY = rectangle.Y;
    
                    _zoom = (double)rectangle.Width / (double)this.pictureBox1.Image.Width;
                }
            }
    
            private void Init()
            {
                this.pictureBox1 = new System.Windows.Forms.PictureBox();
                this.pictureBox2 = new System.Windows.Forms.PictureBox();
                this.button1 = new System.Windows.Forms.Button();
                this.textBox1 = new System.Windows.Forms.TextBox();
                this.textBox2 = new System.Windows.Forms.TextBox();
                this.textBox3 = new System.Windows.Forms.TextBox();
                this.textBox4 = new System.Windows.Forms.TextBox();
                this.button2 = new System.Windows.Forms.Button();
                this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
                // 
                // button2
                // 
                this.button2.Location = new System.Drawing.Point(663, 330);
                this.button2.Name = "button2";
                this.button2.Size = new System.Drawing.Size(75, 23);
                this.button2.TabIndex = 0;
                this.button2.Text = "open";
                this.button2.UseVisualStyleBackColor = true;
                this.button2.Click += new EventHandler(button2_Click);
                // 
                // pictureBox1
                // 
                this.pictureBox1.Location = new System.Drawing.Point(41, 37);
                this.pictureBox1.Name = "pictureBox1";
                this.pictureBox1.Size = new System.Drawing.Size(300, 270);
                this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
                this.pictureBox1.TabIndex = 0;
                this.pictureBox1.TabStop = false;
                this.pictureBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown);
                this.pictureBox1.MouseMove += new MouseEventHandler(pictureBox1_MouseMove);
                this.pictureBox1.Paint += new PaintEventHandler(pictureBox1_Paint);
                // 
                // pictureBox2
                // 
                this.pictureBox2.Location = new System.Drawing.Point(358, 37);
                this.pictureBox2.Name = "pictureBox2";
                this.pictureBox2.Size = new System.Drawing.Size(300, 270);
                this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
                this.pictureBox2.TabIndex = 0;
                this.pictureBox2.TabStop = false;
                // 
                // button1
                // 
                this.button1.Location = new System.Drawing.Point(583, 330);
                this.button1.Name = "button1";
                this.button1.Size = new System.Drawing.Size(75, 23);
                this.button1.TabIndex = 1;
                this.button1.Text = "crop";
                this.button1.UseVisualStyleBackColor = true;
                this.button1.Click += new System.EventHandler(this.button1_Click);
                // 
                // textBox1
                // 
                this.textBox1.Location = new System.Drawing.Point(41, 332);
                this.textBox1.Name = "textBox1";
                this.textBox1.Size = new System.Drawing.Size(100, 20);
                this.textBox1.TabIndex = 2;
                // 
                // textBox2
                // 
                this.textBox2.Location = new System.Drawing.Point(166, 333);
                this.textBox2.Name = "textBox2";
                this.textBox2.Size = new System.Drawing.Size(100, 20);
                this.textBox2.TabIndex = 2;
                // 
                // textBox3
                // 
                this.textBox3.Location = new System.Drawing.Point(287, 332);
                this.textBox3.Name = "textBox3";
                this.textBox3.Size = new System.Drawing.Size(100, 20);
                this.textBox3.TabIndex = 2;
                // 
                // textBox4
                // 
                this.textBox4.Location = new System.Drawing.Point(411, 332);
                this.textBox4.Name = "textBox4";
                this.textBox4.Size = new System.Drawing.Size(100, 20);
                this.textBox4.TabIndex = 2;
                // 
                // openFileDialog1
                // 
                this.openFileDialog1.FileName = "openFileDialog1";
                this.openFileDialog1.Filter = "Images (*.bmp;*.jpg;*.png)|*.bmp;*.jpg;*.png";
                // 
                // Form1
                // 
                this.ClientSize = new System.Drawing.Size(757, 402);
                this.Controls.Add(this.textBox4);
                this.Controls.Add(this.textBox3);
                this.Controls.Add(this.textBox2);
                this.Controls.Add(this.textBox1);
                this.Controls.Add(this.button1);
                this.Controls.Add(this.pictureBox2);
                this.Controls.Add(this.pictureBox1);
                this.Controls.Add(this.button2);
                this.Name = "Form1";
                this.Text = "Form1";
                this.FormClosing += new FormClosingEventHandler(Form1_FormClosing);
            }
    
            void Form1_FormClosing(object sender, FormClosingEventArgs e)
            {
                if (this.pictureBox1.Image != null)
                    this.pictureBox1.Image.Dispose();  
                if (this.pictureBox2.Image != null)
                    this.pictureBox2.Image.Dispose();
            }
    
            private System.Windows.Forms.PictureBox pictureBox1;
            private System.Windows.Forms.PictureBox pictureBox2;
            private System.Windows.Forms.Button button1;
            private System.Windows.Forms.TextBox textBox1;
            private System.Windows.Forms.TextBox textBox2;
            private System.Windows.Forms.TextBox textBox3;
            private System.Windows.Forms.TextBox textBox4;
            private System.Windows.Forms.Button button2;
            private System.Windows.Forms.OpenFileDialog openFileDialog1;
        }


    Regards,

      Thorsten



    Friday, May 03, 2013 9:45 AM
  • Thank you very much, I go with your code and let you inform..
    Friday, May 03, 2013 10:05 AM
  • Yes , I wanted this. Thanks a lot...
    Friday, May 03, 2013 10:07 AM