0

我使用 CGContextDrawImage 绘制我的设计图像,但它太模糊了。

请帮助我提高它的质量。

我用这个来画画:

//NSImage* design_image

两种尺寸都相同,我用它来插值

CGContextRef ct_ref=[context CGContext];
CGContextSetAllowsAntialiasing(ct_ref, YES);
CGContextSetShouldAntialias(ct_ref, YES);
CGContextSetInterpolationQuality(ct_ref, kCGInterpolationHigh);

id hints = [NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:NSImageInterpolationDefault] forKey:NSImageHintInterpolation];

CGImageRef img_ref=[design_image CGImageForProposedRect:&image_dr_rct context:context hints:hints];

CGContextDrawImage(ct_ref, CGRectMake(image_dr_rct.origin.x, image_dr_rct.origin.y, image_dr_rct.size.width, image_dr_rct.size.height), img_ref);
4

1 回答 1

0

如果您在绘制图像时得到模糊的结果,则问题可能与缩放图像有关。我无法从您的问题中判断您绘制的图像是比原始图像大还是小,但无论哪种方式,您都可以获得较差的结果。您可以尝试不同的插值设置,例如NSImageInterpolationHigh,但最好的办法是创建所需大小的原始图像。

于 2018-02-09T12:59:10.407 回答