summaryrefslogtreecommitdiff
path: root/macosx/Pcsxr-QL/GeneratePreviewForURL.m
diff options
context:
space:
mode:
authorSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2014-07-21 20:23:01 +0000
committerSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2014-07-21 20:23:01 +0000
commit50630078a5b4891fe0b50a6cadb7514bfc8d4f11 (patch)
tree6bc3e89137c1dd8fc587d5d652b81d7f9394adc2 /macosx/Pcsxr-QL/GeneratePreviewForURL.m
parent2a782df55ef84eba063c60401358da11df680c81 (diff)
downloadpcsxr-50630078a5b4891fe0b50a6cadb7514bfc8d4f11.tar.gz
OS X: Implement the memory card QuickLook preview.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@91017 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'macosx/Pcsxr-QL/GeneratePreviewForURL.m')
-rw-r--r--macosx/Pcsxr-QL/GeneratePreviewForURL.m28
1 files changed, 27 insertions, 1 deletions
diff --git a/macosx/Pcsxr-QL/GeneratePreviewForURL.m b/macosx/Pcsxr-QL/GeneratePreviewForURL.m
index 619a5cee..24031a1c 100644
--- a/macosx/Pcsxr-QL/GeneratePreviewForURL.m
+++ b/macosx/Pcsxr-QL/GeneratePreviewForURL.m
@@ -84,5 +84,31 @@ OSStatus GeneratePreviewForFreeze(void *thisInterface, QLPreviewRequestRef previ
static OSStatus GeneratePreviewForMemCard(void *thisInterface, QLPreviewRequestRef preview, NSURL *url, NSDictionary *options)
{
NSArray *memCards = CreateArrayByEnumeratingMemoryCardAtURL(url);
- return unimpErr;
+ NSMutableString *htmlStr = [[NSMutableString alloc] initWithCapacity:memCards.count * 200];
+ NSMutableDictionary *htmlDict = [[NSMutableDictionary alloc] initWithCapacity:memCards.count];
+ int i;
+ for (PcsxrMemoryObject *obj in memCards) {
+ NSImage *theImage = [obj firstMemImage];
+ NSData *tiffData = [theImage TIFFRepresentation];
+ NSBitmapImageRep *bmImg = [NSBitmapImageRep imageRepWithData:tiffData];
+ NSData *pngData = [bmImg representationUsingType:NSPNGFileType properties:nil];
+ NSDictionary *imgProps = @{(NSString *)kQLPreviewPropertyAttachmentDataKey: pngData,
+ (NSString *)kQLPreviewPropertyMIMETypeKey: @"image/png"};
+ NSString *imgName = [[@(i++) stringValue] stringByAppendingPathComponent:@"png"];
+ [htmlStr appendFormat:@"<tr><td><img src=\"cid:%@\"></td><td>%@</td><td>%i</td></tr>\n", imgName, obj.sjisName, obj.blockSize];
+ htmlDict[imgName] = imgProps;
+ }
+
+ NSString *theStr = [[NSString alloc] initWithFormat:@"<html>\n<body>\n<table>\n<tr><td ALIGN=center>Image</td><td ALIGN=name>Image</td><td ALIGN=center>Count</td></tr>%@\n</table>\n</body>\n</html>", htmlStr];
+
+ NSData *data = [theStr dataUsingEncoding:NSUTF8StringEncoding];
+ NSDictionary *previewDict =
+ @{(NSString *)kQLPreviewPropertyAttachmentsKey: htmlDict,
+ (NSString *)kQLPreviewPropertyDisplayNameKey: [url lastPathComponent],
+ (NSString *)kQLPreviewPropertyWidthKey: @400,
+ (NSString *)kQLPreviewPropertyHeightKey: @400};
+
+ QLPreviewRequestSetDataRepresentation(preview, (__bridge CFDataRef)(data), kUTTypeHTML, (__bridge CFDictionaryRef)(previewDict));
+
+ return noErr;
}