diff options
| author | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2014-03-28 23:34:09 +0000 |
|---|---|---|
| committer | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2014-03-28 23:34:09 +0000 |
| commit | dca90ae6a6e6472c0fd597598651e10c4414be34 (patch) | |
| tree | 6beee48ba8a3765380eb8ab7a0bccb9ef3d71c09 /macosx/Pcsxr-QL/GeneratePreviewForURL.m | |
| parent | ebfb89de00860bbdbb6e9a72ed18a358acc7c056 (diff) | |
| download | pcsxr-dca90ae6a6e6472c0fd597598651e10c4414be34.tar.gz | |
OS X: More work on the QuickLook plug-in.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@89710 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'macosx/Pcsxr-QL/GeneratePreviewForURL.m')
| -rw-r--r-- | macosx/Pcsxr-QL/GeneratePreviewForURL.m | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/macosx/Pcsxr-QL/GeneratePreviewForURL.m b/macosx/Pcsxr-QL/GeneratePreviewForURL.m new file mode 100644 index 00000000..106f1bfb --- /dev/null +++ b/macosx/Pcsxr-QL/GeneratePreviewForURL.m @@ -0,0 +1,55 @@ +#include <CoreFoundation/CoreFoundation.h> +#include <CoreServices/CoreServices.h> +#include <QuickLook/QuickLook.h> +#include "MyQuickLook.h" +#include <zlib.h> +#import <Foundation/Foundation.h> +#include "nopic.h" + +/* ----------------------------------------------------------------------------- + Generate a preview for file + + This function's job is to create preview for designated file + ----------------------------------------------------------------------------- */ + +OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options) +{ + @autoreleasepool { + NSData *data; + NSURL *urlNS = (__bridge NSURL *)(url); + gzFile f; + const char* state_filename; + if ([urlNS respondsToSelector:@selector(fileSystemRepresentation)]) { + state_filename = [urlNS fileSystemRepresentation]; + } else { + state_filename = [[urlNS path] fileSystemRepresentation]; + } + + unsigned char *pMem = (unsigned char *) malloc(128*96*3); + if (pMem == NULL) + return mFulErr; + + f = gzopen(state_filename, "rb"); + if (f != NULL) { + gzseek(f, 32, SEEK_SET); // skip header + gzseek(f, sizeof(uint32_t), SEEK_CUR); + gzseek(f, sizeof(uint8_t), SEEK_CUR); + gzread(f, pMem, 128*96*3); + gzclose(f); + + memcpy(pMem, NoPic_Image.pixel_data, 128*96*3); + } + NSBitmapImageRep *imRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:(unsigned char**)&NoPic_Image.pixel_data pixelsWide:NoPic_Image.width pixelsHigh:NoPic_Image.height bitsPerSample:8 samplesPerPixel:3 hasAlpha:NO isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace bitmapFormat:0 bytesPerRow:NoPic_Image.width * NoPic_Image.bytes_per_pixel bitsPerPixel:24]; + if (imRep) { + data = [imRep TIFFRepresentation]; + QLPreviewRequestSetDataRepresentation(preview, (__bridge CFDataRef)(data), kUTTypeImage, NULL); + } + + return noErr; + } +} + +void CancelPreviewGeneration(void *thisInterface, QLPreviewRequestRef preview) +{ + // Implement only if supported +} |
