git.y1.nz

SameBoy

Accurate GB/GBC emulator
download: https://git.y1.nz/archives/sameboy.tar.gz
README | Files | Log | Refs | LICENSE

QuickLook/GBThumbnailProvider.m

      1 #import "GBThumbnailProvider.h"
      2 
      3 extern OSStatus GBQuickLookRender(CGContextRef cgContext, CFURLRef url, bool showBorder);
      4 
      5 @interface QLThumbnailReply (private)
      6 @property unsigned iconFlavor;
      7 @end
      8 
      9 @implementation GBThumbnailProvider
     10 
     11 - (void)provideThumbnailForFileRequest:(QLFileThumbnailRequest *)request completionHandler:(void (^)(QLThumbnailReply *, NSError *))handler
     12 {
     13     CGSize size = {64, 64};
     14     CGSize maximumSize = request.maximumSize;
     15     while (size.width <= maximumSize.width / 2 &&
     16            size.width <= maximumSize.height / 2) {
     17         size.width *= 2;
     18     }
     19     size.height = size.width;
     20     QLThumbnailReply *reply = [QLThumbnailReply replyWithContextSize:size drawingBlock: ^BOOL(CGContextRef context) {
     21         return !GBQuickLookRender(context, (__bridge CFURLRef)request.fileURL, true);
     22     }];
     23     reply.iconFlavor = 0;
     24     handler(reply, nil);
     25 }
     26 
     27 @end

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.