I am using this code for mask UIImage:
- (UIImage*)maskImage:(UIImage *)image withMask:(UIImage *)maskImage2 {
CGImageRef maskRef = maskImage2.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;
}
In the IOS 6 it work perfect and mask all the UIImage but i try it now on my iPhone 4 with IOS 4.3 and noticed that some of the images mask but have a black background as you can see in this image:
This is the mask image:
As you can noticed the first image is mask but it's have a black in the side, and the other images mask perfectly. i noticed that it happen with the same images every time. Any idea what can be the problem?
====================================
Edit
I try to save the images to my document and after a look on them it's look like the maskedImage
i saved without the black border,any idea why it show me this black border?