• 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: Copying an image file to pasteboard
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Copying an image file to pasteboard


  • Subject: Re: Copying an image file to pasteboard
  • From: Ricky Sharp <email@hidden>
  • Date: Mon, 2 Aug 2004 15:56:44 -0500

On Aug 2, 2004, at 2:56 PM, Jeremy Dronfield wrote:

This question is so basic I can't even believe I'm having to ask it; but I can't find anything in the docs or archives, so here goes.

In the Finder, select an image file and hit Command-C to copy it, then open TextEdit and hit Command-V. The image is pasted in. Saving and opening the RTFD package, you will find that the image attachment inside has the title of the original image. Fine. So how was that image written to the pasteboard by the Finder? I have an application in which I want to be able to place images on the pasteboard for pasting into other apps. However, the only way I can get a pastable image onto the pasteboard is by doing [pboard setData:[image TIFFRepresentation] forType:NSTIFFPboardType]. This is clearly not the same thing. I've tried:

[pboard setPropertyList:[NSArray arrayWithObject:filePath] forType:NSFilenamesPboardType]

and

[pboard writeFileContents:filePath]

and creating a file wrapper from the file and using,

[pboard writeFileWrapper:wrapper]

and various combinations of these. None of them work. Can someone please tell me what I'm missing here?

Note that if TextEdit has a plain text document open, all you get pasted in is the filename. You do get the picture pasted in when it's a rich-text document.

Anyhow, definitely check out PasteboardPeeker if you have Mac OS X 10.3.x. It's a Carbon app, but it comes in very handy when you want to see what is put on the pasteboard. When copying a picture file in Finder, I got these types:

'utxt' - Unicode filename
'TEXT' - Plain text filename
'furl' - File URL (encoded i.e. space is )
'icns' - File icon
'PICT' - Pretty sure the preview picture
'hfs ' - File reference

What TextEdit is most likely doing is using either the File Reference or File URL, then making a copy of that file. If you want to provide image data other than TIFF, you could probably make a temp file of that type and point to it. That seems clunky though. Perhaps others will have a better solution where you can provide the image data however you like (e.g. JPEG).


PasteboardPeeker is at:

<http://developer.apple.com/samplecode/PasteboardPeeker/ PasteboardPeeker.html>

___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
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.


References: 
 >Copying an image file to pasteboard (From: Jeremy Dronfield <email@hidden>)

  • Prev by Date: Re: NSTask for interactive telnet
  • Next by Date: Re: Class Member Question
  • Previous by thread: Re: Copying an image file to pasteboard
  • Next by thread: Re: Class Member Question
  • Index(es):
    • Date
    • Thread