2013-02-22 5 views
0

UIImage에서 특정 색을 제거하려면 CGImageCreateWithMaskingColors()을 사용하고 있습니다. 색상 제거 프로세스는 잘 작동하지만 마스킹 프로세스 후 이미지의 투명 영역이 검게 변합니다. 아래 붙여 넣은 코드를 확인하십시오.cgimagecreatewithmaskingcolors가 투명 영역을 모두 검은 색으로 변경합니다.

CGImageRef imageRef = self.editedImage.CGImage; 
CGImageRef myColorMaskedImage = CGImageCreateWithMaskingColors(imageRef, myMaskingColors); 

UIImage *newImage = [self normalizeWithAlpha:[UIImage imageWithCGImage:myColorMaskedImage]]; 
CGImageRelease(myColorMaskedImage); 

답변

0

당신은 검은 색 마스크 두 번째 마스크 패스를해야 :합니다 (maskColors:inImage: 기능을 사용하면 위의 지정 것입니다)

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]; 

관련 문제