public DrawImage ( Image image, Point destPoints ) : void | ||
image | Image | Image. |
destPoints | Point | Destination points. |
return | void |
Bitmap bmp = new Bitmap("image.jpg"); // load image from file Graphics g = this.CreateGraphics(); // get graphics object g.DrawImage(bmp, 0, 0); // draw image at location 0,0
Bitmap bmp = new Bitmap("image.jpg"); // load image from file Rectangle destRect = new Rectangle(0, 0, 100, 100); // destination rectangle for image Rectangle srcRect = new Rectangle(0, 0, bmp.Width, bmp.Height); // source rectangle for image Graphics g = this.CreateGraphics(); // get graphics object g.DrawImage(bmp, destRect, srcRect, GraphicsUnit.Pixel); // draw image using rectanglesIn this example, we load an image from a file and define two rectangles - one for the destination location and size of the image, and one for the source location and size of the image. The DrawImage method is then used to draw the image onto the form using these rectangles. These examples utilize classes from the System.Drawing package library, which provides classes for working with images, graphics, and drawing in C#.
public DrawImage ( Image image, Point destPoints ) : void | ||
image | Image | Image. |
destPoints | Point | Destination points. |
return | void |