I need to be able to take multiple images and overlay a smaller one on top of a larger one and save the result as a single ima开发者_开发技巧ge. How would I go about accomplishing this in C#?
- Load the first image using new Bitmap(filename)
- Load the second image the same way.
- Get a Graphics object by calling Graphics.FromImage(bitmap1)
- Call graphics.DrawImage(bitmap2...) to put the second image on the first
- Call bitmap1.Save(...) to save the new image to a file.
It depends on the environment that you're working and what you want to do with the resulting image.
If it's within a Winforms or console application then GDI+ would be one way to do it. Examples of how to do such manipulations can be found at Bob Powell's GDI+ FAQ.
If it's within a WPF, Silverlight or XNA then there are better alternatives available.
精彩评论