How to splice multiple images into one image

Source: Internet
Author: User

There are 10 small pictures with numbers ranging from 0 to 9 on hand. Now we need to splice them into a multi-digit integer image. In. net, bitmap and graphics can be used to achieve this.

First, we need to create a new bitmap as the result after splicing, and then create a graphics class instance for painting:

Bitmap resultimg; // The image that stores the final splicing result
Graphics resultgraphics; // Example for drawing
Resultimg =   New Bitmap ( 45   *   4 , 60 ); // The width of each digital image is 45 pixels, and the height is 60 pixels. The four-digit Length Integer is displayed here.
Resultgraphics = Graphics. fromimage (resultimg );

Then, create an array for storing the path of the small image file, draw each small image from left to right in sequence using a loop, and finally use the bitmap as the image source of the picturebox control:

String [] Numberimgpath = { " 0. jpg " , " 3. jpg " , " 1. jpg " , " 7. jpg " };
For ( Int I =   0 ; I < Numberimgpath. length; I ++ )
{
Resultgraphics. drawimage (image. fromfile (numberimgpath [I]), 45   * I, 60 );
}
Resultgraphics. Dispose ();
Picturebox. Image = Resultimg;

Note the aboveCode45 is the width of a small digital image, and 60 is the height.

After the above code is executed, the image 0317 is displayed.

 

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.