
July 29th, 2005, 08:35 PM
|
|
Registered User
|
|
Join Date: Jul 2005
Posts: 2
Time spent in forums: 11 m 22 sec
Reputation Power: 0
|
|
|
C# .net custom class problem
okay so basically, i have a gdi+ function that loads & draws an image and ran on a button click, and when i tried to make a class out of it, it quit displaying the image. the code for the button is as follows:
Code:
private void button1_Click(object sender, System.EventArgs e)
{
Bitmap bmp=new Bitmap("gdip.bmp");
Graphics grf=this.CreateGraphics();
grf.DrawImage(bmp,0,0);
grf.Dispose();
}
.. the class looks like so:
Code:
public class Bmp
{
private Graphics grf;
private Bitmap img;
~Bmp(){grf.Dispose();}
public Bmp(Form f,string fn)
{
grf=f.CreateGraphics();
ld(fn);
}
public bool ld(string fn)
{
img=new Bitmap(fn);
return false;
}
public bool dr()
{
grf.DrawImage(this.img,0,0);
return false;
}
}
and the class calls look like this:
Code:
Bmp bmp;
private void Form1_Load(object sender, System.EventArgs e)
{
bmp=new Bmp(this,"gdip.bmp");
bmp.dr();
}
please note that there are no errors on compile, and the bitmap class actually loads the bitmap, but no draw
|