UIImage ——> NSData
UIKIT_EXTERN
NSData
*UIImagePNGRepresentation(
UIImage
*image);
// return image as PNG. May return nil if image has no CGImageRef or invalid bitmap format
UIKIT_EXTERN NSData *UIImageJPEGRepresentation( UIImage *image, CGFloat compressionQuality); // return image as JPEG. May return nil if image has no CGImageRef or invalid bitmap format. compression is 0(most)..1(least)
UIKIT_EXTERN NSData *UIImageJPEGRepresentation( UIImage *image, CGFloat compressionQuality); // return image as JPEG. May return nil if image has no CGImageRef or invalid bitmap format. compression is 0(most)..1(least)
UIImage *addPic = [UIImage imageNamed: @"ko.png"];
NSData *imageData = UIImagePNGRepresentation(addPic);// png格式
// NSData *imageData = UIImageJPEGRepresentation(addPic, 1);// jpeg格式
[picker addAttachmentData: imageData mimeType: @"" fileName:@"ko.png”];
NSData——> UIImage
+ (UIImage *)imageWithData:(NSData *)data;
+ (UIImage *)imageWithData:(NSData *)data scale:(CGFloat)scale NS_AVAILABLE_IOS(6_0);
UIImage *img = [UIImage imageWithData:self.message.imageData];