Link to home
Start Free TrialLog in
Avatar of privateson
privateson

asked on

How to Create UIImage from NSData and Avatar Data of XMPP?



Hi, This question is related to Iphone SDK, NSData and UIImage.

I am trying to create an image from the Avatar Data returned from the xmpp like the following: Away due to idle.0awaya3f549fa9705e7ead2905de0b6a804227ecdd404a3f549fa9705e7ead2905de0b6a804227ecdd404

So in this case, I assume that a3f549fa9705e7ead2905de0b6a804227ecdd404 is the photo data. So How can I transfer this into NSData?

I think if I can get the NSData object, I can easily create the UIImage, right?
Avatar of pgnatyuk
pgnatyuk
Flag of Israel image

It's not that easy. Or, maybe, I do not understand the problem and your program.
NSData is a class allowing to store raw data. It is useful if your app is downloading a file. Or if you need to save a data on disk.

This way works fine:

NSString *file = @"/Library/Test/test.png";
NSImage* image = [[NSImage alloc] initWithContentOfFile:file];
NSData* data = [image TIFFRepresentation];

[image release];

Opposite is a bit problem. At least you need to know the format of the data.

You can check this nice article:
Convert an NSImage to CIImage
http://theocacao.com/document.page/350/

Few comments under the article are interesting too.
ASKER CERTIFIED SOLUTION
Avatar of BeyondWu
BeyondWu
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial