2011-07-31 49 views
0

我有一個PictureBox控件,裏面有一個條形碼圖片,我希望能夠在同一張紙上多次添加此圖片。在PictureBox中打印圖像multiplier times

現在,我每次只能打印一張圖像,我想要添加5張或10張圖像並將它們放在一起並同時打印出來。

我該怎麼做?

+0

在您的PrintDocument.PrintPage事件處理程序中經常調用e.Graphics.DrawImage()。 –

回答

0

創建大小爲10個圖像的位圖,繪製條形碼,並將其放入PictureBox。

1

你可以結合所有圖像在一個圖像,然後打印該圖像。所以:

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; 
+0

@SzamDev你試過這個,這是否回答你的問題? –