我正在使用CGImageCreateWithMaskingColors()
从UIImage
中移除特定颜色。颜色去除过程工作正常,但在屏蔽过程后图像中的透明区域变黑。请参阅下面粘贴的代码。
CGImageRef imageRef = self.editedImage.CGImage;
CGImageRef myColorMaskedImage = CGImageCreateWithMaskingColors(imageRef, myMaskingColors);
UIImage *newImage = [self normalizeWithAlpha:[UIImage imageWithCGImage:myColorMaskedImage]];
CGImageRelease(myColorMaskedImage);
答案 0 :(得分:0)
你必须做第二次掩蔽传递来掩盖黑色:
float colorMaskingLow[6] = {0, low, 0, low, 0, low};
float colorMaskingHigh[6] = {high, 255, high, 255, high, 255};
UIImage *image = [self maskColors:colorMaskingHigh inImage:image];
return [self maskColors:colorMaskingLow inImage:image];
(maskColors:inImage:
函数是您在上面指定的函数)