Hi there,
I've got mask images w/o alpha channel, pure black and white with a black polygone on the center sourrounded by white.
I've got png's image that I'd like to mask. the png have got an alpha channel. using the method here below : ok on simulator, but background is black on device ... any idea to fix that ?
- (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);
//CGImageRelease(maskRef);
return [UIImage imageWithCGImage:masked];
}