Image myImage = Image.FromFile("image.jpg"); Graphics g = this.CreateGraphics(); g.DrawImageUnscaled(myImage, 50, 50);
Bitmap bmp = new Bitmap(500, 500); Graphics g = Graphics.FromImage(bmp); g.DrawEllipse(Pens.Red, 0, 0, 100, 100); Image myImage = Image.FromFile("image.jpg"); g.DrawImageUnscaled(myImage, 50, 50); pictureBox1.Image = bmp;In this example, we first create a Bitmap object to use as our canvas. Then, we create a Graphics object from the bitmap and use it to draw a red ellipse. We also load an image from file and use the DrawImageUnscaled method to draw it onto the canvas at position (50, 50). Finally, we set the image of a PictureBox control to the bitmap to display it on the form. This method belongs to the System.Drawing.dll package library.