• 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
Re: How do I put a GIF onto an NSPasteboard?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I put a GIF onto an NSPasteboard?


  • Subject: Re: How do I put a GIF onto an NSPasteboard?
  • From: Heinrich Giesen <email@hidden>
  • Date: Sun, 27 Nov 2005 16:45:43 +0100


On 27.11.2005, at 13:53, Pete Yandell wrote:

I have sample code to put a TIFF representation on the pasteboard,
and I have sample code to generate a GIF representation of an
NSImage, but I'm not sure how to set the pasteboard types correctly
for the GIF.

The usual way is to use an NSFilesPromisePboardType, which was a longer discussion in this list a long time ago.

Or you can write the gif data to the filesystem and use the NSFilenamesPboardType.

Or you cheat and write the gif data to the NSTIFFPboardType: (example)

NSPasteboard *pb = [NSPasteboard generalPasteboard];
NSBitmapImageRep *theRep;
[pb declareTypes:[NSArray arrayWithObject:NSTIFFPboardType] owner:self];

theRep = [NSImageRep imageRepWithContentsOfFile:@"anImagePath.jpg"];
NSData* gif = [theRep representationUsingType:NSGIFFileType properties:nil];
[pb setData:gif forType:NSTIFFPboardType];


This works pretty well because the pb has to contain data that can be
evaluated be [[NSImage alloc] initWithData:xxx] or initWithPasteboard:
The same is valid for similar methods of NSImageRep or NSBitmapImageRep.
Important are the data not the name.

I know of no application that refuses gif (or jpeg or png) data in a
pasteBoard with type NSTIFFPboardType.

BTW: as a gift you find also an image of NSPICTPboardType on the pasteBoard.

--
Heinrich Giesen
email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Prev by Date: Re: NSDate without time component
  • Next by Date: [OT] WebObjects licensing - Apple please clarify
  • Previous by thread: How do I put a GIF onto an NSPasteboard?
  • Next by thread: Embedding Custom NSView in an NSWindow
  • Index(es):
    • Date
    • Thread