Re: NSImage to PICT (corrected)
Re: NSImage to PICT (corrected)
- Subject: Re: NSImage to PICT (corrected)
- From: olivier <email@hidden>
- Date: Wed, 23 Jul 2003 12:37:37 -0500
i was too quick to post, here is the same code without the typo:
#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)resultPicHandle)];
DisposeHandle((Handle)resultPicHandle);
return returnValue;
}
@end
_______________________________________________
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.