title: Overlay watermark PNG on JPG file centered
body: <p>I have a method that takes an image and resizes it and saves it preserving the exif information.  What I want to do now is overlay a transparent PNG image on top of the image as a watermark.  The size of the png will always be larger than any of the images I want to place it on.  I would like to center it on top of the image preserving the watermark's aspect ratio. Here is the code as I have it so far:</p>
  
  <pre><code>private static void ResizeImage(Image theImage, int newSize, string savePath, IEnumerable&lt;PropertyItem&gt; propertyItems)
  {
      int width;
      int height;
      CalculateNewRatio(theImage.Width, theImage.Height, newSize, out width, out height);
      using (var b = new Bitmap(width, height))
      {
          using (var g = Graphics.FromImage(b))
          {
              g.SmoothingMode = SmoothingMode.AntiAlias;
              g.InterpolationMode = InterpolationMode.HighQualityBicubic;
              g.PixelOffsetMode = PixelOffsetMode.HighQuality;
              using(var a = Image.FromFile("Watermark.png"))
              {
                  g.DrawImage();  //What to do here?
              }
              g.DrawImage(theImage, new Rectangle(0, 0, width, height));
  
              var qualityParam = new EncoderParameter(Encoder.Quality, 80L);
              var codecs = ImageCodecInfo.GetImageEncoders();
              var jpegCodec = codecs.FirstOrDefault(t =&gt; t.MimeType == "image/jpeg");
              var encoderParams = new EncoderParameters(1);
              encoderParams.Param[0] = qualityParam;
              foreach(var item in propertyItems)
              {
                  b.SetPropertyItem(item);
              }
              b.Save(savePath, jpegCodec, encoderParams);
          }
      }
  }
  </code></pre>