• 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: Reading image from system clipboard
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading image from system clipboard


  • Subject: Re: Reading image from system clipboard
  • From: Graham Cox <email@hidden>
  • Date: Mon, 3 Aug 2009 19:51:34 +1000


On 03/08/2009, at 4:07 PM, Deepa wrote:

I am developing an desktop app for which I want to implement a behavior which is similar to 'New from clipboard' of Preview application.

I tried using NSPasteboard:

// To get file copied to clipboard from Finder
NSArray *files = [[NSPasteboard generalPasteboard] propertyListForType: NSFilenamesPboardType];


This returns array of files copied to the clipboard

// To get tiff image
NSData *pbData = [[NSPasteboard generalPasteboard] dataForType: NSTIFFPboardType];
CIImage *pbImg = [CIImage imageWithData: pbData];


But this doesn't return null (tiff image data was copied to the clipboard).

Am I doing something wrong here???

Can someone help me out to sove this problem. I also wanted to know a method which copies and reads jpeg/gif/png image formats to/from system clipboard.


It's not clear what the problem is.

Do you want image data or not? Preview's 'New from clipboard' is looking for image data.

Normally when you read a pasteboard, you should pass it a list of types using -availableTypeFromArray:, where the array you give it indicates your *preferred order*. The type returned is the first matching type found, so if you prefer image data over file data, you list the image type first. It is up to the receiving application to set the preferred order, not the sending application, which has no idea who might make use of which copied data.

So if you want to read an image, you might prefer the order PDF, TIFF, File... then deal appropriately with whichever one you get back.

--Graham


_______________________________________________

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


References: 
 >Reading image from system clipboard (From: Deepa <email@hidden>)

  • Prev by Date: [IB] - can't assign keyboard shortcut to a menu item
  • Next by Date: [iPhone] Get rid of the default navigation back button
  • Previous by thread: Reading image from system clipboard
  • Next by thread: text control for keyboard shortcut input?
  • Index(es):
    • Date
    • Thread