Crop Image
Crop the image
//Croping start from x=0; y=0; and till width=125 and height=128;
UIImage *image =imageView.image;
CGRect cropRect = CGRectMake(0, 0, 125,128);
CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage], cropRect);
[imageView setImage:[UIImage imageWithCGImage:imageRef]];
CGImageRelease(imageRef);
Mask Image
- (UIImage*) maskImage:(UIImage *)image withMask:(UIImage *)maskImage { CGImageRef maskRef = maskImage.CGImage; CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(maskRef), CGImageGetHeight(maskRef), CGImageGetBitsPerComponent(maskRef), CGImageGetBitsPerPixel(maskRef), CGImageGetBytesPerRow(maskRef), CGImageGetDataProvider(maskRef), NULL, false); CGImageRef masked = CGImageCreateWithMask([image CGImage], mask); return [UIImage imageWithCGImage:masked]; }
Comments
Post a Comment