Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
You can easily draw an existing image on the screen. First you need to create a Bitmap object by using the bitmap constructor that takes a file name, Bitmap(String). This constructor accepts images with several different file formats, including BMP, GIF, JPEG, PNG, and TIFF. After you have created the Bitmap object, pass that Bitmap object to the DrawImage method of a Graphics object.
This example creates a Bitmap object from a JPEG file and then draws the bitmap with its upper-left corner at (60, 10).
The following illustration shows the bitmap drawn at the specified location:
Bitmap bitmap = new Bitmap("Grapes.jpg");
e.Graphics.DrawImage(bitmap, 60, 10);
Dim bitmap As New Bitmap("Grapes.jpg")
e.Graphics.DrawImage(bitmap, 60, 10)
The preceding example is designed for use with Windows Forms, and it requires PaintEventArgs e
, which is a parameter of the Paint event handler.
.NET Desktop feedback feedback
.NET Desktop feedback is an open source project. Select a link to provide feedback: