Print image in PictureBox multipule times
I have a PictureBox control and there is a barcode image in it, I want to be able to add this image multipl开发者_如何学Goe times on the same paper.
Now, I can only print one image at every time and I want to add maybe 5 or 10 images and put them together and print them at the same time.
How I can do it??
You can combine all images in one image and then print that image. so:
int repeatTimes= 10;
Image imageSource = Image.FromFile(@"your image file path");//or your resource..
Bitmap myCombinationImage = new Bitmap(new Size(imageSource.Width, imageSource.Heigh * repeatTimes);
using (Graphics graphics = Graphics.FromImage(myCombinationImage))
{
Point newLocation = new Point(0, 0);
for (int imageIndex; imageIndex < repeatTimes; imageIndex++)
{
graphics.DrawImage(imageSource, newLocation);
newLocation = new Point(newLocation.X, newLocation.Y + imageSource.Height);
}
}
pictureBox.Image = myCombinationImage;
Create Bitmap with the size of 10 images, draw your barcodes, and put it into PictureBox.
精彩评论