I want to change a colour in UIimage to transparent I am using below code to change black colour to transparent
-(void)changeColorToTransparent: (UIImage *)image{
CGImageRef rawImageRef = image.CGImage;
const float colorMasking[6] = { 0, 0, 0, 0, 0, 0 };
UIGraphicsBeginImageContext(image.size);
CGImageRef maskedImageRef = CGImageCreateWithMaskingColors(rawImageRef, colorMasking);
{
CGContextTranslateCTM(UIGraphicsGetCurrentContext(), 0.0, image.size.height);
CGContextScaleCTM(UIGraphicsGetCurrentContext(), 1.0, -1.0);
}
CGContextDrawImage(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, image.size.width, image.size.height), maskedImageRef);
UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
CGImageRelease(maskedImageRef);
UIGraphicsEndImageContext();
}
Its working fine.. But i want to draw a point on image by picking the colour form colour picker and then wants to make that point transparent.. I dont know how to give values in colour masking in below line
const float colorMasking[6] = { 0, 0, 0, 0, 0, 0 };
Can any one please help me how we can make a colour to transparent