• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to get tiff from clipboard and convert to bmp?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: How to get tiff from clipboard and convert to bmp?
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: Creating WebView in code
  • Next by Date: Problem to save a CIImage using a CGImageRef
  • Previous by thread: Re: Creating WebView in code
  • Next by thread: Re: How to get tiff from clipboard and convert to bmp?
  • Index(es):
    • Date
    • Thread