System.Drawing.Bitmap.Dispose C# (CSharp) Method

Dispose() protected method

protected Dispose ( bool disposing ) : void
disposing bool
return void
        protected override void Dispose(bool disposing)
        {
            if (disposing){
                if (NativeCGImage != null){
                    NativeCGImage.Dispose ();
                    NativeCGImage = null;
                }
                //Marshal.FreeHGlobal (bitmapBlock);
                bitmapBlock = IntPtr.Zero;
                Console.WriteLine("Bitmap Dispose");
            }
            base.Dispose (disposing);
        }

Usage Example

Example #1
1
 private void button3_Click(object sender, EventArgs e)
 {
     if (listView1.SelectedItems.Count != 1)
         return;
     OpenFileDialog od = new OpenFileDialog();
     od.Filter = "Bitmap file (*.bmp)|*.bmp";
     od.FilterIndex = 0;
     if (od.ShowDialog() == DialogResult.OK)
     {
         Section s = listView1.SelectedItems[0].Tag as Section;
         try
         {
             Bitmap bmp = new Bitmap(od.FileName);
             s.import(bmp);
             bmp.Dispose();
             pictureBox1.Image = s.image();
             listView1.SelectedItems[0].SubItems[3].Text = s.cnt.ToString();
             button4.Enabled = true;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
All Usage Examples Of System.Drawing.Bitmap::Dispose