1

目前我正在执行以下操作来重新缩放图像:

CGImageRef resizeCGImage(CGImageRef image, size_t new_width, size_t new_height)
{


CGColorSpaceRef colorspace = CGImageGetColorSpace(image);
CGContextRef context = CGBitmapContextCreate(NULL, new_width,new_height,
                                             8,
                                             new_width*4,
                                             colorspace,
                                             kCGImageAlphaNoneSkipLast);

if (context != NULL)
{
    CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
    CGContextDrawImage(context, CGRectMake(0 , 0, new_width, new_height), image);
    CGImageRef imgRef = CGBitmapContextCreateImage(context);
    CGContextRelease(context);

    return imgRef;
}

return NULL;

}

当我从 1920x1080 重新缩放到 1280x720 时,生成的图像质量太低。它在小文本(变得难以阅读)周围最为明显。

有没有更好的方法(由 Cocoa API 提供)来重新缩放图像?“更好”是指更好的图像质量。

4

1 回答 1

2

使用 CILanczosScaleTransform 过滤器尝试 Core Image。

于 2013-11-04T20:25:39.403 回答