http://stackoverflow.com/questions/17448102/ios-masking-an-image-keeping-retina-scale-factor-in-accountios
I want to mask an image by passing another image as mask. I am able to mask the image but the resulting image doesn't look good. It is jagged at borders.ide
I guess the problem is related to retina graphics. The scale property for the two images are different as:code
The resulting image has a scale value of 1.get
The code I am using is:it
+ (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); CGImageRelease(mask); UIImage *maskedImage = [UIImage imageWithCGImage:masked ]; CGImageRelease(masked); return maskedImage; }
How can I get a masked image which follows retina scale?io