Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have build such kind of application using approximatively the same approach except :</p> <ul> <li>I cache the generated image on the disk and always generate two to three images in advance in a separate thread.</li> <li>I don't overlay with a <code>UIImage</code> but instead draw the image in the layer when zooming is 1. Those tiles will be released automatically when memory warnings are issued.</li> </ul> <p>Whenever the user start zooming, I acquire the <code>CGPDFPage</code> and render it using the appropriate CTM. The code in <code>- (void)drawLayer: (CALayer*)layer inContext: (CGContextRef) context</code> is like :</p> <pre><code>CGAffineTransform currentCTM = CGContextGetCTM(context); if (currentCTM.a == 1.0 &amp;&amp; baseImage) { //Calculate ideal scale CGFloat scaleForWidth = baseImage.size.width/self.bounds.size.width; CGFloat scaleForHeight = baseImage.size.height/self.bounds.size.height; CGFloat imageScaleFactor = MAX(scaleForWidth, scaleForHeight); CGSize imageSize = CGSizeMake(baseImage.size.width/imageScaleFactor, baseImage.size.height/imageScaleFactor); CGRect imageRect = CGRectMake((self.bounds.size.width-imageSize.width)/2, (self.bounds.size.height-imageSize.height)/2, imageSize.width, imageSize.height); CGContextDrawImage(context, imageRect, [baseImage CGImage]); } else { @synchronized(issue) { CGPDFPageRef pdfPage = CGPDFDocumentGetPage(issue.pdfDoc, pageIndex+1); pdfToPageTransform = CGPDFPageGetDrawingTransform(pdfPage, kCGPDFMediaBox, layer.bounds, 0, true); CGContextConcatCTM(context, pdfToPageTransform); CGContextDrawPDFPage(context, pdfPage); } } </code></pre> <p>issue is the object containg the <code>CGPDFDocumentRef</code>. I synchronize the part where I access the <code>pdfDoc</code> property because I release it and recreate it when receiving memoryWarnings. It seems that the <code>CGPDFDocumentRef</code> object do some internal caching that I did not find how to get rid of.</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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