【发布时间】:2015-02-11 01:59:05
【问题描述】:
所以我有以下代码,并且在 const double colorMasking[6] 的行上,现在它是一个双精度但如果我清理并构建它说不兼容的指针类型传递双精度应该是浮点数。但是,如果我将其更改为浮动,错误就会消失,但是一旦我清理并再次构建,它就会说传递浮点数的不兼容指针类型应该是双倍的。和我刚刚做的完全相反。知道这里发生了什么吗?
-(UIImage *)changeWhiteColorTransparent: (UIImage *)image
{
CGImageRef rawImageRef=image.CGImage;
const double colorMasking[6] = {222, 255, 222, 255, 222, 255};
UIGraphicsBeginImageContext(image.size);
CGImageRef maskedImageRef=CGImageCreateWithMaskingColors(rawImageRef, colorMasking);
{
//if in iphone
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();
return result;
}
【问题讨论】:
-
愚蠢的问题:该错误消息标记了哪一行。
-
如果
colorMasking是CGFloat而不是double,它是否有效? -
@HotLicks 我认为是
CGImageRef maskedImageRef=CGImageCreateWithMaskingColors(rawImageRef, colorMasking);,因为这是他唯一一次通过colorMasking。 -
我也想知道用int初始化float数组是否有效。
-
文档提供:
CGImageRef CGImageCreateWithMaskingColors ( CGImageRef image, const CGFloat components[] );所以colorMasking应该是CGFloat类型。
标签: ios objective-c xcode pointers cgfloat