Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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)

enter image description here

PS. I can't place image because i don't have enough reputation:(

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
230 views
Welcome To Ask or Share your Answers For Others

1 Answer

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..


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...