1

我需要在可缩放的 PDF 页面上绘制 CGImageRef。只要缩小,一切看起来都很好。但是,一旦我放大,它当然会变得模糊。

有什么办法可以提高缩放图像的质量?这是我的代码:

-(id)initWithRect:(CGRect)aRect 
          andPage:(NSUInteger)aPage 
     andAddressID:(NSString *)anID
         andTitle:(NSString *)aTitle
        visible:(BOOL)amIvisible{
    self = [super init];
    if(self) {![enter image description here][1]
        self.highlightRect = aRect;
        self.page = aPage;
        self.addressID = anID;
        self.title = aTitle;
        icon = [UIImage imageNamed:@"test.png"];
        self.visible = amIvisible;
    }
    return self;
}

-(void) drawInContext:(CGContextRef)context{
    CGRect imageRect = CGRectMake((highlightRect.origin.x + (highlightRect.size.width/2) -16), 
                                  highlightRect.origin.y-40,
                                  36,
                                  25);
    CGImageRef iconRef = [icon CGImage];
    CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
    if(visible)
        CGContextDrawImage(context,imageRect,iconRef);
}

这就是图像缩小后的样子:

缩小

并放大:

放大

谢谢你的帮助!

4

0 回答 0