开发者

How to merge two images into a single Jpeg

开发者 https://www.devze.com 2022-12-27 22:41 出处:网络
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.

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#?


  1. Load the first image using new Bitmap(filename)
  2. Load the second image the same way.
  3. Get a Graphics object by calling Graphics.FromImage(bitmap1)
  4. Call graphics.DrawImage(bitmap2...) to put the second image on the first
  5. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号