Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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