I'm trying to allow the user to drag and position pre-selected images onto a image that they choose from their library or photo gallery and save the new edited image, as a whole.
The code below gets the two images merged, but does not save the second one in the same spot that the user selected. The "userImage" is the one that is not static. Thanks again for any input!
//Saves the image to the camera roll
- (IBAction)savePhoto:(id)sender {
UIImage *backgroundImage = [imageView image]; //This image is static
//This image will be moved around by a touchesMoved event
UIImage *userImage = [UIImage imageNamed:@"chopper_stash.png"];
UIGraphicsBeginImageContext(backgroundImage.size);
[backgroundImage drawInRect:CGRectMake(0, 0, backgroundImage.size.width, backgroundImage.size.height)];
//I realize that this sends the image to the top left, but how do I declare it's new location
[userImage drawInRect:CGRectMake(0,0, userImage.size.width, userImage.size.height)];
UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
//Save it to the camera roll
UIImageWriteToSavedPhotosAlbum(result, nil, nil, nil);
}