Creating NSImage with NSData
Creating NSImage with NSData
- Subject: Creating NSImage with NSData
- From: Mark Woollard <email@hidden>
- Date: Mon, 15 Mar 2004 10:24:14 +0000
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] initWith
Data: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.