C # synthesize JPG images into BMP Images

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.