Mega Code Archive

 
Categories / C# Tutorial / 2D Graphics
 

Load bmp image from file

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Windows.Forms;   class Form1 : Form   {     private Image theImage;     public Form1()     {       SetStyle(ControlStyles.Opaque, true);       theImage = new Bitmap("person.bmp");     }     protected override void OnPaint(PaintEventArgs e)     {       Graphics g = e.Graphics;       g.DrawImage(theImage, ClientRectangle);     }     [STAThread]     static void Main()     {       Application.EnableVisualStyles();       Application.Run(new Form1());     }   }