Friday, 24 February 2012

Invert of any object in iphone

UIGraphicsBeginImageContext(rgbImg.image.size);
    CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeCopy);
    UIImage * image=rgbImg.image;
    [image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
    CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeDifference);
    CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(),[UIColor whiteColor].CGColor);
    CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, image.size.width, image.size.height));
    rgbImg.image= UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

No comments:

Post a Comment