Skip to content

Instantly share code, notes, and snippets.

@wilg
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilg/2d7f3057345321db0202 to your computer and use it in GitHub Desktop.
Save wilg/2d7f3057345321db0202 to your computer and use it in GitHub Desktop.
Quick Look Doesn't Work!
#include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h>
#include <QuickLook/QuickLook.h>
#include <Cocoa/Cocoa.h>
OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options);
void CancelPreviewGeneration(void *thisInterface, QLPreviewRequestRef preview);
OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options)
{
@autoreleasepool {
NSURL *inputImageURL = (__bridge_transfer NSURL *)(CFBundleCopyResourceURL(QLPreviewRequestGetGeneratorBundle(preview),
(__bridge CFStringRef)@"MyImage",
(__bridge CFStringRef)@"png", NULL));
NSImage *inputImage = [[NSImage alloc] initWithContentsOfURL:inputImageURL];
QLPreviewRequestSetDataRepresentation(preview,
(__bridge CFDataRef)([inputImage TIFFRepresentation]),
kUTTypeImage,
nil);
}
return noErr;
}
void CancelPreviewGeneration(void *thisInterface, QLPreviewRequestRef preview)
{
// Implement only if supported
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment