I'm trying to make a Quick Look generator. My understanding is that you can provide QLPreviewRequestSetDataRepresentation
any type of data that can be understood by Quick Look out-of-the-box. I'd like to provide image data (kUTTypeImage
).
Here's the simplest thing I can get to fail: load an input image and then immediately return it to QLPreviewRequestSetDataRepresentation
.
(Obviously, in my real application I would do some custom transformations to the image before returning it, but even this simplified example seems to fail.)
NSImage *inputImage = [[NSImage alloc] initWithContentsOfURL:inputImageURL];
QLPreviewRequestSetDataRepresentation(preview,
(__bridge CFDataRef)([inputImage TIFFRepresentation]),
kUTTypeImage,
nil);
This doesn't work, even though the documentation gives every indication that it should. The Quick Look generator just crashes and falls back to the default display.
I know the NSImage is being properly read from the Quick Look bundle.
I can set the data to HTML just fine, and even include the image as an attachment and render as HTML, but that's a hacky solution.