Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
CGImageRef方法_C_Core Foundation_Cgimage_Cgimageref - Fatal编程技术网

CGImageRef方法

CGImageRef方法,c,core-foundation,cgimage,cgimageref,C,Core Foundation,Cgimage,Cgimageref,我从一个示例中复制了此方法以对图像应用过滤器,但我遇到了一个问题: CGImageRef createStandardImage(CGImageRef image) { const size_t width = CGImageGetWidth(image); const size_t height = CGImageGetHeight(image); CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();

我从一个示例中复制了此方法以对图像应用过滤器,但我遇到了一个问题:

    CGImageRef createStandardImage(CGImageRef image) 
{
    const size_t width = CGImageGetWidth(image);
    const size_t height = CGImageGetHeight(image);
    CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
    CGContextRef ctx = CGBitmapContextCreate(NULL, width, height, 8, 4*width, space,
                                             kCGBitmapByteOrder32Big | kCGImageAlphaPremultipliedFirst);
    CGColorSpaceRelease(space);
    CGContextDrawImage(ctx, CGRectMake(0, 0, width, height), image);
    CGImageRef dstImage = CGBitmapContextCreateImage(ctx);
    CGContextRelease(ctx);
    return dstImage;
}
我在添加此方法时收到警告

警告:语义问题:函数“createStandardImage”没有以前的原型

…如果我尝试调用它,我会出错:

错误:语义问题:“createStandardImage”的类型冲突


为什么???

我已经看到,如果我在我的ViewController中插入此方法,我会收到警告,但在尝试使用此方法时没有错误…您将此方法放置在何处?最后(尝试)我将此方法放在一个.h文件中,因此我包含此简单文件。我一直在警告,但现在效果很好