IPhone DevelopmentApplication in progressMaskUsage is the content to be introduced in this article, mainly to introduceMask. There is not much content. This article is mainly implemented by code. Let's take a look at the details.
Mask Method
- + (UIImage*) maskImage:(UIImage*)image withMask:(UIImage*)mask {
-
- CGImageRef imgRef = [image CGImage];CGImageRef maskRef = [mask CGImage];
- CGImageRef actualMask = CGImageMaskCreate(CGImageGetWidth(maskRef),CGImageGetHeight(maskRef),
- CGImageGetBitsPerComponent(maskRef),CGImageGetBitsPerPixel(maskRef),
- CGImageGetBytesPerRow(maskRef),CGImageGetDataProvider(maskRef),
- NULL, false);CGImageRef masked = CGImageCreateWithMask(imgRef,
- actualMask);return [UIImage imageWithCGImage:masked];
- }
Resize Images
- + (UIImage *) resizeImage:(UIImage *)image size:(CGSize)newSize {UIGraphicsBeginImageContext(newSize);
- [image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
- UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();UIGraphicsEndImageContext();
- return newImage;
- }
Method call/: Convert the original image to 120x120. In this step, the size of the original image is determined.
- UIImage * newImg = [Utils resizeImage: orgImg size: CGSizeMake (120,120)];
- UIImage * maskImg = [UIImage imageNamed: @ "mask.png"];
- // Obtain the parts of the mask.
- NewImg = [ImageUtils maskImage: newImg withMask: maskImg];
- // Start cropping (Clip) Slices
Summary: DetailsIPhone DevelopmentApplication in progressMaskI hope this article will help you with your usage!