• 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: Creating NSImage with NSData
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating NSImage with NSData


  • Subject: Re: Creating NSImage with NSData
  • From: Robert Cerny <email@hidden>
  • Date: Mon, 15 Mar 2004 12:53:58 +0100

Hi,

- (id)initWithData:(NSData *)data
Initializes the receiver, a newly allocated NSImage instance, with the contents of the data object data. If initWithData: is able to create one or more image representations, it returns self. Otherwise, the receiver is freed, and nil is returned.

if you're getting nil, it means that the NSImage cannot be created using known representations. You need to create the representation manually and than init NSImage from it.

HTH
Robert

On 15.3.2004, at 11:24, Mark Woollard wrote:

I have a jpg of image data extracted from part of a file. I thought I
should be able to create an NSImage directly from this data as follows:

NSData *data = [NSData dataWithBytes:p length:len];
m_image = [[NSImage alloc] initWithData:data];

Where p is a pointer to the data buffer and len the length of the data.
However, m_image is null after the code is executed. I have added test
code to write out the NSData buffer to file and the resulting file can
be opened and displayed just as any other jpg image on the system, so I
conclude the code extracting the image from the file in question is OK,
and the buffer contains a valid jpg. Am I mis-understanding what
initWithData does?

Thanks
Mark
_______________________________________________
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.
_______________________________________________
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: Creating NSImage with NSData
      • From: Mark Woollard <email@hidden>
References: 
 >Creating NSImage with NSData (From: Mark Woollard <email@hidden>)

  • Prev by Date: Re: Frameworks & Nibs
  • Next by Date: Re: Creating NSImage with NSData
  • Previous by thread: Creating NSImage with NSData
  • Next by thread: Re: Creating NSImage with NSData
  • Index(es):
    • Date
    • Thread