Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to make a user control like a panel or a textbox with 9 images as the background.
And the format of the images are Targa Image.
I use the dll in the link below to load TGA Images in the Winform.
.NET Targa Image Reader[^]

I want the images are assigned into this format:

top left corner , top center , top right corner ,

center left , center center , center right ,

bottom left corner , bottom center , bottom right corner ,


The images in the 4 corners are fixed in size while the other 5 images will change its size with the height and width of the control. Also the position of the images will change along the size of the control. I perfer to use Graphic to make it but not picture boxes because I do not want to create 9 boxes for each control.

At least, I hope someone can show me the method and the code of how to make it with the first 3 images. Hope this will not be too difficult to make.
Posted

1 solution

Handle the Paint event, and call the Graphics.DrawImage method for each of the 9 Images you have loaded, using the e.Graphics parameter supplied.

Each call can specify the destination location and rectangle, so it shouldn't be too difficult. The problem is going to be deciding how to fix the four corner images and stretch the others, if you want to keep the same aspect ratio to each image.
 
Share this answer
 
Comments
jackyng0123 24-Mar-12 6:15am    
Thanks, I have solved this question with your suggestion.
OriginalGriff 24-Mar-12 6:29am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900