title: Programmatically create large PNG based on smaller PNG in Objective-C
body: <p>I'm trying to programatically create a large PNG based on a smaller PNG in Objective-C. The smaller PNG is a logo that I'm using as a watermark. I want to place the smaller PNG in the lower right corner of the large PNG. The large PNG should be the size of the source video and has a transparent background.</p>
  
  <p>I have this working in C# but can't quite figure out how to get working in Objective-C. I think I should be using the Image I/O libraries.</p>
  
  <pre><code>Bitmap bm;
  int shortestSide;
  if (videoWidth &gt; videoHeight)
      shortestSide = videoHeight;
  else
      shortestSide = videoWidth;
  
  var logoDimension = (int)(shortestSide * 0.05);
  
  Image logo;
  if (logoDimension &lt;= 16)
      logo = Resources.watermark_16x16;
  else if (logoDimension &lt;= 24)
      logo = Resources.watermark_24x24;
  else if (logoDimension &lt;= 36)
       logo = Resources.watermark_36x36;
  else if (logoDimension &lt;= 48)
       logo = Resources.watermark_48x48;
  else if (logoDimension &lt;= 54)
       logo = Resources.watermark_54x54;
  else
       logo = Resources.watermark_64x64;
  
  var logoPoint = new Point(videoWidth - logo.Width * 2, videoHeight - logo.Height * 2);
  
  var image = new Bitmap(videoWidth, videoHeight, PixelFormat.Format32bppArgb);
  using (var g = Graphics.FromImage(image))
  {
      g.DrawImageUnscaled(logo, logoPoint);
  }
  
  bm = image;
  bm.Save(watermarkPath, ImageFormat.Png);
  </code></pre>
  
  <p>Thanks!</p>