How to get tiff from clipboard and convert to bmp?
How to get tiff from clipboard and convert to bmp?
- Subject: How to get tiff from clipboard and convert to bmp?
- From: zhiy xue <email@hidden>
- Date: Fri, 2 Apr 2010 10:35:50 +0800
I want to support get *.tiff data from clipboard, and convert it to
bmp format. Below is my code, but it will crash in
GetGraphicsImporterForDataRef. Could you please help? Many thanks for
your help.
NSPasteboard* pPasteboard = [NSPasteboard generalPasteboard];
[pPasteboard retain];
ComponentInstance gi = 0;
NSData* data = [pPasteboard dataForType: NSTIFFPboardType];
Handle hPict = NewHandle([data length]);
HLock(hPict);
memcpy(*hPict, [data bytes], [data length]);
HUnlock(hPict);
//Crash here. Anything was wrong?
if(GetGraphicsImporterForDataRef(hPict, HandleDataHandlerSubType,
&gi) != noErr)
return;
long unsigned int imageCount = 0;
if(GraphicsImportGetImageCount(gi, &imageCount) != noErr)
return result;
GraphicsImportSetImageIndex(gi, 0);
PicHandle hPicH;
GraphicsImportGetAsPicture(gi, &hPicH);
DisposeHandle(hPict);
CloseComponent(gi);
[pPasteboard release];
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden