1

I'm need to draw a CGImageRef on a PDF-page that is zoomable. Everything looks fine as long as it's zoomed out. But as soon as I zoom in, of course it gets all blurry.

Is there any way increase the quality of the zoomed image? Here is my code:

-(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);
}

And this is what the image looks like zoomed out:

Zoomed out

And zoomed in:

Zoomed in

Thanks for any help!

kolt siewerts
  • 41
  • 1
  • 3
  • Possible duplicate of http://stackoverflow.com/questions/500027/how-to-zoom-in-out-an-uiimage-object-when-user-pinches-screen? – Narayanan Ramamoorthy May 18 '11 at 09:12
  • Thanks for the idea! But I'm afraid I have to stick with a CGImageRef because this is what the PDF-Engine I use expects. I guess I have to improve the CGImageRef somehow... – kolt siewerts May 18 '11 at 10:53
  • Please try to set CGContextSetInterpolationQuality to kCGInterpolationNone. I distinctly remember having done that trying to speed things up but as a surprise, resized image quality improved drastically. – TheBlack May 20 '11 at 00:59
  • @TheBlack Sorry, but I tried that already ether: [screenshot](http://kolt-siewerts.com/1.png) – kolt siewerts May 20 '11 at 07:35

0 Answers0