我正在尝试调整10x10像素CGImageRef的大小,如下所示:

CGImageRef imageRef = CGImageCreateWithImageInRect(screenShot, CGRectMake(mouseLoc.x-5, screen_height-mouseLoc.y-5, 10, 10));

CGContextRef mainViewContentContext = CGBitmapContextCreate (NULL, maskImage.size.width, maskImage.size.height, 8, maskImage.size.height*4, colorSpace, kCGImageAlphaPremultipliedFirst);

CGContextDrawImage(mainViewContentContext, NSMakeRect(0,0, maskImage.size.width, maskImage.size.height), imageRef);

然后,我需要制作一个像this这样的250x250像素的图像,但是放大后的图像看起来像上面有反锯齿(看起来像this)

最佳答案

尝试CGContextSetInterpolationQuality:

// disable interpolation like this:
CGContextSetInterpolationQuality(mainViewContentContext, kCGInterpolationNone);
// now draw

关于objective-c - 调整CGImageRef的大小而无需抗锯齿,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7232729/

10-13 05:32