NSImage to PICT
NSImage to PICT
- Subject: NSImage to PICT
- From: olivier <email@hidden>
- Date: Wed, 23 Jul 2003 11:30:03 -0500
For the benefit of all:
#import <QuickTime/QuickTime.h>
@implementation NSImage (pictExport)
- (NSData*) pictRepresentation
{
MovieImportComponent importer;
if (OpenADefaultComponent(GraphicsImporterComponentType,
kQTFileTypeTIFF, &importer) != noErr)
{
CloseComponent(importer);
return nil;
}
Handle imageHandle;
NSData *imageData = [self TIFFRepresentation];
long int dataSize = [imageData length];
(void)PtrToHand([imageData bytes], &imageHandle, dataSize);
OSErr err = GraphicsImportSetDataHandle(importer, imageHandle);
if (err != noErr)
{
return nil;
}
PicHandle resultPicHandle = (PicHandle)NewHandleClear(20);
err = GraphicsImportGetAsPicture(importer, &resultPicHandle) ;
NSData *returnValue = [NSData dataWithBytes:*resultPicHandle
length:(int)GetHandleSize((Handle)test)];
DisposeHandle((Handle)test);
return returnValue;
}
@end
Olivier
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.