问题
I don't know how to fill picturebox with small loaded image multiple times and then save it. Picturebox has a size determined by user. Then I load the image and put it to picturebox as many times as possible with current size of picturebox. Any idea how to do that? Example bellow shows how it should look like (but here there is a background and i cant save this multiple images in one picture)
PS. I can't place image because i don't have enough reputation:(
回答1:
You add the image as the BackgroundImage
with BackgroundImageLayout = ImageLayout.Tile
and then save the result with DrawToBitmap
.
pictureBox1.BackgroundImage = someImage;
pictureBox1.BackgroundImageLayout = ImageLayout.Tile;
using (Bitmap bmp = new Bitmap(pictureBox1.ClientSize.Width,
pictureBox1.ClientSize.Height))
{
pictureBox1.DrawToBitmap(bmp, pictureBox1.ClientRectangle);
bmp.Save(yourSaveFileName, System.Drawing.Imaging.ImageFormat.Png);
}
For full control you would use DrawImage
to draw multiple images into the Bitmap
of the Image, but for your question the above should do..
来源:https://stackoverflow.com/questions/33848324/fill-picturebox-with-multiple-images-and-save-it-c-sharp