In C #, sometimes there are several image display problems, such as a background image, and images that are always to be displayed on the background image, how can I combine these two images into one image for display?
The following example provides a solution,CodeAs follows:
// Strwinepath Image
// Strbackpic background image
Private void testpaint (string strwinepath, string strwinedetailbackpic)
{
// Obtain the image of the wine. The image format of the wine is JPG.
Image imgwine = image. fromfile (strwinepath );
// Obtain the background image. The format of the background image is also in JPG format. Currently, the image is in BMP format.
Bitmap BMP = new Bitmap (strbackpic );
Obtain the drawing surface of the background image
Graphics G = graphics. fromimage (BMP );
// Draw the wine image to the background image
G. drawimage (imgwine, 149,209,100,416 );
// Load and display the background image to the background
This. backgroundimage = BMP;
This. backgroundimagelayout = system. Windows. Forms. imagelayout. Stretch;
}
This completes the synthesis of two images.