Skip to content

Instantly share code, notes, and snippets.

@odrobnik
Created May 16, 2012 15:58
Show Gist options
  • Save odrobnik/2711594 to your computer and use it in GitHub Desktop.
Save odrobnik/2711594 to your computer and use it in GitHub Desktop.
Force decompression of UIImage on background queue before setting on UIImageView
dispatch_queue_t queue = dispatch_queue_create("PlusFlickrPhotoView Queue", DISPATCH_QUEUE_CONCURRENT);
dispatch_async(queue, ^{
// force decompress of image
UIGraphicsBeginImageContext(CGSizeMake(1, 1));
[image drawAtPoint:CGPointZero];
UIGraphicsEndImageContext();
// set the image on main thread
dispatch_sync(dispatch_get_main_queue(), ^{
_imageView.image = image;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment