title: iPhone SDK: Problem saving one image over another
body: <p>basically I am making an app that involves a user taking a photo, or selecting one already on their device, and then placing an overlay onto the image.</p>
  
  <p>So, I seem to have coded everything fine, apart from one thing, after the user has selected the overlay and positioned it, when saved the size of the overlay has changed, whereas the x and y values seem correct.</p>
  
  <p>And so this is the code I use to add the overlay ("image" being the users photo):</p>
  
  <pre><code>float wid = (overlay.image.size.width);
  float hei = (overlay.image.size.height);
  
  overlay.frame = CGRectMake(0, 0, wid, hei);
  [image addSubview:overlay];
  </code></pre>
  
  <p>And this is the code used to save the resulting image:</p>
  
  <pre><code>UIGraphicsBeginImageContext(image.image.size);  
  
  // Draw the users photo  
  [image.image drawInRect:CGRectMake(0, 0, image.image.size.width, image.image.size.height)];  
  
  // Draw the overlay  
  float xx = (overlay.center.x);
  float yy = (overlay.center.y);
  
  CGRect aaFrame = overlay.frame;
  float width = aaFrame.size.width;
  float height = aaFrame.size.height;
  
  
  [overlay.image drawInRect:CGRectMake(xx, yy, width, height)];
      UIGraphicsEndImageContext();
  </code></pre>
  
  <p>Any help? Thanks</p>