在没有抗锯齿的情况下调整 CGImageRef 的大小 [英] Resize CGImageRef without anti-liasing

查看:190
本文介绍了在没有抗锯齿的情况下调整 CGImageRef 的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to resize a 10x10 pixel CGImageRef, captured like this:

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)

Then I need to make a 250x250 pixel image like this this, but the upscaled image looks like there is anti aliasing on it (looks like this)

推荐答案

try CGContextSetInterpolationQuality:

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

这篇关于在没有抗锯齿的情况下调整 CGImageRef 的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆