【问题标题】:cgimagecreatewithmaskingcolors changes all the transparent region to blackcgimagecreatewithmaskingcolors 将所有透明区域更改为黑色
【发布时间】:2013-02-22 06:06:14
【问题描述】:

我正在使用CGImageCreateWithMaskingColors()UIImage 中删除特定颜色。颜色去除过程正常,但图像中的透明区域在屏蔽过程后变黑。请参阅下面粘贴的代码。

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

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

【问题讨论】:

    标签: ios uiimage core-graphics


    【解决方案1】:

    您必须进行第二次遮罩处理才能遮盖黑色:

        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: 函数就是您在上面指定的)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-04
      • 2011-02-12
      • 2014-05-27
      • 2019-08-24
      • 2012-11-29
      • 1970-01-01
      • 1970-01-01
      • 2011-08-20
      相关资源
      最近更新 更多