• 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: determining format of NSImageRep
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: determining format of NSImageRep


  • Subject: Re: determining format of NSImageRep
  • From: "John C. Randolph" <email@hidden>
  • Date: Mon, 24 Mar 2003 16:49:06 -0800

On Monday, March 24, 2003, at 04:17 PM, Mark J. Lilback wrote:

My program has received an NSData* that contains image data. I have no idea what format. So I call [[NSImage alloc] initWithData: data] and if it returns something, I know I have a valid image.

Now I want to save this again, after the user possibly modified the image (or replaced the image with a new one). I need an NSData with the raw data in the same format as the original.

I know I can call representationUsingType:properties:, but how can I determine what the original image type was?

The best method I can see is to call [NSImageRep imageRepClassForData: data] and then look for the known classes that implement the basic types for jpg, gif, png, etc. But it seems really strange for me that there is no message that returns what format an image is.

Well, what you're actually asking for here is to know what the image file *was*, before it was interpreted by one of the imageRep classes' -initWith... routines. An NSBitmapImageRep doesn't know whether the pixels it contains came from a .jpeg, a .gif or anything else.

The best way I can think of to know what kind of image format is in the NSData object is to look for the known headers of various image types. (JFIF, etc.)

-jcr



John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
http://developer.apple.com/cocoa/index.html
_______________________________________________
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.

  • Follow-Ups:
    • Re: determining format of NSImageRep
      • From: "Mark J. Lilback" <email@hidden>
    • Re: determining format of NSImageRep
      • From: Sherm Pendley <email@hidden>
References: 
 >determining format of NSImageRep (From: "Mark J. Lilback" <email@hidden>)

  • Prev by Date: Re: one NSPipe, multiple NSTasks?
  • Next by Date: (no subject)
  • Previous by thread: determining format of NSImageRep
  • Next by thread: Re: determining format of NSImageRep
  • Index(es):
    • Date
    • Thread