• 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: Sending an image to Preview to preview the image
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sending an image to Preview to preview the image


  • Subject: Re: Sending an image to Preview to preview the image
  • From: Bill <email@hidden>
  • Date: Tue, 6 May 2008 15:40:42 -0700


On May 6, 2008, at 3:31 PM, Michael Watson wrote:
Thoughts:

1. Why not build your own preview panel/window? It's remarkably easy to do if you already have the image data in an NSData object.

True, but preview has other advantages, such as saving the file to various formats. Sure I could do all that, but since that functionality already exists in Preview....



2. If you must use Preview, you could write the image to a temp file and tell Preview to open that via NSWorkspace's - openFile:withApplication: method.

I tried that also, but then there is that temp file that could end up in the Recovered Items folder in the Trash. That method also exposes the temp folder in Preview (which is probably not a big deal, but it looks odd).


Thanks,
k


--
m-s

On 06 May, 2008, at 18:08, Kimo wrote:

My app produces a list of images (NSData format), and I'd like the app Preview to display the image when the user double-clicks on an image in my app.

Currently I use NSPerformService as shown below, which works, but Preview always asks to save the file when you close its window. I've seen other apps where you double-click an image and Preview opens a window with a title something like "Preview of ...." and it doesn't try to save the image when you close the window.

To send an image to Preview using NSPerformService:
NSData *data; /* assume exists */
NSPasteboard *pb = [NSPasteboard pasteboardWithUniqueName];
[pb declareTypes:[NSArray arrayWithObject:NSTIFFPboardType] owner:nil];
[pb setData:data forType:NSTIFFPboardType];
NSPerformService( @"Preview/Open images", pb );


It works, but is there a better way to send image data to Preview?
Thanks in advance!


_______________________________________________

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: Sending an image to Preview to preview the image
      • From: Ricky Sharp <email@hidden>
References: 
 >Sending an image to Preview to preview the image (From: Kimo <email@hidden>)
 >Re: Sending an image to Preview to preview the image (From: Michael Watson <email@hidden>)

  • Prev by Date: Re: How to convert UInt8 array to NSString
  • Next by Date: Re: Sending an image to Preview to preview the image
  • Previous by thread: Re: Sending an image to Preview to preview the image
  • Next by thread: Re: Sending an image to Preview to preview the image
  • Index(es):
    • Date
    • Thread