Monday, June 27, 2011

iPhone Development

Adding an overlay to an image and saving the composite.

#import 
....
#pragma mark -
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 
{   
    imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
    OverlayView *overlay = [[OverlayView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGTH)];
    overlay.alpha = 0.6;  // Customize the opacity of the top image.
    [imageView addSubview:overlay];
    
    CGContextRef context = UIGraphicsGetCurrentContext();
    //UIImage *imageCopy = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    // Save image
    UIImageWriteToSavedPhotosAlbum(imageView.image, self,                                    @selector(image:didFinishSavingWithError:contextInfo:), context);
    [picker dismissModalViewControllerAnimated:YES];
}



0 comments: