Note that there are some explanatory texts on larger screens.

plurals
  1. POretaining image quality while drawing high resolution pdf to iphone?
    primarykey
    data
    text
    <p>I have a problem related to pdf drawing in iPhone. When I draw the pdf in ipad it works fine but in iphone quality of image of page is not good. That image contains dark spots at the place of gray background.<br> Can anyone help me to solve this problem?</p> <p>thanks.</p> <pre><code>- (UIImage *) imageForPageIndex:(NSUInteger)pageIndex { UIImage *image = nil; if ([delegate illustration_Enable]) { CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = CGBitmapContextCreate(NULL, pageSize.width, pageSize.height, 8, /* bits per component*/ pageSize.width * 4, /* bytes per row */ colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); CGColorSpaceRelease(colorSpace); CGContextClipToRect(context, CGRectMake(0, 0, pageSize.width, pageSize.height)); [self renderPageAtIndex:pageIndex OnContext:context]; CGImageRef cgimage = CGBitmapContextCreateImage(context); CGContextRelease(context); image = [UIImage imageWithCGImage:cgimage]; CGImageRelease(cgimage); } else { CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = CGBitmapContextCreate(NULL, pageSize.width, pageSize.height, 8, /* bits per component*/ pageSize.width * 4, /* bytes per row */ colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); CGColorSpaceRelease(colorSpace); CGContextClipToRect(context, CGRectMake(0, 0, pageSize.width, pageSize.height)); [self renderPageAtIndex:pageIndex OnContext:context]; CGImageRef cgimage = CGBitmapContextCreateImage(context); CGContextRelease(context); image = [UIImage imageWithCGImage:cgimage]; CGImageRelease(cgimage); } return image; } -(void)renderPageAtIndex:(int)index OnContext:(CGContextRef)ctx{ if ([delegate illustration_Enable]) { if (index-1 == [imageList count]) { return; } UIImage *image = nil; image = [UIImage imageWithContentsOfFile:[imageList objectAtIndex:index-1]]; CGRect rect1 = CGRectMake(0, 0, image.size.width, image.size.height); CGRect rect2 = CGContextGetClipBoundingBox(ctx); CGAffineTransform transform = [self aspectFill:rect1 :rect2]; CGContextConcatCTM(ctx, transform); CGContextDrawImage(ctx, CGRectMake(0, 0, image.size.width, image.size.height), image.CGImage); } else { CGPDFPageRef page = CGPDFDocumentGetPage(pdf, index); CGRect rect1 = CGPDFPageGetBoxRect(page,kCGPDFMediaBox); CGRect rect2 = CGContextGetClipBoundingBox(ctx); CGAffineTransform transform; if (takeBookmarkImg) { transform = [self aspectFill:rect1 :rect2]; } else { transform = [self aspectFit:rect1 :rect2]; } CGContextConcatCTM(ctx, transform); CGContextDrawPDFPage(ctx, page); } } - (CGAffineTransform) aspectFit:(CGRect)innerRect :(CGRect) outerRect { scaleFactor = MIN(outerRect.size.width/innerRect.size.width, outerRect.size.height/innerRect.size.height); baseScaleFactor = scaleFactor; CGAffineTransform scale = CGAffineTransformMakeScale(scaleFactor, scaleFactor); CGRect scaledInnerRect = CGRectApplyAffineTransform(innerRect, scale); CGAffineTransform translation = CGAffineTransformMakeTranslation((outerRect.size.width - scaledInnerRect.size.width) / 2 - scaledInnerRect.origin.x-(totalMoveX+moveX), (outerRect.size.height - scaledInnerRect.size.height) / 2 - scaledInnerRect.origin.y+(totalMoveY+moveY)); return CGAffineTransformConcat(scale, translation); } </code></pre> <p>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload