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.