不使用反锯齿调整CGImageRef大小

5

我正在尝试调整一个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);

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

有趣的问题。大多数时候人们都在寻求相反的答案。 - Mark Ransom
1
仅供参考和便于谷歌搜索,这里发生的是称为“插值”,而不是抗锯齿。 - Chuck
1个回答

6

尝试使用CGContextSetInterpolationQuality

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

1
同样的问题 :( 我得不到完美的像素。 - Marek
@Marek 我误读了你的问题。我所做的示例强制使用HQ插值-正在更新... - justin

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接