I'm implementing a Photoshop plugin on the Mac, and I'm doing it using Cocoa. Doing ok so far, but the next step is to provide a "preview" image, as a part of my plugin window, and I'm stuck. I'm a n00b Obj-C programmer, which isn't really helping :-)
So far I've got something like this:
int dataSize = gFilterRecord->bigDocumentData->wholeSize32.v *
gFilterRecord->bigDocumentData->wholeSize32.h *
gFilterRecord->planes;
NSData *inData = [[NSData alloc] initWithBytesNoCopy:gFilterRecord->inData length:dataSize freeWhenDone:NO];
NSLog(@"LoadImageFromSDK : Data created");
NSImage *imageTmp = [[NSImage alloc] initWithData:inData];
NSLog(@"LoadImageFromSDK : Image created");
//Save to PNG file as a test of this image creation
[[imageTmp TIFFRepresentation] writeToFile:@"/tmp/imageTmp.tif" atomically:YES];
NSLog(@"LoadImageFromSDK : Wrote image to disk");
At the moment, it crashes horribly on:
09/07/22 10:23:32 AM Adobe Photoshop Elements[46628] *** NSCopyMemoryPages(0x0, 0x245f4000, 2265088) failed
I'm probably calculating the size of inData incorrectly. Help?
Also, is NSImage going to be able to interpret that image data blob correctly? Or should I give it up and just do a pixel-by-pixel mapping into the NSImage?