码迷,mamicode.com
首页 > 移动开发 > 详细

iOS 字符串和图片互转

时间:2014-08-01 13:13:01      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:os   io   for   ar   size   res   log   ios   

    for (UIImage *myImg in _imgArray)

    {

        NSData *imageData = UIImageJPEGRepresentation(myImg,0.5);

        NSString *_encodedImageStr = [imageData base64Encoding];

        [parameters setObject:_encodedImageStr forKey:[NSString stringWithFormat:@"img[%i]",imgCount]];

        imgCount ++;

    }

 

 

Base64字符串转UIImage图片:

NSData *_decodedImageData   = [[NSData alloc] initWithBase64Encoding:_encodedImageStr];

 

UIImage *_decodedImage      = [UIImage imageWithData:_decodedImageData];

 

NSLog(@"===Decoded image size: %@", NSStringFromCGSize(_decodedImage.size));

 

 

UIImage图片转成base64字符串:

UIImage *_originImage = [UIImage imageNamed:@"full_playlist_hl.png"];

 

NSData *_data = UIImageJPEGRepresentation(_image, 1.0f);

 

NSString *_encodedImageStr = [_data base64Encoding];

 

NSLog(@"===Encoded image:\n%@", _encodedImageStr);

iOS 字符串和图片互转,布布扣,bubuko.com

iOS 字符串和图片互转

标签:os   io   for   ar   size   res   log   ios   

原文地址:http://www.cnblogs.com/Ewenblog/p/3884525.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!