* Merge winforms framework content to working branch (#14) * Breadcrumb / TOC / Move net5 to net folder (#15) * change path from net5 to net * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Add .net 5 winforms placeholder article (#16) * added some metadata and adjusted net5 placeholder * corrections * corrections * corrections * Test1 * Swapping landing page vs concept * fix links * Fix links * Fix desc
2.1 KiB
title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | ms.date | dev_langs | helpviewer_keywords | ms.assetid | |||||
|---|---|---|---|---|---|---|---|---|---|
| How to: Draw an Existing Bitmap to the Screen | 03/30/2017 |
|
|
5bc558d7-b326-4050-a834-b8600da0de95 |
How to: Draw an Existing Bitmap to the Screen
You can easily draw an existing image on the screen. First you need to create a xref:System.Drawing.Bitmap object by using the bitmap constructor that takes a file name, xref:System.Drawing.Bitmap.%23ctor%28System.String%29. This constructor accepts images with several different file formats, including BMP, GIF, JPEG, PNG, and TIFF. After you have created the xref:System.Drawing.Bitmap object, pass that xref:System.Drawing.Bitmap object to the xref:System.Drawing.Graphics.DrawImage%2A method of a xref:System.Drawing.Graphics object.
Example
This example creates a xref:System.Drawing.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:
[!code-csharpSystem.Drawing.WorkingWithImages#21] [!code-vbSystem.Drawing.WorkingWithImages#21]
Compiling the Code
The preceding example is designed for use with Windows Forms, and it requires xref:System.Windows.Forms.PaintEventArgs e, which is a parameter of the xref:System.Windows.Forms.Control.Paint event handler.
