How to draw a pcitore in a control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i want to set a picture as a control's back ground by drawing it with
Graphics, but the Image class does not support the "FromFile" method in cf so
i can not load the pictrue from file. it there anyway to do that?
thx in advanced
 
Here's some sample of code of how to use draw using Graphics and
Bitmap

protected override void OnPaint(PaintEventArgs e) {
string file = string.Format("{0}\\image.jpg",

Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase));

Bitmap image = new Bitmap(file);

e.Graphics.DrawImage(image, this.ClientRectangle,
new Rectangle(0, 0, image.Width, image.Height),
GraphicsUnit.Pixel);
}
 
Here's a small code snippet for drawing a bitmap

[C# CODE]

protected override void OnPaint(PaintEventArgs e) {
string file = string.Format("{0}\\image.jpg",

Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);

Bitmap image = new Bitmap(file);

e.Graphics.DrawImage(image, this.ClientRectangle,
new Rectangle(0, 0, image.Width, image.Height),
GraphicsUnit.Pixel);
}


Regards,
Christian Resma Helle
http://christian-helle.blogspot.com
 
Back
Top