How to

draw image from file

Published: 21. January 2009 | Updated: 21. January 2009
License: Microsoft Public License (MS-PL)
Categories: GDI
Tags: C# GDI Winforms
Was this snippet helpful for you? YESYES / NONO

Import namespace

using System.Drawing;

Code

// create image from file
Image img = Image.FromFile(@"C:\image.jpg");

// create graphics
Graphics graphics = this.CreateGraphics();

// draw image
graphics.DrawImage(img, Point.Empty);

// dispose
img.Dispose();
graphics.Dispose();
Send us feedback about this snippet »



Related Snippets: