diff options
| author | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2014-08-06 19:39:04 +0000 |
|---|---|---|
| committer | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2014-08-06 19:39:04 +0000 |
| commit | 2863112f258b1c3618d0b454cff96d81a4dc618d (patch) | |
| tree | 206a509df8b3326810692b81148ee95ea0bac4aa /macosx/Pcsxr-QL/GeneratePreviewForURL.m | |
| parent | f629ca7098a057086b1a15df93f3fc58b058c4b8 (diff) | |
| download | pcsxr-2863112f258b1c3618d0b454cff96d81a4dc618d.tar.gz | |
OS X: QuickLook: some minor tweaking.
The generator will use the same APIs as the gif generator if there is only one image. It will still generate a PNG file.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@91192 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'macosx/Pcsxr-QL/GeneratePreviewForURL.m')
| -rw-r--r-- | macosx/Pcsxr-QL/GeneratePreviewForURL.m | 29 |
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); |
