Hi there, I'm trying to put white color in my images to transparent with the following code. Problem is that "CGImageRef maskedTransparent" is blank. I don't understand because the code I'm using is nearly a copy paste from the doc ... Any idea ?
(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);
//Array defining min & max RGB values to be transformed to transparent colors. float maskingMinMax[6] = {255, 255, 255, 255, 255, 255};
//masking image to remove range in maskinLinMax CGImageRef maskedTransparent = CGImageCreateWithMaskingColors(masked, maskingMinMax);
return [UIImage imageWithCGImage:maskedTransparent];
}