Get QuickLook preview image for file

前端 未结 2 1024
我寻月下人不归
我寻月下人不归 2020-12-31 17:41

Is there any way to get the quick look preview image for a file?

I\'m looking for something like this:

NSImage *image = [QuickLookPreviewer quickLookPr

2条回答
  •  無奈伤痛
    2020-12-31 18:33

    See QLThumbnailRequest in the docs: https://developer.apple.com/library/mac/#documentation/UserExperience/Reference/QLThumbnailRequest_Ref/Reference/reference.html

    NSURL *path = aFileUrl;
    
    NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:(NSString *)kQLThumbnailOptionIconModeKey];
    
    CGImageRef ref = QLThumbnailImageCreate(kCFAllocatorDefault, (CFURLRef)path, CGSizeMake(600, 800 /* Or whatever size you want */), (CFDictionaryRef)options);
    

提交回复
热议问题