NSData and UIImage

后端 未结 5 1971
孤独总比滥情好
孤独总比滥情好 2020-12-13 03:51

I am trying to load UIImage object from NSData, and the sample code was to NSImage, I guess they should be the same. But just now load

5条回答
  •  孤街浪徒
    2020-12-13 04:08

    I didn't try UIImageJPEGRepresentation() before, but UIImagePNGRepresentation works fine for me, and conversion between NSData and UIImage is dead simple:

    NSData *imageData = UIImagePNGRepresentation(image);
    UIImage *image=[UIImage imageWithData:imageData];
    

提交回复
热议问题