Skip to content

Instantly share code, notes, and snippets.

View iVanPan's full-sized avatar
💭
I may be slow to respond.

Van iVanPan

💭
I may be slow to respond.
  • Open to New Opportunities
  • HangZhou, China
View GitHub Profile
@iVanPan
iVanPan / UIImage+PSPDFKitAdditions.m
Created July 19, 2016 05:49 — forked from steipete/UIImage+PSPDFKitAdditions.m
Preload UIImage for super-smooth interaction. especially great if you use JPGs, which otherwise produce a noticeable lag on the main thread.
- (UIImage *)pspdf_preloadedImage {
CGImageRef image = self.CGImage;
// make a bitmap context of a suitable size to draw to, forcing decode
size_t width = CGImageGetWidth(image);
size_t height = CGImageGetHeight(image);
CGColorSpaceRef colourSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef imageContext = CGBitmapContextCreate(NULL, width, height, 8, width*4, colourSpace,
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little);

Videos