Akmal Ali

Akmal Ali

  • NA
  • 16
  • 29.6k

why the exeption appier

Feb 14 2011 2:06 AM

Hi.
My name is Akmal. And I try to use C# for my job. I need to draw some images on PictureBox control. This is code:
 
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Windows.Forms;
namespace
test_Move_Image
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Image map;
Bitmap bmp;
private void button1_Click(object sender, EventArgs e)
{
Image img = Image.FromFile(@"c:\MAP_TAS\wash.jpg");
Bitmap tbmp = new Bitmap(img.Width, img.Height);
Graphics tgr = Graphics.FromImage(tbmp);
tgr.DrawImage(img, 0, 0);
map = tbmp;
draw_map();
tgr.Dispose();
tbmp.Dispose();
}
private void draw_map()
{
pictureBox1.Image =
null;
pictureBox1.Image = map;
GC.Collect();
GC.WaitForPendingFinalizers();
}

}
}

 

Try to run this code and you will see the erorr. But i don't uderstand where the problem in my code?
Please help me.

Answers (11)