``
CGContextRef context = CGBitmapContextCreate(NULL, target_w, target_h, 8, 0, rgb, bmi);
CGColorSpaceRelease(rgb);
UIImage *pdfImage = nil;
if (context != NULL) {
CGContextDrawPDFPage(context, page);
CGImageRef imageRef = CGBitmapContextCreateImage(context);
CGContextRelease(context);
pdfImage = [UIImage imageWithCGImage:imageRef scale:screenScale orientation:UIImageOrientationUp];
CGImageRelease(imageRef);
} else {
CGContextRelease(context);
}
``
``
__weak typeof(self) weakSelf = self;
void (^ loadThumbnailBlock)(NSIndexPath *indexPath) = ^ (NSIndexPath *indexPath) {
Page *page = [weakSelf.fetchedResultsController objectAtIndexPath:indexPath];
[weakSelf loadThumbnailForPage:page forIndexPath:indexPath];
};
``
``
__block NSBlockOperation *operation = [[NSBlockOperation alloc] init];
__weak typeof(self)weakSelf = self;
__weak typeof(operation)weakOp = operation;
MMVoidBlock thumbnailOperationBlock = ^ {
if (!weakOp.isCancelled) {
workerBlock();
}
[weakSelf.thumbnailOperationList removeObjectForKey:key];
};
[operation addExecutionBlock:thumbnailOperationBlock];
``
网友评论