summaryrefslogtreecommitdiff
path: root/macosx/Pcsxr-QL/GeneratePreviewForURL.m
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/Pcsxr-QL/GeneratePreviewForURL.m')
-rw-r--r--macosx/Pcsxr-QL/GeneratePreviewForURL.m29
1 files changed, 17 insertions, 12 deletions
diff --git a/macosx/Pcsxr-QL/GeneratePreviewForURL.m b/macosx/Pcsxr-QL/GeneratePreviewForURL.m
index 164d6cfc..ae58b002 100644
--- a/macosx/Pcsxr-QL/GeneratePreviewForURL.m
+++ b/macosx/Pcsxr-QL/GeneratePreviewForURL.m
@@ -98,15 +98,22 @@ static OSStatus GeneratePreviewForMemCard(void *thisInterface, QLPreviewRequestR
Bundle = [[NSBundle alloc] initWithURL:bundURL];
}
int i = 0;
-
- NSDictionary *prep = @{(NSString *) kCGImagePropertyGIFDictionary: @{(NSString *) kCGImagePropertyGIFDelayTime: @0.2}};
-
+
+ NSDictionary *gifPrep = @{(NSString *) kCGImagePropertyGIFDictionary: @{(NSString *) kCGImagePropertyGIFDelayTime: @0.30f}};
+
for (PcsxrMemoryObject *obj in memCards) {
- if (obj.memIconCount == -1 || obj.memIconCount == 1) {
+ if (obj.memImageIndex == -1 || obj.memIconCount == 1) {
+ NSMutableData *pngData = [NSMutableData new];
+ CGImageDestinationRef dst = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)pngData, kUTTypePNG, 1, NULL);
NSImage *theImage = [obj firstMemImage];
- NSData *tiffData = [theImage TIFFRepresentation];
- NSBitmapImageRep *bmImg = [NSBitmapImageRep imageRepWithData:tiffData];
- NSData *pngData = [bmImg representationUsingType:NSPNGFileType properties:nil];
+ NSRect smallRect = NSMakeRect(0, 0, 16, 16);
+
+ CGImageRef imageRef = [theImage CGImageForProposedRect:&smallRect context:nil hints:nil];
+ CGImageDestinationAddImage(dst, imageRef, NULL);
+
+ CGImageDestinationFinalize(dst);
+ CFRelease(dst);
+
NSDictionary *imgProps = @{(NSString *)kQLPreviewPropertyAttachmentDataKey: pngData,
(NSString *)kQLPreviewPropertyMIMETypeKey: @"image/png"};
NSString *imgName = [[@(i++) stringValue] stringByAppendingPathExtension:@"png"];
@@ -117,11 +124,9 @@ static OSStatus GeneratePreviewForMemCard(void *thisInterface, QLPreviewRequestR
NSMutableData *gifData = [NSMutableData new];
CGImageDestinationRef dst = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)gifData, kUTTypeGIF, obj.memIconCount, NULL);
- for (NSInteger j = 0; j < obj.memIconCount; j++) {
- NSImage *theImage = [obj memoryImageAtIndex:j];
-
- CGImageRef imageRef=[theImage CGImageForProposedRect:nil context:nil hints:nil];
- CGImageDestinationAddImage(dst, imageRef,(__bridge CFDictionaryRef)(prep));
+ for (NSImage *theImage in obj.memoryCardImages) {
+ CGImageRef imageRef = [theImage CGImageForProposedRect:NULL context:nil hints:nil];
+ CGImageDestinationAddImage(dst, imageRef,(__bridge CFDictionaryRef)(gifPrep));
}
CGImageDestinationFinalize(dst);
CFRelease(dst);